Add a test for fd_filestat_set_*#14
Conversation
This PR matches CraneStation/wasi-misc-tests#14. The file was created using `cargo build --release --target=wasm32-wasi`
kubkon
left a comment
There was a problem hiding this comment.
LGTM! Just some minor nitpicks.
src/bin/fd_filestat_set.rs
Outdated
| use misc_tests::wasi::{wasi_fd_filestat_set_size, wasi_fd_filestat_set_times, wasi_fd_filestat_get, wasi_path_open}; | ||
| use std::{env, process}; | ||
|
|
||
| fn test_file_allocate(dir_fd: libc::__wasi_fd_t) { |
There was a problem hiding this comment.
Would you mind renaming the test case to for example test_fd_filestat_set? I know it's less than ideal and somewhat cumbersome, but I'd like to keep the tests names collision free so that, in the future, if anybody wants to, they can pull all test cases into one binary. :-)
There was a problem hiding this comment.
Sorry for that, that was remains of the old testcase :)
src/bin/fd_filestat_set.rs
Outdated
| ); | ||
| assert_eq!(stat.st_size, 100, "file size should be 100"); | ||
|
|
||
| // Allocate should not modify if less than current size |
There was a problem hiding this comment.
Hmm, is this a runaway comment from a different testcase perhaps?
| stat.st_mtim, new_mtim, "mtim should change" | ||
| ); | ||
| assert_eq!( | ||
| stat.st_atim, old_atim, "atim should not change" |
There was a problem hiding this comment.
Would you mind swapping new_mtim and old_atim for expected literal values? I find that tests which use variables for testing, sometimes can produce misleading results. :-)
There was a problem hiding this comment.
I need to remember the old values of stat.st_atim and stat.st_mtim somewhere, because it's stat is reused between fd_filestat_get calls. I can alternatively clone the whole stat structure but I'm not sure if it's cleaner.
There was a problem hiding this comment.
Ah, of course, that's fair enough! :-)
53d5161 to
09eeca1
Compare
|
I'll merge it now, but could you open a PR adding the binary to |
|
The changes in 09eeca1 didn't change the resulting binary. I expect the CI to pass in CraneStation/wasi-common#56 now, after disabling the test on Windows for the time being. |
This PR matches CraneStation/wasi-misc-tests#14. The file was created using `cargo build --release --target=wasm32-wasi`
The test works for me on Linux with current master wasi-common.