Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,10 @@ fn kernel_main_continue() -> ! {
test_exec::test_wc_coreutil();
log::info!("=== COREUTIL TEST: which (command location) ===");
test_exec::test_which_coreutil();
log::info!("=== COREUTIL TEST: cat (file concatenation) ===");
test_exec::test_cat_coreutil();
log::info!("=== COREUTIL TEST: ls (directory listing) ===");
test_exec::test_ls_coreutil();

// Test Rust std library support
log::info!("=== STD TEST: Rust std library support ===");
Expand Down
58 changes: 58 additions & 0 deletions kernel/src/test_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2735,3 +2735,61 @@ pub fn test_which_coreutil() {
}
}
}

/// Test the `cat` coreutil
///
/// Verifies that /bin/cat correctly outputs file contents.
pub fn test_cat_coreutil() {
log::info!("Testing cat coreutil (file concatenation)");

#[cfg(feature = "testing")]
let cat_test_elf_buf = crate::userspace_test::get_test_binary("cat_test");
#[cfg(feature = "testing")]
let cat_test_elf: &[u8] = &cat_test_elf_buf;
#[cfg(not(feature = "testing"))]
let cat_test_elf = &create_hello_world_elf();

match crate::process::creation::create_user_process(
String::from("cat_test"),
cat_test_elf,
) {
Ok(pid) => {
log::info!("Created cat_test process with PID {:?}", pid);
log::info!("cat_test: process scheduled for execution.");
log::info!(" -> Userspace will emit CAT_TEST_PASSED marker if successful");
}
Err(e) => {
log::error!("Failed to create cat_test process: {}", e);
log::error!("cat_test cannot run without valid userspace process");
}
}
}

/// Test the `ls` coreutil
///
/// Verifies that /bin/ls correctly lists directory contents.
pub fn test_ls_coreutil() {
log::info!("Testing ls coreutil (directory listing)");

#[cfg(feature = "testing")]
let ls_test_elf_buf = crate::userspace_test::get_test_binary("ls_test");
#[cfg(feature = "testing")]
let ls_test_elf: &[u8] = &ls_test_elf_buf;
#[cfg(not(feature = "testing"))]
let ls_test_elf = &create_hello_world_elf();

match crate::process::creation::create_user_process(
String::from("ls_test"),
ls_test_elf,
) {
Ok(pid) => {
log::info!("Created ls_test process with PID {:?}", pid);
log::info!("ls_test: process scheduled for execution.");
log::info!(" -> Userspace will emit LS_TEST_PASSED marker if successful");
}
Err(e) => {
log::error!("Failed to create ls_test process: {}", e);
log::error!("ls_test cannot run without valid userspace process");
}
}
}
8 changes: 8 additions & 0 deletions userspace/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,14 @@ path = "wc_test.rs"
name = "which_test"
path = "which_test.rs"

[[bin]]
name = "cat_test"
path = "cat_test.rs"

[[bin]]
name = "ls_test"
path = "ls_test.rs"

[[bin]]
name = "fork_memory_test"
path = "fork_memory_test.rs"
Expand Down
2 changes: 2 additions & 0 deletions userspace/tests/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ BINARIES=(
"tail_test"
"wc_test"
"which_test"
"cat_test"
"ls_test"
)

echo "Building ${#BINARIES[@]} userspace binaries with libbreenix..."
Expand Down
Loading
Loading