From 5f731a0a605fb17b907852c9512bad348aec7142 Mon Sep 17 00:00:00 2001 From: Able Date: Sat, 9 Apr 2022 16:50:07 -0500 Subject: [PATCH] add in aos_stress_test --- .gitignore | 3 ++- Cargo.toml | 1 + aos_wasm_stress_test/.cargo/config.toml | 6 +++++ aos_wasm_stress_test/Cargo.toml | 10 ++++++++ aos_wasm_stress_test/build.sh | 3 +++ aos_wasm_stress_test/readme.md | 4 ++++ aos_wasm_stress_test/src/main.rs | 31 +++++++++++++++++++++++++ aos_wasm_stress_test/src/panic.rs | 6 +++++ 8 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 aos_wasm_stress_test/.cargo/config.toml create mode 100644 aos_wasm_stress_test/Cargo.toml create mode 100755 aos_wasm_stress_test/build.sh create mode 100644 aos_wasm_stress_test/readme.md create mode 100644 aos_wasm_stress_test/src/main.rs create mode 100644 aos_wasm_stress_test/src/panic.rs diff --git a/.gitignore b/.gitignore index 64be939..9dbe23e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -/*/target +*/target +target Cargo.lock diff --git a/Cargo.toml b/Cargo.toml index da15068..5598836 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,4 +2,5 @@ members = [ "libwasm", + "aos_wasm_stress_test", ] \ No newline at end of file diff --git a/aos_wasm_stress_test/.cargo/config.toml b/aos_wasm_stress_test/.cargo/config.toml new file mode 100644 index 0000000..f44d78c --- /dev/null +++ b/aos_wasm_stress_test/.cargo/config.toml @@ -0,0 +1,6 @@ +[build] +target = "wasm32-unknown-unknown" + +# [unstable] +# build-std = ["core", "compiler_builtins", "alloc"] +# build-std-features = ["compiler-builtins-mem"] diff --git a/aos_wasm_stress_test/Cargo.toml b/aos_wasm_stress_test/Cargo.toml new file mode 100644 index 0000000..fbf8c8d --- /dev/null +++ b/aos_wasm_stress_test/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "aos_wasm_stress_test" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +libwasm = {path="../libwasm"} +# mice = "0.11.0" diff --git a/aos_wasm_stress_test/build.sh b/aos_wasm_stress_test/build.sh new file mode 100755 index 0000000..986dc9e --- /dev/null +++ b/aos_wasm_stress_test/build.sh @@ -0,0 +1,3 @@ +cargo build --release +wasm-strip target/wasm32-unknown-unknown/release/aos_wasm_stress_test.wasm +mv target/wasm32-unknown-unknown/release/aos_wasm_stress_test.wasm aos_wasm_stress_test.wasm \ No newline at end of file diff --git a/aos_wasm_stress_test/readme.md b/aos_wasm_stress_test/readme.md new file mode 100644 index 0000000..3a68e32 --- /dev/null +++ b/aos_wasm_stress_test/readme.md @@ -0,0 +1,4 @@ + +This is a stress test and simple program for ableOS. + + diff --git a/aos_wasm_stress_test/src/main.rs b/aos_wasm_stress_test/src/main.rs new file mode 100644 index 0000000..0f0d312 --- /dev/null +++ b/aos_wasm_stress_test/src/main.rs @@ -0,0 +1,31 @@ +#![no_std] +#![no_main] + +use libwasm::driver::DriverExitCode; + +#[no_mangle] +fn start() -> i32 { + let rand; + unsafe { + send_signal(PID(1), Signals::Quit); + rand = get_random(); + } + + rand as i32 +} + +#[no_mangle] +fn driver_entry() {} + +#[no_mangle] +fn driver_exit() -> DriverExitCode { + DriverExitCode::Success +} + +use { + libwasm::get_random, + libwasm::process::{signals::Signals, PID}, + libwasm::syscalls::send_signal, +}; + +mod panic; diff --git a/aos_wasm_stress_test/src/panic.rs b/aos_wasm_stress_test/src/panic.rs new file mode 100644 index 0000000..47f4b6b --- /dev/null +++ b/aos_wasm_stress_test/src/panic.rs @@ -0,0 +1,6 @@ +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop {} +} + +use core::panic::PanicInfo;