Skip to content

Commit

Permalink
Re-enable all the native tests
Browse files Browse the repository at this point in the history
Some were wrongly disabled in 275eefa
  • Loading branch information
emanuele-f committed Aug 17, 2023
1 parent 86b4c50 commit 85c2fda
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
4 changes: 1 addition & 3 deletions app/src/main/jni/core/capture_libpcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,10 @@ static int connectPcapd(pcapdroid_t *pd) {
log_d("BPF filter is in use");
}

#ifdef ANDROID
if(pd->pcap_file_capture) {
// must be a file path
if(access(pd->pcap.capture_interface, F_OK)) {
log_f("The specified PCAP file does not exist");
log_f("The specified PCAP file does not exist: %s", pd->pcap.capture_interface);
goto cleanup;
}
} else {
Expand All @@ -175,7 +174,6 @@ static int connectPcapd(pcapdroid_t *pd) {
goto cleanup;
}
}
#endif

// Start the daemon
char args[256];
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/jni/pcapd/pcapd_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <stdint.h>
#include <net/if.h>
#include <pcap.h>
#include <linux/limits.h>

#include "nl_utils.h"
#include "common/uid_lru.h"
#include "common/uid_resolver.h"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/jni/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project(tests)
cmake_minimum_required(VERSION 3.18.1)
project(tests)

option(FUZZING "Build for Fuzz Testing" OFF)

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/jni/tests/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ add_test(NAME blacklist_match COMMAND ./blacklist match)
add_test(NAME blacklist_detection COMMAND ./blacklist detection)

test_source(dump_api)
#~ add_test(NAME dump_api_snaplen COMMAND ./dump_api snaplen)
add_test(NAME dump_api_snaplen COMMAND ./dump_api snaplen)
add_test(NAME dump_api_max_pkts_flow COMMAND ./dump_api max_pkts_per_flow)
#~ add_test(NAME dump_api_max_size COMMAND ./dump_api max_dump_size)
add_test(NAME dump_api_max_size COMMAND ./dump_api max_dump_size)

#~ test_source(root_capture)
#~ add_test(NAME root_capture COMMAND ./root_capture invalid_pkts)
test_source(root_capture)
add_test(NAME root_capture COMMAND ./root_capture invalid_pkts)
2 changes: 1 addition & 1 deletion app/src/main/jni/tests/test/dump_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static void max_pkts_per_flow() {
src_ip = pkt.tuple.src_ip;
dst_ip = pkt.tuple.dst_ip;

remote_ip = (zdtun_cmp_ip(4, &pkt.tuple.src_ip, &local_ip) == 0) ?
remote_ip = (zdtun_cmp_ip(4, &src_ip, &local_ip) == 0) ?
&dst_ip : &src_ip;

#if 0
Expand Down
1 change: 1 addition & 0 deletions app/src/main/jni/tests/test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pcapdroid_t* pd_init_test(const char *ifname) {
assert(pd != NULL);

pd->vpn_capture = false;
pd->pcap_file_capture = true;
pd->pcap.capture_interface = (char*) ifname;
pd->pcap.as_root = false; // don't run as root
pd->app_filter = -1; // don't filter
Expand Down

0 comments on commit 85c2fda

Please sign in to comment.