Skip to content

Commit 9efd947

Browse files
authored
ndpi: add run_tests.sh (#13597)
`infra/experimental/chronos/check_tests.sh ndpi c` ``` sha256:a72333481d219c8d9a6a507ff125e4c2216e3dbb3c578a5832da586e3354df59 /src/ndpi/tests/unit /src serializerUnitTest OK serializeProtoUnitTest OK /src ``` Signed-off-by: Adam Korczynski <adam@adalogics.com>
1 parent 9d60f54 commit 9efd947

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

projects/ndpi/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
################################################################################
1616

1717
FROM gcr.io/oss-fuzz-base/base-builder
18-
RUN apt-get update && apt-get install -y make autoconf automake autogen pkg-config libtool flex bison cmake libnuma-dev libpcre2-dev
18+
RUN apt-get update && apt-get install -y make autoconf automake autogen pkg-config libtool flex bison cmake libnuma-dev libpcre2-dev libjson-c-dev
1919
RUN git clone --depth 1 https://github.com/ntop/nDPI.git ndpi
2020
ADD https://www.tcpdump.org/release/libpcap-1.9.1.tar.gz libpcap-1.9.1.tar.gz
21-
COPY build.sh $SRC/
21+
ADD https://github.com/json-c/json-c/archive/refs/tags/json-c-0.17-20230812.tar.gz json-c-0.17-20230812.tar.gz
22+
RUN tar -xvzf json-c-0.17-20230812.tar.gz
23+
COPY build.sh run_tests.diff run_tests.sh $SRC/
2224
WORKDIR $SRC

projects/ndpi/build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,19 @@
1515
#
1616
################################################################################
1717

18+
pushd $SRC/ndpi
19+
git apply $SRC/run_tests.diff
20+
popd
21+
22+
pushd $SRC/json-c-json-c-0.17-20230812
23+
mkdir build
24+
cd build
25+
cmake -DBUILD_SHARED_LIBS=OFF ..
26+
make -j$(nproc)
27+
make install
28+
popd
29+
1830
bash -x ./ndpi/tests/ossfuzz.sh
31+
pushd $SRC/ndpi/tests/unit
32+
make unit
33+
popd

projects/ndpi/run_tests.diff

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/tests/ossfuzz.sh b/tests/ossfuzz.sh
2+
index e63a3d2..02fef25 100644
3+
--- a/tests/ossfuzz.sh
4+
+++ b/tests/ossfuzz.sh
5+
@@ -44,7 +44,7 @@ fi
6+
cd ndpi
7+
# Set LDFLAGS variable and `--with-only-libndpi` option as workaround for the
8+
# "missing dependencies errors" in the introspector build. See #8939
9+
-RANLIB=llvm-ranlib LDFLAGS="-L/usr/local/lib -lpcap" ./autogen.sh --enable-fuzztargets --with-only-libndpi --enable-tls-sigs
10+
+RANLIB=llvm-ranlib LDFLAGS="-L/usr/local/lib -lpcap" ./autogen.sh --enable-fuzztargets --enable-tls-sigs
11+
make -j$(nproc)
12+
# Copy fuzzers
13+
ls fuzz/fuzz* | grep -v "\." | while read -r i; do cp "$i" "$OUT"/; done

projects/ndpi/run_tests.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash -eu
2+
# Copyright 2025 Google LLC.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
################################################################################
17+
18+
pushd $SRC/ndpi/tests/unit
19+
./unit
20+
popd

0 commit comments

Comments
 (0)