-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add convenience scripts for running tests and fuzzing using Docker co…
…ntainers
- Loading branch information
1 parent
75f29f0
commit 17a10d9
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
DOCKER="docker" | ||
|
||
${DOCKER} build -t pdu-fuzz - <<'EOF' | ||
FROM ubuntu:bionic | ||
ENV LANG=C.UTF-8 \ | ||
LC_ALL=C.UTF-8 | ||
VOLUME /usr/local/src/pdu | ||
WORKDIR /usr/local/src/pdu | ||
SHELL ["/bin/bash", "-eu", "-o", "pipefail", "-c"] | ||
RUN \ | ||
export DEBIAN_FRONTEND=noninteractive; \ | ||
apt-get -q update; \ | ||
apt-get -q install -y curl build-essential linux-headers-generic pkg-config binutils-dev libunwind-dev libpcap-dev tshark; \ | ||
apt-get -q clean autoclean; | ||
RUN \ | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable; \ | ||
source $HOME/.cargo/env; \ | ||
cargo install honggfuzz; | ||
ENTRYPOINT \ | ||
source $HOME/.cargo/env; \ | ||
cd ./fuzz; \ | ||
RUSTFLAGS="-C link-dead-code" cargo hfuzz run $FUZZ_TARGET | ||
EOF | ||
|
||
if [ -z "$1" ]; then | ||
echo "Usage: fuzz.sh [ ethernet | arp | ipv4 | ipv6 | tcp | udp | icmp | gre ]" | ||
fi | ||
|
||
${DOCKER} run --init --rm -v "$(pwd):/usr/local/src/pdu" -e FUZZ_TARGET=$1 pdu-fuzz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
hfuzz_target/ | ||
hfuzz_workspace/**/*.cov | ||
!hfuzz_workspace/**/ | ||
!.gitignore | ||
.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
DOCKER="docker" | ||
|
||
${DOCKER} build -t pdu-test - <<'EOF' | ||
FROM ubuntu:bionic | ||
ENV LANG=C.UTF-8 \ | ||
LC_ALL=C.UTF-8 | ||
VOLUME /usr/local/src/pdu | ||
WORKDIR /usr/local/src/pdu | ||
SHELL ["/bin/bash", "-eu", "-o", "pipefail", "-c"] | ||
RUN \ | ||
export DEBIAN_FRONTEND=noninteractive; \ | ||
apt-get -q update; \ | ||
apt-get -q install -y curl build-essential linux-headers-generic pkg-config binutils-dev libunwind-dev libpcap-dev tshark; \ | ||
apt-get -q clean autoclean; | ||
RUN \ | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable; \ | ||
source $HOME/.cargo/env; \ | ||
cargo install honggfuzz; | ||
ENTRYPOINT \ | ||
source $HOME/.cargo/env; \ | ||
cargo test --verbose | ||
EOF | ||
|
||
${DOCKER} run --init --rm -v "$(pwd):/usr/local/src/pdu" pdu-test |