proot-me / proot-rs

Rust implementation of PRoot, a ptrace-based sandbox
GNU General Public License v3.0
129 stars 21 forks source link

Implement test_with_proot() for unit tests #30

Closed imlk0 closed 3 years ago

imlk0 commented 3 years ago

This PR is purely test-related:

After this we can write unit tests for each system call to test if syscall translation is correct.

test_with_proot() starts a regular proot-rs event loop and runs our tracee function, we can place some syscall in tracee function to simulate a normal tracee program. In addition, I extended the struct Proot by adding a Fn field to hold a callback function. In this callback function, we are able to check the internal state of proot-rs (e.g. by some assert!() statements). Of course, all of the above are controlled by conditional compilation and are only enabled in unit tests.