-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(fs-test): refactor new_file_test
new_file_test now runs a kernel called open_close_file, which attempts to open foo.txt, write to it, then closes the file, and attempts to open it again so as to read from it. This is more of a workaround because of the fact that we cannot read the temporary file easily, but it should work just as well and expand the test's coverage to "reading the contents of a file that is a temporary file on the host filesystem".
- Loading branch information
Showing
3 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
[package] | ||
name = "uhyve-test-kernels" | ||
version = "0.1.0" | ||
authors = ["Jonathan Klimt <[email protected]>"] | ||
authors = [ | ||
"Jonathan Klimt <[email protected]>", | ||
'Panagiotis "Ivory" Vasilopoulos <[email protected]>', | ||
] | ||
edition = "2021" | ||
publish = false | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::{ | ||
fs::{read_to_string, File}, | ||
io::prelude::*, | ||
}; | ||
|
||
#[cfg(target_os = "hermit")] | ||
use hermit as _; | ||
|
||
fn main() { | ||
println!("Hello from open_close_file!"); | ||
|
||
{ | ||
let mut file = File::create("/root/foo.txt").unwrap(); | ||
file.write_all(b"Hello, world!").unwrap(); | ||
} | ||
{ | ||
let file_content = read_to_string("/root/foo.txt").unwrap(); | ||
assert_eq!(file_content, "Hello, world!".to_string()); | ||
} | ||
} |