diff --git a/.github/workflows/selftest.yml b/.github/workflows/selftest.yml index 6cbe7c5..b96f432 100644 --- a/.github/workflows/selftest.yml +++ b/.github/workflows/selftest.yml @@ -8,24 +8,25 @@ on: jobs: run_tests: name: Tests - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: + - name: Checkout device-mapper-tests + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Install dependencies uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: cargo cryptsetup xfs xfsprogs - version: 1.0 + packages: cryptsetup xfs xfsprogs + version: "1.0" - name: Check cryptsetup enabled run: cryptsetup benchmark -c aes-xts-plain64 -s 512 - - name: Checkout device-mapper-tests - uses: actions/checkout@v4 - with: - repository: akiradeveloper/device-mapper-tests - ref: bump - path: tests - - name: Test - working-directory: tests/device-mapper-tests - run: sudo make test \ No newline at end of file + working-directory: device-mapper-tests + env: + CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: sudo + run: make test diff --git a/README.md b/README.md index 4e1ecb7..a1f8102 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ - device-mapper-tests: The test framework. **Please make sure all tests for the framework completes in success.** - writeboost-tests: Tests for [dm-writeboost](https://github.com/akiradeveloper/dm-writeboost). You need to `modprobe dm-writeboost`. -- wb-command-tests: Tests for [dm-writeboost-tools](https://github.com/akiradeveloper/dm-writeboost-tools). You need to `modprobe dm-writeboost` and `cargo install` the dm-writeboost-tools. +- wb-command-tests: Tests for `writeboost-cli` from [dm-writeboost-tools](https://github.com/akiradeveloper/dm-writeboost-tools). You need to `modprobe dm-writeboost` and run `cargo install --path writeboost-cli` from the dm-writeboost-tools checkout. Ensure `writeboost-cli` is on `PATH` when running the tests. ## Requirements for the framework diff --git a/device-mapper-tests/src/scenario/many_files.rs b/device-mapper-tests/src/scenario/many_files.rs index fd3eb17..591112d 100644 --- a/device-mapper-tests/src/scenario/many_files.rs +++ b/device-mapper-tests/src/scenario/many_files.rs @@ -9,7 +9,7 @@ impl ManyFiles { let n = self.n; for i in 0..n { run_cmd!(touch $root/$i).unwrap(); - run_cmd!(echo $i > $root/$i).unwrap(); + std::fs::write(format!("{}/{}", root, i), format!("{}\n", i)).unwrap(); } kernel::drop_caches(); for i in 0..n { diff --git a/wb-command-tests/tests/tests.rs b/wb-command-tests/tests/tests.rs index 3bc4eec..e9535f3 100644 --- a/wb-command-tests/tests/tests.rs +++ b/wb-command-tests/tests/tests.rs @@ -1,16 +1,16 @@ use device_mapper_tests::*; -use cmd_lib::{run_cmd, run_fun}; +use cmd_lib::run_cmd; #[test] -fn test_wbcreate() { +fn test_create() { let mut env = env(); let fast = env.alloc_device(Sector::MB(100)); let p1 = fast.path(); let slow = env.alloc_device(Sector::MB(50)); let p2 = slow.path(); - run_cmd!(wbcreate wbdev $p1 $p2 --reformat --read_cache_threshold=4 --writeback_threshold=70 --nr_max_batched_writeback=32 --update_sb_record_interval=3600 --sync_data_interval=3600 --write_around_mode).unwrap(); - run_cmd!(wbremove wbdev).unwrap(); + run_cmd!(writeboost-cli create wbdev $p1 $p2 --reformat --read_cache_threshold=4 --writeback_threshold=70 --nr_max_batched_writeback=32 --update_sb_record_interval=3600 --sync_data_interval=3600 --write_around_mode).unwrap(); + run_cmd!(writeboost-cli remove wbdev).unwrap(); } #[test] @@ -20,82 +20,82 @@ fn test_recreate() { let p1 = fast.path(); let slow = env.alloc_device(Sector::MB(50)); let p2 = slow.path(); - run_cmd!(wbcreate wbdev $p1 $p2 --reformat).unwrap(); - run_cmd!(wbremove wbdev).unwrap(); + run_cmd!(writeboost-cli create wbdev $p1 $p2 --reformat).unwrap(); + run_cmd!(writeboost-cli remove wbdev).unwrap(); - run_cmd!(wbcreate wbdev $p1 $p2).unwrap(); + run_cmd!(writeboost-cli create wbdev $p1 $p2).unwrap(); run_cmd!(dd if=/dev/zero of=/dev/mapper/wbdev oflag=direct bs=1M count=50).unwrap(); - run_cmd!(wbremove wbdev).unwrap(); + run_cmd!(writeboost-cli remove wbdev).unwrap(); } #[test] -fn test_wbremove() { +fn test_remove() { let mut env = env(); let fast = env.alloc_device(Sector::MB(100)); let p1 = fast.path(); let slow = env.alloc_device(Sector::MB(50)); let p2 = slow.path(); - run_cmd!(wbcreate wbdev $p1 $p2 --reformat).unwrap(); - run_cmd!(wbremove wbdev --noflush --nowriteback).unwrap(); + run_cmd!(writeboost-cli create wbdev $p1 $p2 --reformat).unwrap(); + run_cmd!(writeboost-cli remove wbdev --noflush --nowriteback).unwrap(); } #[test] -fn test_wbcheck() { +fn test_check() { let mut env = env(); let fast = env.alloc_device(Sector::MB(100)); let p1 = fast.path(); let slow = env.alloc_device(Sector::MB(50)); let p2 = slow.path(); - run_cmd!(wbcreate wbdev $p1 $p2 --reformat).unwrap(); + run_cmd!(writeboost-cli create wbdev $p1 $p2 --reformat).unwrap(); run_cmd!(dd if=/dev/zero of=/dev/mapper/wbdev oflag=direct bs=1M count=50).unwrap(); - run_cmd!(wbcheck $p2 1); + run_cmd!(writeboost-cli check $p2 --segid=1).unwrap(); - run_cmd!(wbremove wbdev --nowriteback); + run_cmd!(writeboost-cli remove wbdev --nowriteback).unwrap(); } #[test] -fn test_wbdump() { +fn test_dump() { let mut env = env(); let fast = env.alloc_device(Sector::MB(100)); let p1 = fast.path(); let slow = env.alloc_device(Sector::MB(50)); let p2 = slow.path(); - run_cmd!(wbcreate wbdev $p1 $p2 --reformat).unwrap(); + run_cmd!(writeboost-cli create wbdev $p1 $p2 --reformat).unwrap(); run_cmd!(dd if=/dev/zero of=/dev/mapper/wbdev oflag=direct bs=1M count=50).unwrap(); - run_cmd!(wbdump $p2 1).unwrap(); + run_cmd!(writeboost-cli dump $p2 1).unwrap(); - run_cmd!(wbremove wbdev).unwrap(); + run_cmd!(writeboost-cli remove wbdev).unwrap(); } #[test] -fn test_wbmeta() { +fn test_meta() { let mut env = env(); let fast = env.alloc_device(Sector::MB(100)); let p1 = fast.path(); let slow = env.alloc_device(Sector::MB(50)); let p2 = slow.path(); - run_cmd!(wbcreate wbdev $p1 $p2 --reformat).unwrap(); + run_cmd!(writeboost-cli create wbdev $p1 $p2 --reformat).unwrap(); run_cmd!(dd if=/dev/zero of=/dev/mapper/wbdev oflag=direct bs=1M count=50).unwrap(); - run_cmd!(wbmeta $p2 0).unwrap(); - run_cmd!(wbmeta $p2 1).unwrap(); + run_cmd!(writeboost-cli meta $p2 0).unwrap(); + run_cmd!(writeboost-cli meta $p2 1).unwrap(); - run_cmd!(wbremove wbdev).unwrap(); + run_cmd!(writeboost-cli remove wbdev).unwrap(); } #[test] -fn test_wbstatus() { +fn test_status() { let mut env = env(); let fast = env.alloc_device(Sector::MB(100)); let p1 = fast.path(); let slow = env.alloc_device(Sector::MB(50)); let p2 = slow.path(); - run_cmd!(wbcreate wbdev $p1 $p2 --reformat).unwrap(); + run_cmd!(writeboost-cli create wbdev $p1 $p2 --reformat).unwrap(); run_cmd!(dd if=/dev/zero of=/dev/mapper/wbdev oflag=direct bs=1M count=50).unwrap(); - run_cmd!(dmsetup status wbdev | wbstatus).unwrap(); + run_cmd!(dmsetup status wbdev | writeboost-cli status).unwrap(); - run_cmd!(wbremove wbdev --nowriteback).unwrap(); + run_cmd!(writeboost-cli remove wbdev --nowriteback).unwrap(); }