diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2022-03-16 11:03:57 +0100 |
---|---|---|
committer | lns <matzeton@googlemail.com> | 2022-04-14 19:17:48 +0200 |
commit | c3df3a12aa88739e303340ccd7436d467b4662d2 (patch) | |
tree | 13355914f93b668afb47f2b5b643dffc073fb8e7 /tests | |
parent | 4775be3d85434d4e385f43a47b783844bbfb2571 (diff) |
Fixed msys2 build warnings and re-activated CI Mingw64 build.fix/windows-msys2
* Removed Visual Studio leftovers. Maintaining an autotools project with VS integration requires some additional overhead.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dga/Makefile.in | 23 | ||||
-rwxr-xr-x | tests/do.sh.in | 44 | ||||
-rw-r--r-- | tests/result/kerberos_fuzz.pcapng.out | 2 | ||||
-rw-r--r-- | tests/result/telnet.pcap.out | 3 | ||||
-rw-r--r-- | tests/unit/Makefile.in | 35 | ||||
-rw-r--r-- | tests/unit/unit.c | 21 |
6 files changed, 80 insertions, 48 deletions
diff --git a/tests/dga/Makefile.in b/tests/dga/Makefile.in index e2846830e..efa8b188b 100644 --- a/tests/dga/Makefile.in +++ b/tests/dga/Makefile.in @@ -1,36 +1,33 @@ CC=@CC@ CXX=@CXX@ -BUILD_MINGW=@BUILD_MINGW@ +EXE_SUFFIX=@EXE_SUFFIX@ SRCHOME=../../src -CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @JSONC_CFLAGS@ @PCAP_INC@ @CFLAGS@ +ifneq ($(OS),Windows_NT) +CFLAGS+=-fPIC -DPIC +endif +CFLAGS+=-g -I$(SRCHOME)/include @CFLAGS@ LIBNDPI=$(SRCHOME)/lib/libndpi.a -LIBS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ @ADDITIONAL_LIBS@ @JSONC_LIBS@ -lpthread +LIBS=$(LIBNDPI) @LIBS@ @ADDITIONAL_LIBS@ -lpthread LDFLAGS=@LDFLAGS@ HEADERS=$(SRCHOME)/include/ndpi_api.h $(SRCHOME)/include/ndpi_typedefs.h $(SRCHOME)/include/ndpi_protocol_ids.h OBJS=dga_evaluate PREFIX?=@prefix@ -ifneq ($(BUILD_MINGW),) -all: - @echo 'DGA test disabled due to mingw build.' - -else - -all: dga_evaluate +all: dga_evaluate$(EXE_SUFFIX) EXECUTABLE_SOURCES := dga_evaluate.c COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c )) -dga_evaluate: $(LIBNDPI) dga_evaluate.o +dga_evaluate$(EXE_SUFFIX): $(LIBNDPI) dga_evaluate.o $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) dga_evaluate.o $(LIBS) -o $@ %.o: %.c $(HEADERS) Makefile $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ clean: - /bin/rm -f *.o dga_evaluate + /bin/rm -f *.o dga_evaluate$(EXE_SUFFIX) /bin/rm -f .*.o.cmd .*.o.d /bin/rm -rf build @@ -42,5 +39,3 @@ distdir: distclean: clean /bin/rm -f Makefile - -endif diff --git a/tests/do.sh.in b/tests/do.sh.in index dc4ed6a92..120b66b28 100755 --- a/tests/do.sh.in +++ b/tests/do.sh.in @@ -3,26 +3,29 @@ cd "$(dirname "${0}")" FUZZY_TESTING_ENABLED=@BUILD_FUZZTARGETS@ -if [ "$NDPI_DISABLE_FUZZY" = "1" ]; then +if [ "${NDPI_DISABLE_FUZZY}" = "1" ]; then FUZZY_TESTING_ENABLED=0 fi #Remember: valgrind and *SAN are incompatible! -VALGRIND="" -if [ "$NDPI_TESTS_VALGRIND" = "1" ]; then - VALGRIND="valgrind -q --leak-check=full" +CMD_PREFIX="${CMD_PREFIX}" +if [ "${NDPI_TESTS_WINE}" = "1" ]; then + CMD_PREFIX="wine" +elif [ "${NDPI_TESTS_VALGRIND}" = "1" ]; then + CMD_PREFIX="valgrind -q --leak-check=full" fi +EXE_SUFFIX=@EXE_SUFFIX@ PCRE_ENABLED=@PCRE_ENABLED@ PCRE_PCAPS="WebattackRCE.pcap" GCRYPT_PCAPS="gquic.pcap quic-23.pcap quic-24.pcap quic-27.pcap quic-28.pcap quic-29.pcap quic-mvfst-22.pcap quic-mvfst-27.pcapng quic-mvfst-exp.pcap quic_q50.pcap quic_t50.pcap quic_t51.pcap quic_0RTT.pcap quic_interop_V.pcapng quic-33.pcapng doq.pcapng doq_adguard.pcapng dlt_ppp.pcap os_detected.pcapng quic_frags_ch_out_of_order_same_packet_craziness.pcapng quic_frags_ch_in_multiple_packets.pcapng quic-v2-00.pcapng" -READER="$VALGRIND ../example/ndpiReader -p ../example/protos.txt -c ../example/categories.txt -r ../example/risky_domains.txt -j ../example/ja3_fingerprints.csv -S ../example/sha1_fingerprints.csv" +READER="${CMD_PREFIX} ../example/ndpiReader${EXE_SUFFIX} -p ../example/protos.txt -c ../example/categories.txt -r ../example/risky_domains.txt -j ../example/ja3_fingerprints.csv -S ../example/sha1_fingerprints.csv" RC=0 PCAPS=`cd pcap; /bin/ls *.pcap *.pcapng *.cap` -if [ ! -x "../example/ndpiReader" ]; then - echo "$0: Missing $(realpath ../example/ndpiReader)" +if [ ! -x "../example/ndpiReader${EXE_SUFFIX}" ]; then + echo "$0: Missing $(realpath ../example/ndpiReader${EXE_SUFFIX})" echo "$0: Run ./configure and make first" exit 1 fi @@ -68,18 +71,25 @@ check_results() { if [ -f result/$f.out ]; then CMD="$READER -q -t -i pcap/$f -w /tmp/reader.out -v 2" $CMD - NUM_DIFF=`diff result/$f.out /tmp/reader.out | wc -l` - - if [ $NUM_DIFF -eq 0 ]; then - printf "%-48s\tOK\n" "$f" + CMD_RET=$? + if [ $CMD_RET -eq 0 ]; then + NUM_DIFF=`diff result/$f.out /tmp/reader.out | wc -l` else - printf "%-48s\tERROR\n" "$f" - echo "$CMD [old vs new]" - diff result/$f.out /tmp/reader.out - RC=1 + printf "%-48s\tERROR (ndpiReader${EXE_SUFFIX} exit code: ${CMD_RET})\n" "$f" + RC=1 + continue + fi + + if [ $NUM_DIFF -eq 0 ]; then + printf "%-48s\tOK\n" "$f" + else + printf "%-48s\tERROR\n" "$f" + echo "$CMD [old vs new]" + diff result/$f.out /tmp/reader.out + RC=1 fi - /bin/rm /tmp/reader.out + /bin/rm -f /tmp/reader.out fi done } @@ -90,4 +100,4 @@ fi build_results check_results $* -exit $RC
\ No newline at end of file +exit $RC diff --git a/tests/result/kerberos_fuzz.pcapng.out b/tests/result/kerberos_fuzz.pcapng.out index 3602d654e..5b20c3456 100644 --- a/tests/result/kerberos_fuzz.pcapng.out +++ b/tests/result/kerberos_fuzz.pcapng.out @@ -5,4 +5,4 @@ Confidence DPI : 1 (flows) Kerberos 1 288 1 - 1 TCP 126.4.1.0:88 -> 19.0.0.0:53646 [proto: 111/Kerberos][ClearText][Confidence: DPI][cat: Network/14][1 pkts/288 bytes -> 0 pkts/0 bytes][Goodput ratio: 90/0][< 1 sec][r1ióóóca\][PLAIN TEXT (/S.2T )][Plen Bins: 0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + 1 TCP 126.4.1.0:88 -> 19.0.0.0:53646 [proto: 111/Kerberos][ClearText][Confidence: DPI][cat: Network/14][1 pkts/288 bytes -> 0 pkts/0 bytes][Goodput ratio: 90/0][< 1 sec][r1i???ca???????]*??0p??????_???????ea?id;?????o\??????][PLAIN TEXT (/S.2T )][Plen Bins: 0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] diff --git a/tests/result/telnet.pcap.out b/tests/result/telnet.pcap.out index 4159118ec..a091b3500 100644 --- a/tests/result/telnet.pcap.out +++ b/tests/result/telnet.pcap.out @@ -5,5 +5,4 @@ Confidence DPI : 1 (flows) Telnet 87 7418 1 - 1 TCP 192.168.0.2:1550 <-> 192.168.0.1:23 [proto: 77/Telnet][ClearText][Confidence: DPI][cat: RemoteAccess/12][43 pkts/3135 bytes <-> 44 pkts/4283 bytes][Goodput ratio: 9/32][39.57 sec][Username: fake
-][bytes ratio: -0.155 (Mixed)][IAT c2s/s2c min/avg/max/stddev: 0/0 1130/544 14699/8799 2838/1502][Pkt Len c2s/s2c min/avg/max/stddev: 66/66 73/97 151/554 17/76][Risk: ** Unsafe Protocol **][Risk Score: 10][PLAIN TEXT (bam.zing.org)][Plen Bins: 70,6,19,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + 1 TCP 192.168.0.2:1550 <-> 192.168.0.1:23 [proto: 77/Telnet][ClearText][Confidence: DPI][cat: RemoteAccess/12][43 pkts/3135 bytes <-> 44 pkts/4283 bytes][Goodput ratio: 9/32][39.57 sec][Username: fake][bytes ratio: -0.155 (Mixed)][IAT c2s/s2c min/avg/max/stddev: 0/0 1130/544 14699/8799 2838/1502][Pkt Len c2s/s2c min/avg/max/stddev: 66/66 73/97 151/554 17/76][Risk: ** Unsafe Protocol **][Risk Score: 10][PLAIN TEXT (bam.zing.org)][Plen Bins: 70,6,19,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] diff --git a/tests/unit/Makefile.in b/tests/unit/Makefile.in index b2f779fd3..e1d13328e 100644 --- a/tests/unit/Makefile.in +++ b/tests/unit/Makefile.in @@ -1,10 +1,14 @@ CC=@CC@ CXX=@CXX@ BUILD_MINGW=@BUILD_MINGW@ +EXE_SUFFIX=@EXE_SUFFIX@ SRCHOME=../../src -CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @JSONC_CFLAGS@ @PCAP_INC@ @CFLAGS@ +ifneq ($(OS),Windows_NT) +CFLAGS+=-fPIC -DPIC +endif +CFLAGS+=-g -I$(SRCHOME)/include @JSONC_CFLAGS@ @PCAP_INC@ @CFLAGS@ LIBNDPI=$(SRCHOME)/lib/libndpi.a LIBS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ @ADDITIONAL_LIBS@ @JSONC_LIBS@ -lpthread LDFLAGS=@LDFLAGS@ @@ -13,24 +17,41 @@ OBJS=unit PREFIX?=@prefix@ ifneq ($(BUILD_MINGW),) -all: - @echo 'Unit tests disabled due to mingw build.' +ifeq ($(DISABLE_NPCAP),0) +CFLAGS+=-I@srcdir@/../windows/WpdPack/Include -I@srcdir@/../windows/WpdPack/Include/pcap else +CFLAGS+=-DDISABLE_NPCAP +endif -all: unit +ifeq ($(DISABLE_NPCAP),0) + +ifneq ($(BUILD_MINGW_X64),) +LIBS+=@srcdir@/../windows/WpdPack/Lib/x64/wpcap.lib +else +LIBS+=@srcdir@/../windows/WpdPack/Lib/wpcap.lib +endif + +endif + +LIBS+=-Wl,-Bstatic -lpthread -Wl,-Bdynamic +else +LIBS+=-pthread +endif + +all: unit$(EXE_SUFFIX) EXECUTABLE_SOURCES := unit.c COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c )) -unit: $(LIBNDPI) unit.o +unit$(EXE_SUFFIX): $(LIBNDPI) unit.o $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) unit.o $(LIBS) -o $@ %.o: %.c $(HEADERS) Makefile $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ clean: - /bin/rm -f *.o unit + /bin/rm -f *.o unit$(EXE_SUFFIX) /bin/rm -f .*.o.cmd .*.o.d /bin/rm -rf build @@ -42,5 +63,3 @@ distdir: distclean: clean /bin/rm -f Makefile - -endif diff --git a/tests/unit/unit.c b/tests/unit/unit.c index 69d44f3c2..bf08d7ed0 100644 --- a/tests/unit/unit.c +++ b/tests/unit/unit.c @@ -29,8 +29,8 @@ #include <winsock2.h> #include <process.h> #include <io.h> -#define getopt getopt____ #else +#include <getopt.h> #include <unistd.h> #include <netinet/in.h> #include <sys/socket.h> @@ -39,7 +39,6 @@ #include <stdio.h> #include <stdlib.h> -#include <getopt.h> #include <string.h> #include <stdarg.h> #include <search.h> @@ -96,8 +95,8 @@ int serializerUnitTest() { for(i=0; i<16; i++) { char kbuf[32], vbuf[32]; - snprintf(kbuf, sizeof(kbuf), "Key %d", i); - snprintf(vbuf, sizeof(vbuf), "Value %d", i); + ndpi_snprintf(kbuf, sizeof(kbuf), "Key %d", i); + ndpi_snprintf(vbuf, sizeof(vbuf), "Value %d", i); assert(ndpi_serialize_uint32_uint32(&serializer, i, i*i) != -1); assert(ndpi_serialize_uint32_string(&serializer, i, "Data") != -1); assert(ndpi_serialize_string_string(&serializer, kbuf, vbuf) != -1); @@ -112,8 +111,8 @@ int serializerUnitTest() { for(i=0; i<4; i++) { char kbuf[32], vbuf[32]; - snprintf(kbuf, sizeof(kbuf), "Ignored"); - snprintf(vbuf, sizeof(vbuf), "Item %d", i); + ndpi_snprintf(kbuf, sizeof(kbuf), "Ignored"); + ndpi_snprintf(vbuf, sizeof(vbuf), "Item %d", i); assert(ndpi_serialize_uint32_uint32(&serializer, i, i*i) != -1); assert(ndpi_serialize_string_string(&serializer, kbuf, vbuf) != -1); assert(ndpi_serialize_string_float(&serializer, kbuf, (float)(i*i), "%f") != -1); @@ -325,7 +324,9 @@ int serializeProtoUnitTest(void) /* *********************************************** */ int main(int argc, char **argv) { +#ifndef WIN32 int c; +#endif if (ndpi_get_api_version() != NDPI_API_VERSION) { printf("nDPI Library version mismatch: please make sure this code and the nDPI library are in sync\n"); @@ -337,6 +338,11 @@ int main(int argc, char **argv) { if (ndpi_info_mod == NULL) return -1; +/* + * If we want argument parsing on Windows, + * we need to re-implement it as Windows has no such function. + */ +#ifndef WIN32 while((c = getopt(argc, argv, "vh")) != -1) { switch(c) { case 'v': @@ -348,6 +354,9 @@ int main(int argc, char **argv) { return(0); } } +#else + verbose = 0; +#endif /* Tests */ if (serializerUnitTest() != 0) return -1; |