Merge ubuntu and macos fuzzer && Record time for ./test_all_fuzzers.sh (#629)

* Add ccache

* Update codecov.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update test_all_fuzzers.sh

Add fuzzer timer

* Fix `./test_all_fuzzers.sh` on macos

* Fix CI

* Fix CI

* Update build_and_test.yml

* Fix typo
This commit is contained in:
syheliel 2022-05-14 06:57:26 +08:00 committed by GitHub
parent d61612c94c
commit aa101c396a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 27 deletions

View File

@ -1,4 +1,4 @@
name: Build and Test name: build and test
on: on:
push: push:
@ -94,23 +94,44 @@ jobs:
run: sudo ./libafl_concolic/test/smoke_test_ubuntu_deps.sh run: sudo ./libafl_concolic/test/smoke_test_ubuntu_deps.sh
- name: Run smoke test - name: Run smoke test
run: ./libafl_concolic/test/smoke_test.sh run: ./libafl_concolic/test/smoke_test.sh
ubuntu-fuzzers: fuzzers:
runs-on: ubuntu-latest env:
CC: ccache clang # use ccache in default
CXX: ccache clang # use ccache in default
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions-rs/toolchain@v1 - uses: actions-rs/toolchain@v1
with: with:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
- name: add ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.job }}-${{ matrix.os }}
max-size: 2000M
- name: enable mult-thread for `make`
run: export MAKEFLAGS="-j$(expr $(nproc) \+ 1)"
- uses: Swatinem/rust-cache@v1 - uses: Swatinem/rust-cache@v1
- name: Add nightly rustfmt and clippy - name: Add nightly rustfmt and clippy
run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade
- name: Install deps - uses: lyricwulf/abc@v1
run: sudo apt-get install -y llvm llvm-dev clang nasm ninja-build with:
linux: llvm llvm-dev clang nasm ninja-build
# update bash for macos to support `declare -A` command`
macos: llvm libpng nasm coreutils z3 bash
- name: install cargo-make - name: install cargo-make
run: cargo install --force cargo-make run: cargo install --force cargo-make
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Build and run example fuzzers - name: Build and run example fuzzers
if: runner.os == 'Linux'
run: ./scripts/test_all_fuzzers.sh run: ./scripts/test_all_fuzzers.sh
- name: Build and run example fuzzers
if: runner.os == 'macOS' # use bash v4
run: /usr/local/bin/bash ./scripts/test_all_fuzzers.sh
- run: ccache --show-stats
nostd-build: nostd-build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -182,25 +203,7 @@ jobs:
run: ./scripts/shmem_limits_macos.sh run: ./scripts/shmem_limits_macos.sh
- name: Run Tests - name: Run Tests
run: cargo test run: cargo test
macos-fuzzers:
runs-on: macOS-latest
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: Swatinem/rust-cache@v1
- name: Add nightly rustfmt and clippy
run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade
- name: Install deps
run: brew install llvm libpng nasm coreutils z3 && brew link --force llvm
- name: install cargo-make
run: cargo install --force cargo-make
- uses: actions/checkout@v2
- name: Increase map sizes
run: ./scripts/shmem_limits_macos.sh
- name: Build and run example fuzzers
run: ./scripts/test_all_fuzzers.sh
other_targets: other_targets:
runs-on: macOS-latest runs-on: macOS-latest
steps: steps:

View File

@ -1,6 +1,6 @@
on: [push] on: [push]
name: build name: codecov
jobs: jobs:
check: check:
@ -32,4 +32,4 @@ jobs:
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1
with: with:
name: code-coverage-report name: code-coverage-report
path: cobertura.xml path: cobertura.xml

View File

@ -12,9 +12,12 @@ libafl=$(pwd)
git submodule init && git submodule update git submodule init && git submodule update
# record time of each fuzzer
declare -A time_record || (echo "declare -A not avaliable, please update your bash version to 4";exit 1)
for fuzzer in $(echo $fuzzers $backtrace_fuzzers); for fuzzer in $(echo $fuzzers $backtrace_fuzzers);
do do
cd $fuzzer cd $fuzzer
start=`date +%s`
# Clippy checks # Clippy checks
if [ "$1" != "--no-fmt" ]; then if [ "$1" != "--no-fmt" ]; then
@ -35,9 +38,15 @@ do
cargo build || exit 1 cargo build || exit 1
echo "[+] Done building $fuzzer" echo "[+] Done building $fuzzer"
fi fi
end=`date +%s`
time_record[$fuzzer]=$((end-start))
# Save disk space # Save disk space
cargo clean cargo clean
cd $libafl cd $libafl
echo "" echo ""
done done
# print time for each fuzzer
for key in ${!time_record[@]}; do
echo "dir:"$key" time:"${time_record[$key]};
done