-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add direct tests for all shims #3179
Comments
Hi there! I'm interested in contributing and thought I'd start with this issue which sounds doable. I'm studying software engineering at uni and I had some experience with C and currently going deeper into Rust after taking a course at uni. From what I understand so far for this issue, I wrote some code and this is what I have so far and I was wondering if I'm in the right direction?
fn main() {
// ...
test_ftruncate();
}
fn test_ftruncate() {
// Create a file with some content
// Taken from the test functions above
let path = prepare_with_content("test_ftruncate.txt", &[]);
let mut name = path.into_os_string();
name.push("\0");
let name_ptr = name.as_bytes().as_ptr().cast::<libc::c_char>();
let fd = unsafe { libc::open(name_ptr, libc::O_RDONLY, 42) };
// We use i64 here because the second argument for ftruncate()
// uses off_t which is a signed integer types and on my machine,
// off_t is synonymous with long long
// References:
// - https://doc.rust-lang.org/std/os/raw/type.c_longlong.html
// - https://locka99.gitbooks.io/a-guide-to-porting-c-to-rust/content/features_of_rust/types.html
// - https://stackoverflow.com/questions/9073667/where-to-find-the-complete-definition-of-off-t-type
let l: i64 = 4;
let length = l.cast::<libc::c_longlong>(); // not too sure about this line
let res = unsafe { libc::ftruncate(fd, length) };
if res == 0 {
// call succeeds
} else {
// call fails
}
} |
Right, basically these tests should be fairly similar to this one but directly using the libc APIs rather than calling Rust's You can use the |
Support for extra modes in |
Add libc direct test for shims and update CONTRIBUTING.md Add more ``libc`` direct test for shims as mentioned in #3179. Changes: - Added ``libc`` direct tests for ``rename`` and ``ftruncate64`` - Added the command for running ``pass-dep`` test in ``CONTRIBUTING.md``
For example: "lseek" on Linux is currently only tested via the libstd functions, but not via direct libc calls.
And really we should ideally have direct tests for all of our shims to make sure they don't start to bitrot when the standard library changes. So the first step here would be to figure out which of our shims still need testing. Just assembling the TODO list is already quite valuable!
The text was updated successfully, but these errors were encountered: