From e4b14aa1b4867fde96e4c094133c399c6fe777f8 Mon Sep 17 00:00:00 2001 From: Yiwei Lin Date: Tue, 15 Oct 2024 23:42:58 +0800 Subject: [PATCH] Fix build error with workflow update --- .github/workflows/cargo-test-kexpr.yml | 59 ++++++++++++++++++++++++++ .github/workflows/cargo-test.yml | 15 +++---- Makefile | 4 +- src/kexpr.rs | 1 - src/msg/mod.rs | 2 +- tests/kexpr.py | 1 + 6 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/cargo-test-kexpr.yml diff --git a/.github/workflows/cargo-test-kexpr.yml b/.github/workflows/cargo-test-kexpr.yml new file mode 100644 index 0000000..8ff1c8e --- /dev/null +++ b/.github/workflows/cargo-test-kexpr.yml @@ -0,0 +1,59 @@ +name: cargo-test-kexpr + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + install: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Get-submodule + run: git submodule update --init --recursive + + - name: Install-linux-dbgsym + run: | + NAME=$(lsb_release -c | awk '{print $2}') + sudo tee /etc/apt/sources.list.d/ddebs.list << EOF + deb http://ddebs.ubuntu.com/ ${NAME} main restricted universe multiverse + deb http://ddebs.ubuntu.com/ ${NAME}-updates main restricted universe multiverse + EOF + + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C8CAB6595FDFF622 + sudo apt-get update + sudo apt-get install linux-image-$(uname -r)-dbgsym + + - name: Install-dependencies + run: | + sudo apt-get update + sudo apt install autoconf automake check gcc clang llvm liblzma-dev libelf-dev libdw-dev libtool make pkgconf python3 python3-dev python3-pip python3-setuptools zlib1g-dev + + - name: Install-bpftool + run: | + git clone https://github.com/libbpf/bpftool.git + cd bpftool + git submodule update --init + cd src; make; sudo make install + + - name: Install-drgn + run: | + git clone https://github.com/osandov/drgn.git + cd drgn + python3 setup.py build + sudo python3 setup.py install + + - name: Create-vmlinux-h + run: bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h + + - name: Test + run: | + cargo clean + cargo build + CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test --target-dir test_build diff --git a/.github/workflows/cargo-test.yml b/.github/workflows/cargo-test.yml index d0f7b55..061d191 100644 --- a/.github/workflows/cargo-test.yml +++ b/.github/workflows/cargo-test.yml @@ -1,4 +1,4 @@ -name: Rust +name: cargo-test on: push: @@ -22,6 +22,7 @@ jobs: run: | sudo apt-get update sudo apt-get install clang llvm libelf1 libelf-dev zlib1g-dev + - name: Install-bpftool run: | git clone https://github.com/libbpf/bpftool.git @@ -32,14 +33,8 @@ jobs: - name: Create-vmlinux-h run: bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h - - name: Test-normal - run: | - cargo clean - cargo build --no-default-features kexpr - sudo cargo test --target-dir test_build - - - name: Test-kexpr + - name: Test run: | cargo clean - cargo build - sudo cargo test --target-dir test_build + cargo build --no-default-features + cargo test --no-default-features --target-dir test_build diff --git a/Makefile b/Makefile index 1a0eb82..9d307e9 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ ifeq ($(ARCH), ) CARGO_OPT = ifeq ("$(wildcard /proc/kcore)", "") - BUILD_FEATURE += --no-default-features kexpr + BUILD_FEATURE += --no-default-features endif ifneq ("$(wildcard /sys/kernel/btf/vmlinux)", "") @@ -64,7 +64,7 @@ check: # FIXME: This will create file with super user permission. We # better avoid this if possible. test: - sudo cargo test --features kexpr --target-dir test_build + CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test --target-dir test_build clean: cargo clean diff --git a/src/kexpr.rs b/src/kexpr.rs index a176dbf..004a93b 100644 --- a/src/kexpr.rs +++ b/src/kexpr.rs @@ -254,7 +254,6 @@ mod kexpr_tests { &String::from_utf8( Command::new("./tests/kexpr.py") .args($args) - .stdout(Stdio::piped()) .output() .expect("Fail to execute kexpr") .stdout, diff --git a/src/msg/mod.rs b/src/msg/mod.rs index b9b0b38..e1914da 100644 --- a/src/msg/mod.rs +++ b/src/msg/mod.rs @@ -16,7 +16,7 @@ struct MsgEnt { id: u64, typ: u64, pid: u64, - cmd: [c_char; TASK_COMM_LEN], + cmd: [u8; TASK_COMM_LEN], } unsafe impl Plain for MsgEnt {} diff --git a/tests/kexpr.py b/tests/kexpr.py index bc13b95..78ba834 100755 --- a/tests/kexpr.py +++ b/tests/kexpr.py @@ -59,5 +59,6 @@ def busdev_kexpr2addr(bus, device, kexpr): elif plat_dev: busdev_kexpr2addr("platform", plat_dev, kexpr) else: + print(f"Invalid arguments {args}") exit(1)