DragonOS/kernel/crates/rust-slabmalloc
LoGin e8fc8b3af9
Build multiversion docs / build-multiversion (push) Waiting to run Details
Sync to CNB.cool / sync (push) Waiting to run Details
Test MM (Host) / Build slab_stress (host) (push) Waiting to run Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (1, 128) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (1, 255) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (1, 256) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (1, 64) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (2, 128) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (2, 255) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (2, 256) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (2, 64) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (3, 128) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (3, 255) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (3, 256) (push) Blocked by required conditions Details
Test MM (Host) / Slab allocator long-run (valgrind) - size=${{ matrix.size }}, seed=${{ matrix.seed }} (3, 64) (push) Blocked by required conditions Details
Test x86_64 / Integration Test (push) Waiting to run Details
ci: 添加rust-slabmalloc的主机测试工作流和属性测试 (#1577)
- 新增GitHub Actions工作流,用于在主机上构建并运行slab_stress压力测试
- 添加proptest依赖,实现随机分配/释放序列的属性测试
- 新增slab_stress二进制工具,支持Valgrind内存检查
- 完善测试文档,说明主机测试的使用方法
- 修复页面状态迁移测试,确保Full/Partial/Empty列表转换正确

Signed-off-by: longjin <longjin@DragonOS.org>
2025-12-30 08:37:47 +08:00
..
src ci: 添加rust-slabmalloc的主机测试工作流和属性测试 (#1577) 2025-12-30 08:37:47 +08:00
Cargo.toml ci: 添加rust-slabmalloc的主机测试工作流和属性测试 (#1577) 2025-12-30 08:37:47 +08:00
README.host-tests.md ci: 添加rust-slabmalloc的主机测试工作流和属性测试 (#1577) 2025-12-30 08:37:47 +08:00

README.host-tests.md

rust-slabmallocLinux 主机测试体系

该目录下的 slabmallocno_std 库,但在 Linux 主机上我们可以用 cargo test 跑单元测试/属性测试,并用一个独立的压力工具配合 Valgrind/Miri 做长稳与 UB 检查。

快速开始

在本 crate 目录运行:

cd /home/jinlong/code/DragonOS/kernel/crates/rust-slabmalloc
cargo test

单元测试Unit tests

单元测试位于 src/tests.rs,覆盖:

  • 基础分配/释放正确性
  • ObjectPage 布局与位图行为
  • 页链表迁移不变量full/partial/empty 即时迁移)

属性/随机测试proptest

属性测试位于 src/prop_tests.rs,使用 proptest 生成随机 alloc/free 序列,验证:

  • 反复 alloc/free 不崩溃
  • 最终可回收所有 empty 页到 pager不泄漏

运行:

cargo test prop_

如需更“啰嗦”的 proptest 输出:

PROPTEST_VERBOSE=1 cargo test prop_

压测/长稳slab_stress

该工具是一个 host 可执行程序:src/bin/slab_stress.rs

编译并运行release

cargo run --release --features host --bin slab_stress -- --iters 500000 --max-live 4096 --size 64 --seed 1

Valgrind

先编译 release

cargo build --release --features host --bin slab_stress

再用 Valgrind 跑:

valgrind \
  -s \
  --error-exitcode=1 \
  --track-origins=yes \
  --leak-check=full \
  --show-leak-kinds=all \
  --malloc-fill=0xAA --free-fill=0xDD \
  ../../target/release/slab_stress --iters 200000 --size 64 --seed 1

说明:如果你看到 still reachable(比如来自 Rust std 的线程信息),这通常不是越界/泄漏错误;真正的越界会体现在 ERROR SUMMARYInvalid read/write 报告里。