From 82f73efb7f2eb9cd9040a9cd7b10a0615671c8c7 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 6 May 2025 13:49:20 -0400 Subject: [PATCH 1/5] Override the Rust version to use the same as the one from the repo of rustc_codegen_gcc --- .github/workflows/ci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3c9f343..4e757cd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -114,6 +114,11 @@ jobs: git clone --depth 1 https://github.com/rust-lang/rustc_codegen_gcc + # Since we use rustc_codegen_gcc from the master branch of the repo, but don't use y.sh in make to build using rustc_codegen_gcc, + # we need to override the rust version. + rust_version=$(grep channel rustc_codegen_gcc/rust-toolchain | cut -f3 -d' ' | sed 's/"//g') + rustup override set $rust_version + echo "MAKE_KRUSTFLAGS=KRUSTFLAGS=-Zcodegen-backend=$(pwd)/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so" >> $GITHUB_ENV From 7d2b72b9a7465c2044519d3cef54e8739a04ead5 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 6 May 2025 19:24:13 -0400 Subject: [PATCH 2/5] Fix tests --- .github/workflows/ci.yaml | 2 +- rfl-debug.config | 3 --- rfl-rust.config | 3 +++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4e757cd..9bf1fc6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -230,7 +230,7 @@ jobs: grep '] rust_print: Info message (level 6) with args$' qemu-stdout grep '] rust_print: A line that is continued with args$' qemu-stdout - - run: grep '] ok 1 rust_doctests_kernel$' qemu-stdout + - run: grep '] ok 2 rust_doctests_kernel$' qemu-stdout - run: | grep -i '\bpanic\b' qemu-stdout && exit 1 diff --git a/rfl-debug.config b/rfl-debug.config index 573628d..d9aeeb4 100644 --- a/rfl-debug.config +++ b/rfl-debug.config @@ -1,4 +1 @@ CONFIG_RUST_DEBUG_ASSERTIONS=y - -CONFIG_KUNIT=y -CONFIG_RUST_KERNEL_DOCTESTS=y diff --git a/rfl-rust.config b/rfl-rust.config index 30a6cff..61d4d34 100644 --- a/rfl-rust.config +++ b/rfl-rust.config @@ -14,3 +14,6 @@ CONFIG_SAMPLE_RUST_HOSTPROGS=y RUST_PHYLIB_ABSTRACTIONS=y AX88796B_PHY=y AX88796B_RUST_PHY=y + +CONFIG_KUNIT=y +CONFIG_RUST_KERNEL_DOCTESTS=y From edf42d17c5ebe47421e2e3253be47744182e5320 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 6 May 2025 20:19:25 -0400 Subject: [PATCH 3/5] Comment test that fails --- .github/workflows/ci.yaml | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9bf1fc6..d113ff8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -232,28 +232,28 @@ jobs: - run: grep '] ok 2 rust_doctests_kernel$' qemu-stdout - - run: | - grep -i '\bpanic\b' qemu-stdout && exit 1 - grep -i '\boops\b' qemu-stdout && exit 1 - grep -i '\btaint\b' qemu-stdout && exit 1 - grep -i '\bfault\b' qemu-stdout && exit 1 - grep -i '\btrace\b' qemu-stdout && exit 1 - grep -i '\bcorrupted\b' qemu-stdout && exit 1 - - grep -i '\bbug\b' qemu-stdout | - grep -Fv '" and report a bug' && - exit 1 - - grep -i '\berror\b' qemu-stdout | - grep -Fv 'message (level 3)' | - grep -Fv 'regulatory.db' && - exit 1 - - grep -i '\bwarning\b' qemu-stdout | - grep -Fv 'message (level 4)' && - exit 1 - - exit 0 + # - run: | + # grep -i '\bpanic\b' qemu-stdout && exit 1 + # grep -i '\boops\b' qemu-stdout && exit 1 + # grep -i '\btaint\b' qemu-stdout && exit 1 + # grep -i '\bfault\b' qemu-stdout && exit 1 + # grep -i '\btrace\b' qemu-stdout && exit 1 + # grep -i '\bcorrupted\b' qemu-stdout && exit 1 + + # grep -i '\bbug\b' qemu-stdout | + # grep -Fv '" and report a bug' && + # exit 1 + + # grep -i '\berror\b' qemu-stdout | + # grep -Fv 'message (level 3)' | + # grep -Fv 'regulatory.db' && + # exit 1 + + # grep -i '\bwarning\b' qemu-stdout | + # grep -Fv 'message (level 4)' && + # exit 1 + + # exit 0 # Re-build with Clippy. - run: make -C linux ${{ env.MAKE_ARCH }} ${{ env.MAKE_CROSS_COMPILE }} ${{ env.MAKE_TOOLCHAIN }} ${{ env.MAKE_OUTPUT }} ${{ env.MAKE_KRUSTFLAGS }} ${{ env.JOBS }} CLIPPY=1 From 157405b0a82547975ac45e3273ac3b16eeff10bd Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 6 May 2025 21:15:54 -0400 Subject: [PATCH 4/5] Add components clippy and rustfmt --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d113ff8..222bea1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -118,6 +118,7 @@ jobs: # we need to override the rust version. rust_version=$(grep channel rustc_codegen_gcc/rust-toolchain | cut -f3 -d' ' | sed 's/"//g') rustup override set $rust_version + rustup component add clippy rustfmt echo "MAKE_KRUSTFLAGS=KRUSTFLAGS=-Zcodegen-backend=$(pwd)/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so" >> $GITHUB_ENV From d13c1bd98e6316108358d195eadf847042263ae4 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 8 May 2025 09:40:44 -0400 Subject: [PATCH 5/5] Re-add the test that check panics --- .github/workflows/ci.yaml | 23 +------------- check_panics.py | 63 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 check_panics.py diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 222bea1..4abc67e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -233,28 +233,7 @@ jobs: - run: grep '] ok 2 rust_doctests_kernel$' qemu-stdout - # - run: | - # grep -i '\bpanic\b' qemu-stdout && exit 1 - # grep -i '\boops\b' qemu-stdout && exit 1 - # grep -i '\btaint\b' qemu-stdout && exit 1 - # grep -i '\bfault\b' qemu-stdout && exit 1 - # grep -i '\btrace\b' qemu-stdout && exit 1 - # grep -i '\bcorrupted\b' qemu-stdout && exit 1 - - # grep -i '\bbug\b' qemu-stdout | - # grep -Fv '" and report a bug' && - # exit 1 - - # grep -i '\berror\b' qemu-stdout | - # grep -Fv 'message (level 3)' | - # grep -Fv 'regulatory.db' && - # exit 1 - - # grep -i '\bwarning\b' qemu-stdout | - # grep -Fv 'message (level 4)' && - # exit 1 - - # exit 0 + - run: python ci/check_panics.py qemu-stdout # Re-build with Clippy. - run: make -C linux ${{ env.MAKE_ARCH }} ${{ env.MAKE_CROSS_COMPILE }} ${{ env.MAKE_TOOLCHAIN }} ${{ env.MAKE_OUTPUT }} ${{ env.MAKE_KRUSTFLAGS }} ${{ env.JOBS }} CLIPPY=1 diff --git a/check_panics.py b/check_panics.py new file mode 100644 index 0000000..b443cfd --- /dev/null +++ b/check_panics.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 + +import re +import sys + +PATTERNS = { + b"No such file or directory": [], + rb"\bpanic\b": [], + rb"\bpanics\b": [], + rb"\boops\b": [], + rb"\boopses\b": [], + rb"\btaint\b": [], + rb"\btaints\b": [ + b"rust_out_of_tree: loading out-of-tree module taints kernel." + ], + rb"\bfault\b": [], + rb"\bfaults\b": [], + rb"\bcorrupted\b": [], + rb"\btrace\b": [ + b"] RCU Tasks Trace:", + b"] trace event string verifier disabled", + b".pcie: probe with driver pci-host-generic failed with error -16" + ], + rb"\btraces\b": [], + rb"\bbug\b": [ + b" and report a bug" + ], + rb"\bbugs\b": [], + rb"\berror\b": [ + b"message (level 3)", + b"regulatory.db", + b".pcie: probe with driver pci-host-generic failed with error -16", + b"rust/kernel/error.rs", + ], + rb"\berrors\b": [], + rb"\bwarning\b": [ + b"message (level 4)" + ], + rb"\bwarnings\b": [], +} + +def main(): + ok = True + with open(sys.argv[1], "rb") as file: + for line in file: + for pattern in PATTERNS: + if re.search(pattern, line): + for allowed_string in PATTERNS[pattern]: + if allowed_string in line: + break + else: + ok = False + print("Bad line found in log:") + print(f" Line: {line}") + print(f" Pattern: {pattern}") + print(f" Allowed: {PATTERNS[pattern]}") + print() + + if not ok: + raise SystemExit(1) + +if __name__ == '__main__': + main()