proot-me / proot-rs

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

Unit test for working directory in guestfs #26

Closed oxr463 closed 3 years ago

oxr463 commented 3 years ago

Do we have a unit test for this?

/// Working directory in guestfs, e.g., `/proc/self/cwd`, is always absolute

_Originally posted by @oxr463 in https://github.com/proot-me/proot-rs/pull/25#discussion_r645747165_

imlk0 commented 3 years ago

Unit tests for cwd field are included in this PR:

https://github.com/proot-me/proot-rs/blob/9a00a8885e00eefb084f5930f7e9b4baad9ef418/src/kernel/standard/chdir.rs#L63-L70

More specifically, in the unit test function test_chdir_fchdir_and_getcwd(), a series of system calls are placed in tracee function (i.e., chdir() and fchdir()) to change the current working directory, and a hook function is placed in proot-rs to check if the cwd field is always a canonical path from start to finish.