Skip to content

Commit

Permalink
Add integration test for environment variable in virtual machine
Browse files Browse the repository at this point in the history
  • Loading branch information
AlixANNERAUD committed Oct 8, 2024
1 parent b671388 commit 750c96b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Modules/Virtual_machine/Tests/Test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ extern "C" fn Test_string(

#[test]
fn Integration_test() {
Task::Initialize().expect("Failed to initialize task manager");
let Task_instance = Task::Initialize().expect("Failed to initialize task manager");

Users::Initialize().expect("Failed to initialize users manager");

Expand All @@ -96,9 +96,18 @@ fn Integration_test() {

File_system::Initialize(File_system).unwrap();

// Set environment variables
let Task = Task_instance.Get_current_task_identifier().unwrap();

Task_instance
.Set_environment_variable(Task, "Path", "/:/bin:/usr/bin")
.unwrap();

// Load the WASM binary
let Binary_buffer =
include_bytes!("./WASM_test/target/wasm32-wasip1/release/Virtual_machine_WASM_test.wasm");

// Register the functions
pub struct Registrable {}

impl Registrable_trait for Registrable {
Expand All @@ -116,6 +125,7 @@ fn Integration_test() {

let User_data = Data_type::New();

// Instantiate the environment
let (_Runtime, _Module, Instance) = Instantiate_test_environment(
Binary_buffer,
Registrable {},
Expand Down
12 changes: 12 additions & 0 deletions Modules/Virtual_machine/Tests/WASM_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ fn Test_file() {
}
}

fn Test_environment_variables() {
println!("Environment variables:");

let Environment = std::env::vars();

for (Key, Value) in Environment {
println!("{}: {}", Key, Value);
}
}

fn Test_directory() {
create_dir("/test_dir").unwrap();

Expand Down Expand Up @@ -171,5 +181,7 @@ fn main() -> Result<(), ()> {

Test_directory();

Test_environment_variables();

Ok(())
}

0 comments on commit 750c96b

Please sign in to comment.