From efc94b9559b566385b2d23318bd61f90ce7910c8 Mon Sep 17 00:00:00 2001 From: David Drysdale Date: Sat, 18 Mar 2017 08:54:27 +0000 Subject: [PATCH] test: try building fuzz binaries on Windows --- appveyor.yml | 1 + test/Makefile.m32 | 15 +++++++++++++-- test/Makefile.msvc | 37 +++++++++++++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 4426accd..35dc4333 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,3 +11,4 @@ build_script: - if "%platform%" == "mingw" ( mingw32-make.exe -f Makefile.m32 demos ) else ( nmake /f Makefile.msvc ) - cd test - if "%platform%" == "mingw" ( mingw32-make.exe -f Makefile.m32 ) else ( nmake /f Makefile.msvc vtest ) + - if "%platform%" == "mingw" ( mingw32-make.exe -f Makefile.m32 aresfuzz.exe aresfuzzname.exe ) else ( nmake /f Makefile.msvc aresfuzz aresfuzzname ) diff --git a/test/Makefile.m32 b/test/Makefile.m32 index 4c97674c..04aceeb5 100644 --- a/test/Makefile.m32 +++ b/test/Makefile.m32 @@ -5,6 +5,7 @@ # ######################################################## CXX = g++ +CC = gcc LD = g++ # Where to find the c-ares source code; needed because the tests use library-internal headers @@ -23,16 +24,26 @@ LDLIBS = -lwsock32 include Makefile.inc OBJS := $(patsubst %.cc,%.o,$(strip $(TESTSOURCES))) +FUZZOBJS := $(patsubst %.c,%.o,$(strip $(FUZZSOURCES))) +FUZZNAMEOBJS := $(patsubst %.c,%.o,$(strip $(FUZZNAMESOURCES))) -all: arestest.exe +all: arestest.exe aresfuzz.exe aresfuzzname.exe arestest.exe: $(OBJS) gmock-all.o gtest-all.o $(LD) $(LDFLAGS) -o $@ $^ -L$(ARES_BLD_DIR) -lcares $(LDLIBS) +aresfuzz.exe: $(FUZZOBJS) + $(LD) $(LDFLAGS) -o $@ $^ -L$(ARES_BLD_DIR) -lcares $(LDLIBS) + +aresfuzzname.exe: $(FUZZNAMEOBJS) + $(LD) $(LDFLAGS) -o $@ $^ -L$(ARES_BLD_DIR) -lcares $(LDLIBS) + $(OBJS): $(TESTHEADERS) .cc.o: $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< +.c.o: + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< gmock-all.o: $(GMOCK_DIR)/src/gmock-all.cc $(CXX) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CPPFLAGS) $(CXXFLAGS) -c $< gtest-all.o: $(GTEST_DIR)/src/gtest-all.cc @@ -44,5 +55,5 @@ vtest: arestest.exe ./arestest.exe -v clean: - $(RM) $(OBJS) gmock-all.o gtest-all.o arestest.exe + $(RM) $(OBJS) gmock-all.o gtest-all.o arestest.exe aresfuzz.exe aresfuzzname.exe diff --git a/test/Makefile.msvc b/test/Makefile.msvc index d0745e96..0e9fe564 100644 --- a/test/Makefile.msvc +++ b/test/Makefile.msvc @@ -109,7 +109,7 @@ VALID_CFGSET = TRUE ! MESSAGE Usage: nmake /f makefile.msvc CFG= ! MESSAGE ! MESSAGE can be one of: [ lib-release | lib-debug | dll-release | dll-debug } -! MESSAGE can be one of: [ all | arestest | clean } +! MESSAGE can be one of: [ all | arestest | aresfuzz | aresfuzzname | clean } ! MESSAGE ! MESSAGE If is not specified then all targets are built. ! MESSAGE If is not specified then lib-debug will be assumed. @@ -252,6 +252,25 @@ RC_CMD = $(RC_CMD_DBG) !ERROR Problem generating PROG_OBJS list. !ENDIF PROG_OBJS = $(PROG_OBJS:.cc=.obj) + +!IF [ECHO FUZZ_OBJS=^$(PROG_OBJDIR)\$(FUZZSOURCES: = $(PROG_OBJDIR^)\) > .\fuzz_objs.inc] == 0 +!INCLUDE .\fuzz_objs.inc +!IF [DEL .\fuzz_objs.inc] +!ENDIF +!ELSE +!ERROR Problem generating FUZZ_OBJS list. +!ENDIF +FUZZ_OBJS = $(FUZZ_OBJS:.c=.obj) + +!IF [ECHO FUZZNAME_OBJS=^$(PROG_OBJDIR)\$(FUZZNAMESOURCES: = $(PROG_OBJDIR^)\) > .\fuzzname_objs.inc] == 0 +!INCLUDE .\fuzzname_objs.inc +!IF [DEL .\fuzzname_objs.inc] +!ENDIF +!ELSE +!ERROR Problem generating FUZZNAME_OBJS list. +!ENDIF +FUZZNAME_OBJS = $(FUZZNAME_OBJS:.c=.obj) + GTEST_OBJ = $(PROG_OBJDIR)\gtest-all.obj GMOCK_OBJ = $(PROG_OBJDIR)\gmock-all.obj @@ -260,10 +279,12 @@ GMOCK_OBJ = $(PROG_OBJDIR)\gmock-all.obj # -------------------------------- .SUFFIXES: -.SUFFIXES: .cc +.SUFFIXES: .cc .c {$(SRCDIR)}.cc{$(PROG_OBJDIR)}.obj: $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< +{$(SRCDIR)}.c{$(PROG_OBJDIR)}.obj: + $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< {$(GMOCK_SRC_DIR)}.cc{$(PROG_OBJDIR)}.obj: $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /I $(GMOCK_DIR) /Fo$@ /Fd$(@D)\ /c $< {$(GTEST_SRC_DIR)}.cc{$(PROG_OBJDIR)}.obj: @@ -274,7 +295,7 @@ GMOCK_OBJ = $(PROG_OBJDIR)\gmock-all.obj # Main targets # --------------------------------------------------------------------- -ALL: arestest +ALL: arestest aresfuzz aresfuzzname @ test: arestest @@ -282,10 +303,18 @@ test: arestest vtest: arestest $(PROG_OUTDIR)\arestest -v -arestest: $(TESTSOURCES) $(PROB_OUTDIR) $(PROG_OBJDIR) $(PROG_OBJS) $(GTEST_OBJ) $(GMOCK_OBJ) +arestest: $(TESTSOURCES) $(PROG_OUTDIR) $(PROG_OBJDIR) $(PROG_OBJS) $(GTEST_OBJ) $(GMOCK_OBJ) $(SPROG_LINK) $(SPROG_LFLAGS) /out:$(PROG_OUTDIR)\arestest.exe $(PROG_OBJS) $(GTEST_OBJ) $(GMOCK_OBJ) @if exist $(PROG_OUTDIR)\arestest.exe.manifest mt -nologo -manifest $(PROG_OUTDIR)\arestest.exe.manifest -outputresource:$(PROG_OUTDIR)\arestest.exe;1 +aresfuzz: $(FUZZSOURCES) $(PROG_OUTDIR) $(PROG_OBJDIR) $(FUZZ_OBJS) + $(SPROG_LINK) $(SPROG_LFLAGS) /out:$(PROG_OUTDIR)\aresfuzz.exe $(FUZZ_OBJS) + @if exist $(PROG_OUTDIR)\aresfuzz.exe.manifest mt -nologo -manifest $(PROG_OUTDIR)\aresfuzz.exe.manifest -outputresource:$(PROG_OUTDIR)\aresfuzz.exe;1 + +aresfuzzname: $(FUZZNAMESOURCES) $(PROG_OUTDIR) $(PROG_OBJDIR) $(FUZZNAME_OBJS) + $(SPROG_LINK) $(SPROG_LFLAGS) /out:$(PROG_OUTDIR)\aresfuzzname.exe $(FUZZNAME_OBJS) + @if exist $(PROG_OUTDIR)\aresfuzzname.exe.manifest mt -nologo -manifest $(PROG_OUTDIR)\aresfuzzname.exe.manifest -outputresource:$(PROG_OUTDIR)\aresfuzzname.exe;1 + $(PROG_OUTDIR): $(PROG_DIR) @if not exist $(PROG_OUTDIR) mkdir $(PROG_OUTDIR)