Skip test setup if device does not support bpf
For older devices that doesn't have bpf support, skip the whole test so
we don't get false alarms. Fixed some compiler warning as well.
Test: ./libnetdbpf_test/libnetdbpf_test
Bug: 119526856
Change-Id: I5a520c3157510372c016c8dee65785eddd8ae431
diff --git a/libnetdbpf/BpfNetworkStatsTest.cpp b/libnetdbpf/BpfNetworkStatsTest.cpp
index 061636f..a64fca9 100644
--- a/libnetdbpf/BpfNetworkStatsTest.cpp
+++ b/libnetdbpf/BpfNetworkStatsTest.cpp
@@ -38,8 +38,6 @@
#include "bpf/BpfUtils.h"
#include "netdbpf/BpfNetworkStats.h"
-using namespace android::bpf;
-
using ::testing::_;
using ::testing::ByMove;
using ::testing::Invoke;
@@ -85,6 +83,8 @@
BpfMap<uint32_t, StatsValue> mFakeIfaceStatsMap;
void SetUp() {
+ SKIP_IF_BPF_NOT_SUPPORTED;
+
mFakeCookieTagMap = BpfMap<uint64_t, UidTag>(createMap(
BPF_MAP_TYPE_HASH, sizeof(uint64_t), sizeof(struct UidTag), TEST_MAP_SIZE, 0));
ASSERT_LE(0, mFakeCookieTagMap.getMap());