Skip to content

Commit

Permalink
flamenco, fuzz: add stubbed binaries to CI for CPI test vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
ravyu-jump committed Dec 4, 2024
1 parent 5f74462 commit 73731e7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- test-case: linux_gcc_x86_64
machine: linux_gcc_x86_64
label: X64
extras: rpath
extras: "rpath fuzz-stubs"
targets: "all integration-test fdctl"
compiler: gcc
compiler-version: 12.4.0
Expand All @@ -48,7 +48,7 @@ jobs:
- test-case: linux_gcc_icelake
machine: linux_gcc_icelake
label: icelake
extras: rpath
extras: "rpath fuzz-stubs"
targets: "all integration-test fdctl"
compiler: gcc
compiler-version: 12.4.0
Expand All @@ -57,7 +57,7 @@ jobs:
- test-case: linux_clang_x86_64
machine: linux_clang_x86_64
label: X64
extras: rpath
extras: "rpath fuzz-stubs"
targets: "all integration-test fdctl"
compiler: clang
compiler-version: 15.0.6
Expand All @@ -66,7 +66,7 @@ jobs:
- test-case: linux_clang_icelake
machine: linux_clang_icelake
label: icelake
extras: "asan ubsan rpath"
extras: "asan ubsan rpath fuzz-stubs"
targets: "all integration-test fdctl"
compiler: clang
compiler-version: 15.0.6
Expand All @@ -75,7 +75,7 @@ jobs:
- test-case: native
machine: native
label: 512G
extras: rpath
extras: "rpath fuzz-stubs"
targets: "all integration-test fdctl"
compiler: clang
compiler-version: 15.0.6
Expand Down
1 change: 1 addition & 0 deletions config/extra/with-fuzz-stubs.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FD_HAS_FUZZ_STUBS:=1
1 change: 1 addition & 0 deletions config/extra/with-fuzz.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include config/extra/with-fuzz-stubs.mk
FD_HAS_FUZZ:=1

CPPFLAGS+=-fno-omit-frame-pointer
Expand Down
1 change: 1 addition & 0 deletions contrib/test/ci_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# ci_tests.sh builds and runs the tests that are required on every CI
# commit. May optionally export coverage data.
# NOTE: Use EXTRAS=fuzz-stubs to build stubbed binaries for fuzz tests.
#
# WARNING: Running this script will destroy your build directory.

Expand Down
13 changes: 10 additions & 3 deletions contrib/test/run_test_vectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ cd ../..
LOG=$LOG_PATH/test_exec_syscall
cat contrib/test/test-vectors-fixtures/syscall-fixtures/*.list | xargs -P 4 -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG

LOG=$LOG_PATH/test_exec_cpi
cat contrib/test/test-vectors-fixtures/cpi-fixtures/*.list | xargs -P 4 -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG

# LOG=$LOG_PATH/test_exec_interp
# cat contrib/test/test-vectors-fixtures/vm-interp-fixtures/*.list | xargs -P 4 -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG

Expand All @@ -58,4 +55,14 @@ cat contrib/test/test-vectors-fixtures/instr-fixtures/*.list | xargs -P 4 -n 100
LOG=$LOG_PATH/test_vm_validate
cat contrib/test/test-vectors-fixtures/vm-validate-fixtures/*.list | xargs -P 4 -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG

# check if ./$OBJDIR/unit-test/test_exec_sol_compat_stubbed exists
if [ -f ./$OBJDIR/unit-test/test_exec_sol_compat_stubbed ]; then
LOG=$LOG_PATH/test_exec_cpi
cat contrib/test/test-vectors-fixtures/cpi-fixtures/*.list | xargs -P 4 -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat_stubbed --log-path $LOG
else
# skip stubbed tests if the binary does not exist
echo -e "\e[38;5;214mNOTICE:\e[0m Skipping stubbed tests due to missing stub binary"
echo "Build with EXTRAS=fuzz-stubs to build the stub binary"
fi

echo Test vectors success
5 changes: 3 additions & 2 deletions src/flamenco/runtime/tests/Local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ $(call make-unit-test,test_exec_instr,test_exec_instr,fd_flamenco fd_funk fd_bal
$(call make-unit-test,test_exec_sol_compat,test_exec_sol_compat,fd_flamenco fd_funk fd_ballet fd_util fd_disco,$(SECP256K1_LIBS))
$(call make-shared,libfd_exec_sol_compat.so,fd_exec_sol_compat,fd_flamenco fd_funk fd_ballet fd_util fd_disco,$(SECP256K1_LIBS))

ifdef FD_HAS_FUZZ
ifdef FD_HAS_FUZZ_STUBS
# The --wrap flag stubs out a function so that we can replace it with our own implementation in the fuzz harness(es)
# See __wrap_fd_execute_instr in fd_exec_instr_test.c for example
# We guard this with FD_HAS_FUZZ because the --wrap flag may not be portable across linkers
# We guard this with FD_HAS_FUZZ_STUBS because the --wrap flag may not be portable across linkers
WRAP_FLAGS += -Xlinker --wrap=fd_execute_instr
$(call make-shared,libfd_exec_sol_compat_stubbed.so,fd_exec_sol_compat,fd_flamenco fd_funk fd_ballet fd_util fd_disco,$(SECP256K1_LIBS) $(WRAP_FLAGS))
$(call make-unit-test,test_exec_sol_compat_stubbed,test_exec_sol_compat,fd_flamenco fd_funk fd_ballet fd_util fd_disco,$(SECP256K1_LIBS) $(WRAP_FLAGS))
endif

endif
Expand Down

0 comments on commit 73731e7

Please sign in to comment.