Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/pcapplusplus/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ RUN git clone --depth=1 https://github.com/the-tcpdump-group/libpcap.git libpcap

WORKDIR PcapPlusPlus

COPY build.sh $SRC
COPY *.sh pcapplusplus_enable_tests.diff $SRC
3 changes: 3 additions & 0 deletions projects/pcapplusplus/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
#
################################################################################

# TODO: Right now, we apply patch only if sanitizer is not 'memory'.
# TODO: Upstream the patch to PcapPlusPlus repo.
git -C "$SRC/PcapPlusPlus" apply "$SRC/pcapplusplus_enable_tests.diff"
$SRC/PcapPlusPlus/Tests/Fuzzers/ossfuzz.sh
18 changes: 18 additions & 0 deletions projects/pcapplusplus/pcapplusplus_enable_tests.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
index 6d461ff6..c984c978 100755
--- a/Tests/Fuzzers/ossfuzz.sh
+++ b/Tests/Fuzzers/ossfuzz.sh
@@ -12,7 +12,13 @@ make -j$(nproc)
# Build PcapPlusPlus linking statically against the built libpcap
cd $SRC/PcapPlusPlus
LIBPCAP_PATH=$SRC/libpcap/
-cmake -DPCAPPP_BUILD_FUZZERS=ON -DPCAPPP_BUILD_TESTS=OFF -DPCAPPP_BUILD_EXAMPLES=OFF -DPCAP_INCLUDE_DIR="${LIBPCAP_PATH}/" -DPCAP_LIBRARY="${LIBPCAP_PATH}/libpcap.a" -S . -B $TARGETS_DIR
+
+PCAPPP_BUILD_TESTS_VALUE="ON"
+if [ "${SANITIZER:-}" = "memory" ]; then
+ PCAPPP_BUILD_TESTS_VALUE="OFF"
+fi
+
+cmake -DPCAPPP_BUILD_FUZZERS=ON -DPCAPPP_BUILD_TESTS=$PCAPPP_BUILD_TESTS_VALUE -DPCAPPP_BUILD_EXAMPLES=OFF -DPCAP_INCLUDE_DIR="${LIBPCAP_PATH}/" -DPCAP_LIBRARY="${LIBPCAP_PATH}/libpcap.a" -S . -B $TARGETS_DIR
cmake --build $TARGETS_DIR -j

# Copy target and options
33 changes: 33 additions & 0 deletions projects/pcapplusplus/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash -eu
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################

export ASAN_OPTIONS=detect_stack_use_after_return=0:detect_leaks=0:abort_on_error=0:halt_on_error=0:exitcode=0
ROOT="$SRC/PcapPlusPlus"

echo "=== Packet++Test ==="
cd "$ROOT/Tests/Packet++Test"
# TODO: Skipping failing tests.
./Bin/Packet++Test -x "VrrpCreateAndEditTest;TestMacAddress;TestTcpReassemblyRetran"

echo "=== Pcap++Test (no networking) ==="
cd "$ROOT/Tests/Pcap++Test"
# TODO: Skipping failing tests. TestPcapLiveDeviceList and
# TestPcapLiveDeviceNoNetworking fail because of network so we should keep
# them disabled.
./Bin/Pcap++Test \
-n -x \
"TestMacAddress;TestTcpReassemblyRetran;TestTcpReassemblyMissingData;TestPcapLiveDeviceList;TestPcapLiveDeviceNoNetworking"