diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3c9f343..4abc67e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -114,6 +114,12 @@ 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 + rustup component add clippy rustfmt + echo "MAKE_KRUSTFLAGS=KRUSTFLAGS=-Zcodegen-backend=$(pwd)/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so" >> $GITHUB_ENV @@ -225,30 +231,9 @@ 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 - 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() 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