diff --git a/.vscode/settings.json b/.vscode/settings.json index e3259c6f0200d3db0961f37e713bf83ab7a0ec7c..2e5eb79c0a9c753fb915591e16578626e6fb7262 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,10 @@ { - "editor.tabSize": 8 + "editor.tabSize": 8, + // rust不显示类型 + "rust-analyzer.inlayHints.typeHints.enable": false, + "rust-analyzer.inlayHints.parameterHints.enable": false, + "rust-analyzer.hover.actions.debug.enable": false, + // rust不显示透镜按钮 Run Test等 + "rust-analyzer.lens.debug.enable": false, + "rust-analyzer.lens.enable": false, } \ No newline at end of file diff --git a/Makefile b/Makefile index b548989ac6c6c5d4259c5609302ad385a4cfc9e6..a44990fa5f65d14ae8dc9abbcedcdd3f33355deb 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ .PHONY: all clean test -SYSBOOSTD=./target/debug/sysboostd -SYSBOOST=../build/sysboost/sysboost +ROOT_DIR=. +SYSBOOSTD=$(ROOT_DIR)/target/debug/sysboostd +BUILD_DIR=$(ROOT_DIR)/build +SYSBOOST=$(BUILD_DIR)/src/sysboost SYSBOOSTD_INSTALL_PATH=/usr/bin/sysboostd SYSBOOST_INSTALL_PATH=/usr/bin/sysboost @@ -36,10 +38,12 @@ format: meson --internal clangformat ./ ./build cargo fmt -test: sysboostd - clear +install: cp -f $(SYSBOOSTD) $(SYSBOOSTD_INSTALL_PATH) cp -f $(SYSBOOST) $(SYSBOOST_INSTALL_PATH) + +test: sysboostd install + clear cargo test test-debug: diff --git a/tests/test_sysboostd.rs b/tests/test_sysboostd.rs index ae198239c130b9b2a50bacd215509c23cc7d0021..888a4d4d255ade064e2eb4f2176382ddfebee2c2 100644 --- a/tests/test_sysboostd.rs +++ b/tests/test_sysboostd.rs @@ -250,5 +250,29 @@ mod tests { let bak_path = "/usr/lib64/libtinfo.so.bak"; assert!(fs::metadata(bak_path).unwrap().is_file()); } + + // cargo test --test test_sysboostd -- tests::test_symbolic_link --exact --nocapture + // 测试命令是否正确设置链接flag + // sysboost -s /usr/bin/bash + // 设置后, 执行 bash & + // 观察点: /proc/pid/maps 里面包含 bash.rto 文件路径 + #[test] + fn test_symbolic_link() { + Command::new("sysboost").arg("-s").arg("/usr/bin/bash").output().expect("Failed to execute command"); + let child = Command::new("bash").arg("&").spawn().expect("Failed to execute command"); + let c_pid = child.id(); + let maps_path = format!("/proc/{}/maps", c_pid); + let output = Command::new("cat").arg(maps_path).output().expect("Failed to execute command"); + if output.status.success() { + let stdout = String::from_utf8_lossy(&output.stdout); + let maps_str = stdout.trim(); + let is_con = maps_str.contains("bash.rto"); + assert!(is_con, "contains bash.rto, \n{}", maps_str); + } else { + assert!(false, "output is fail"); + } + + Command::new("kill").arg("-9").arg(c_pid.to_string()).output().expect("Failed to execute command"); + } }