From 7fe75e0402ae5b26131f38e6a773e3dff54ea8c6 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Tue, 17 Sep 2024 00:39:21 +0200 Subject: [PATCH 1/4] re-introduce reporting --- .github/workflows/clang-linux-nix-check.yml | 15 ++++++++++++++- .github/workflows/gcc-linux-nix-check.yml | 15 ++++++++++++++- crypto3/CMakeLists.txt | 6 ++++++ crypto3/crypto3.nix | 10 ++++++++++ flake.nix | 11 +++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-linux-nix-check.yml b/.github/workflows/clang-linux-nix-check.yml index 43f37fa63f..f323e7fe35 100644 --- a/.github/workflows/clang-linux-nix-check.yml +++ b/.github/workflows/clang-linux-nix-check.yml @@ -18,7 +18,20 @@ jobs: fetch-depth: 0 - name: Run checks - run: nix build -L .?#checks.x86_64-linux.all-clang + run: | + nix build -L .?#checks.x86_64-linux.all-clang + mkdir results + find -name "*_test.xml" -exec mv -t results/ {} + + ls -l -a results/ env: NIX_CONFIG: | cores = 4 + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/linux@v2 + with: + check_name: "Clang Test Results" + files: "results/*.xml" + comment_mode: ${{ github.event.pull_request.head.repo.fork && 'off' || 'always' }} # Don't create PR comment from fork runs + action_fail_on_inconclusive: true # fail, if no reports + diff --git a/.github/workflows/gcc-linux-nix-check.yml b/.github/workflows/gcc-linux-nix-check.yml index 43af748ee2..18c9783335 100644 --- a/.github/workflows/gcc-linux-nix-check.yml +++ b/.github/workflows/gcc-linux-nix-check.yml @@ -18,7 +18,20 @@ jobs: fetch-depth: 0 - name: Run checks - run: nix build -L .?#checks.x86_64-linux.all-gcc + run: | + nix build -L .?#checks.x86_64-linux.all-gcc + mkdir results + find -name "*_test.xml" -exec mv -t results/ {} + + ls -l -a results/ env: NIX_CONFIG: | cores = 4 + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/linux@v2 + with: + check_name: "Gcc Test Results" + files: "results/*.xml" + comment_mode: ${{ github.event.pull_request.head.repo.fork && 'off' || 'always' }} # Don't create PR comment from fork runs + action_fail_on_inconclusive: true # fail, if no reports + diff --git a/crypto3/CMakeLists.txt b/crypto3/CMakeLists.txt index 442ea362f0..f2a775346f 100644 --- a/crypto3/CMakeLists.txt +++ b/crypto3/CMakeLists.txt @@ -21,11 +21,17 @@ option(Boost_USE_STATIC_LIBS "Use static libraries for Boost" OFF) option(CMAKE_ENABLE_TESTS "Enable tests" FALSE) # used by CMTest module option(BUILD_BENCH_TESTS "Build performance benchmark tests" FALSE) option(BUILD_DOCS "Build with configuring Doxygen documentation compiler" FALSE) +option(SANITIZE "Build sanitizers" FALSE) if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") set(CMAKE_CXX_FLAGS "-ggdb -O0") endif() +if(${SANITIZE}) + add_compile_options(-fsanitize=undefined,address,leak) + add_link_options(-fsanitize=undefined,address,leak) +endif() + # This is useful due to some build systems (Ninja in particular) are piping # compiler output and compiler switches it's output to plain text option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE) diff --git a/crypto3/crypto3.nix b/crypto3/crypto3.nix index ce093e40d4..7494015b8b 100644 --- a/crypto3/crypto3.nix +++ b/crypto3/crypto3.nix @@ -9,6 +9,7 @@ enableDebugging, enableDebug ? false, runTests ? false, + sanitize ? false, }: let inherit (lib) optional; @@ -28,11 +29,20 @@ in stdenv.mkDerivation { [ (if runTests then "-DBUILD_TESTS=TRUE" else "-DBUILD_TESTS=False") (if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release") + (if sanitize then "-DSANITIZE=ON" else "-DSANITIZE=OFF") "-G Ninja" ]; doCheck = runTests; # tests are inside crypto3-tests derivation + checkPhase = '' + # JUNIT file without explicit file name is generated after the name of the master test suite inside `CMAKE_CURRENT_SOURCE_DIR` + export BOOST_TEST_LOGGER=JUNIT:HRF + ctest --verbose --output-on-failure -R + mkdir -p ${placeholder "out"}/test-logs + find .. -type f -name '*_test.xml' -exec cp {} ${placeholder "out"}/test-logs \; + ''; + shellHook = '' PS1="\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ " echo "Welcome to Crypto3 development environment!" diff --git a/flake.nix b/flake.nix index 6741d0f3d3..6666cead47 100644 --- a/flake.nix +++ b/flake.nix @@ -33,6 +33,7 @@ crypto3-debug-tests = (pkgs.callPackage ./crypto3/crypto3.nix { enableDebug = true; runTests = true; + sanitize = true; }); parallel-crypto3 = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix { @@ -145,6 +146,12 @@ runTests = true; enableDebug = false; }); + crypto3-clang-sanitize = (pkgs.callPackage ./crypto3/crypto3.nix { + stdenv = pkgs.llvmPackages_18.stdenv; + runTests = true; + enableDebug = false; + sanitize = true; + }); parallel-crypto3-gcc = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix { runTests = true; @@ -209,6 +216,10 @@ name = "all"; paths = [ crypto3-clang parallel-crypto3-clang evm-assigner-clang transpiler-clang proof-producer-clang ]; }; + all-sanitizers = pkgs.symlinkJoin { + name = "all"; + paths = [ crypto3-clang-sanitize ]; + }; all-gcc = pkgs.symlinkJoin { name = "all"; paths = [ crypto3-gcc parallel-crypto3-gcc evm-assigner-gcc zkevm-framework-gcc transpiler-gcc proof-producer-gcc ]; From 960cbf8e708043aa0a2fbe70525eafaf8bc9a7cb Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Tue, 17 Sep 2024 23:44:26 +0200 Subject: [PATCH 2/4] add more logs --- .github/workflows/gcc-linux-nix-check.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/gcc-linux-nix-check.yml b/.github/workflows/gcc-linux-nix-check.yml index 18c9783335..b22305a844 100644 --- a/.github/workflows/gcc-linux-nix-check.yml +++ b/.github/workflows/gcc-linux-nix-check.yml @@ -23,6 +23,10 @@ jobs: mkdir results find -name "*_test.xml" -exec mv -t results/ {} + ls -l -a results/ + ls -l -a + ls -l -a result/ + ls -l -a result/test-logs/ + find -name "*_test.xml" env: NIX_CONFIG: | cores = 4 From ef79af6c6266d3ea9ce4070c6fe094e1d6f5d668 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Tue, 17 Sep 2024 23:54:36 +0200 Subject: [PATCH 3/4] correct paths --- .github/workflows/clang-linux-nix-check.yml | 3 +-- .github/workflows/gcc-linux-nix-check.yml | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/clang-linux-nix-check.yml b/.github/workflows/clang-linux-nix-check.yml index f323e7fe35..cf112ad928 100644 --- a/.github/workflows/clang-linux-nix-check.yml +++ b/.github/workflows/clang-linux-nix-check.yml @@ -21,8 +21,7 @@ jobs: run: | nix build -L .?#checks.x86_64-linux.all-clang mkdir results - find -name "*_test.xml" -exec mv -t results/ {} + - ls -l -a results/ + cp result/test-logs/*_test.xml results/ env: NIX_CONFIG: | cores = 4 diff --git a/.github/workflows/gcc-linux-nix-check.yml b/.github/workflows/gcc-linux-nix-check.yml index b22305a844..e6394c0c05 100644 --- a/.github/workflows/gcc-linux-nix-check.yml +++ b/.github/workflows/gcc-linux-nix-check.yml @@ -21,12 +21,7 @@ jobs: run: | nix build -L .?#checks.x86_64-linux.all-gcc mkdir results - find -name "*_test.xml" -exec mv -t results/ {} + - ls -l -a results/ - ls -l -a - ls -l -a result/ - ls -l -a result/test-logs/ - find -name "*_test.xml" + cp result/test-logs/*_test.xml results/ env: NIX_CONFIG: | cores = 4 From e898cb51425a9146031176d17f9c5428fc8c3435 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Wed, 18 Sep 2024 09:41:59 +0200 Subject: [PATCH 4/4] add crypto-3 sanitzie package --- flake.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flake.nix b/flake.nix index 6666cead47..18d12df041 100644 --- a/flake.nix +++ b/flake.nix @@ -33,6 +33,10 @@ crypto3-debug-tests = (pkgs.callPackage ./crypto3/crypto3.nix { enableDebug = true; runTests = true; + }); + crypto3-sanitize = (pkgs.callPackage ./crypto3/crypto3.nix { + enableDebug = true; + runTests = true; sanitize = true; });