diff options
-rw-r--r-- | .travis.yml | 7 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | nDPId-test.c | 27 | ||||
-rw-r--r-- | nDPIsrvd.c | 3 | ||||
-rwxr-xr-x | test/run_tests.sh | 6 |
5 files changed, 31 insertions, 14 deletions
diff --git a/.travis.yml b/.travis.yml index b41e94d0a..16f136450 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,11 @@ script: - env python3 --version - test/run_tests.sh nDPI - make -f Makefile.old clean +# pkg-config build - PKG_CONFIG_PATH="$(realpath ./nDPI/_install/lib/pkgconfig)" make -f Makefile.old PKG_CONFIG_BIN=pkg-config ENABLE_DEBUG=yes ENABLE_SANITIZER=yes all examples +- ./nDPId-test || test $? -eq 1 +- ./nDPId -h || test $? -eq 1 +# cmake/pkg-config build +- mkdir -p build && cd build && PKG_CONFIG_PATH="$(realpath ../nDPI/_install/lib/pkgconfig)" cmake .. -DCMAKE_INSTALL_PREFIX=$(realpath ../_install) -DBUILD_EXAMPLES=ON -DENABLE_MEMORY_PROFILING=ON -DENABLE_SANITIZER=ON && make install +- cd build && ./nDPId-test || test $? -eq 1 +- cd build && ./nDPId -h || test $? -eq 1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 887a5a78f..2b760c132 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.12.4) project(nDPId C) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) find_package(PkgConfig REQUIRED) diff --git a/nDPId-test.c b/nDPId-test.c index a70f9b9dc..42d353905 100644 --- a/nDPId-test.c +++ b/nDPId-test.c @@ -308,26 +308,31 @@ int main(int argc, char ** argv) if (argc != 2) { usage(argv[0]); - return -1; + return 1; } if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { - return -1; + return 1; } nDPId_options.reader_thread_count = 1; /* Please do not change this! Generating meaningful pcap diff's relies on a single reader thread! */ nDPId_options.instance_alias = strdup("nDPId-test"); + if (access(argv[1], R_OK) != 0) + { + fprintf(stderr, "%s: pcap file `%s' does not exist or is not readable\n", argv[0], argv[1]); + return 1; + } nDPId_options.pcap_file_or_interface = strdup(argv[1]); if (validate_options(argv[0]) != 0) { - return -1; + return 1; } if (setup_pipe(mock_pipefds) != 0 || setup_pipe(mock_servfds) != 0) { - return -1; + return 1; } /* We do not have any sockets, any socket operation must fail! */ @@ -336,28 +341,28 @@ int main(int argc, char ** argv) if (setup_remote_descriptors(MAX_REMOTE_DESCRIPTORS) != 0) { - return -1; + return 1; } pthread_t nDPId_thread; struct thread_return_value nDPId_return = {}; if (pthread_create(&nDPId_thread, NULL, nDPId_mainloop_thread, &nDPId_return) != 0) { - return -1; + return 1; } pthread_t nDPIsrvd_thread; struct thread_return_value nDPIsrvd_return = {}; if (pthread_create(&nDPIsrvd_thread, NULL, nDPIsrvd_mainloop_thread, &nDPIsrvd_return) != 0) { - return -1; + return 1; } pthread_t distributor_thread; struct thread_return_value distributor_return = {}; if (pthread_create(&distributor_thread, NULL, distributor_client_mainloop_thread, &distributor_return) != 0) { - return -1; + return 1; } /* Try to gracefully shutdown all threads. */ @@ -366,7 +371,7 @@ int main(int argc, char ** argv) { if (THREADS_RETURNED_ERROR() != 0) { - return -1; + return 1; } } @@ -374,7 +379,7 @@ int main(int argc, char ** argv) { if (THREADS_RETURNED_ERROR() != 0) { - return -1; + return 1; } } @@ -382,7 +387,7 @@ int main(int argc, char ** argv) { if (THREADS_RETURNED_ERROR() != 0) { - return -1; + return 1; } } diff --git a/nDPIsrvd.c b/nDPIsrvd.c index f687a29e6..7e3a62167 100644 --- a/nDPIsrvd.c +++ b/nDPIsrvd.c @@ -879,19 +879,18 @@ int main(int argc, char ** argv) } syslog(LOG_DAEMON, "collector listen on %s", nDPIsrvd_options.json_sockpath); + syslog(LOG_DAEMON, "distributor listen on %s", nDPIsrvd_options.serv_optarg); switch (serv_address.raw.sa_family) { default: goto error; case AF_INET: case AF_INET6: - syslog(LOG_DAEMON, "distributor listen on %s", nDPIsrvd_options.serv_optarg); syslog(LOG_DAEMON | LOG_ERR, "Please keep in mind that using a TCP Socket may leak sensitive information to " "everyone with access to the device/network. You've been warned!"); break; case AF_UNIX: - syslog(LOG_DAEMON, "distributor listen on %s", nDPIsrvd_options.json_sockpath); break; } diff --git a/test/run_tests.sh b/test/run_tests.sh index 5c6e54c19..a19ec0408 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -68,6 +68,12 @@ mkdir -p /tmp/nDPId-test-stderr set +e TESTS_FAILED=0 +${nDPId_test_EXEC} -h 2>/dev/null +if [ $? -ne 1 ]; then + printf '%s\n' "nDPId-test: ${nDPId_test_EXEC} seems to be an invalid executable" + exit 7 +fi + for pcap_file in $(ls *.pcap *.pcapng *.cap); do if file "${pcap_file}" | grep -qoE ':\s(pcap|pcap-ng) capture file'; then true # pass |