action: enable unit test
diff --git a/.github/workflows/sim-example.yml b/.github/workflows/sim-example.yml
index 839fff5..29f9a6d 100644
--- a/.github/workflows/sim-example.yml
+++ b/.github/workflows/sim-example.yml
@@ -41,9 +41,9 @@
- "switchless"
- "tcmalloc"
- "thread"
+ - "unit-test"
- "wasmi"
- "zlib-lazy-static-sample"
- #- "unit-test" TODO: fix or conditionalize UD catcher
runs-on: ${{ matrix.runs-on }}
container:
image: ${{ matrix.image }}
diff --git a/samplecode/unit-test/enclave/Cargo.toml b/samplecode/unit-test/enclave/Cargo.toml
index 59964d3..1e0e6d9 100644
--- a/samplecode/unit-test/enclave/Cargo.toml
+++ b/samplecode/unit-test/enclave/Cargo.toml
@@ -9,6 +9,7 @@
[features]
default = []
+hw_test = []
[target.'cfg(not(target_env = "sgx"))'.dependencies]
sgx_types = { git = "https://github.com/apache/teaclave-sgx-sdk.git" }
@@ -59,4 +60,4 @@
sgx_unwind = { path = "../../../sgx_unwind" }
sgx_signal = { path = "../../../sgx_signal" }
#sgx_ucrypto = { path = "../../../sgx_ucrypto" }
-#sgx_urts = { path = "../../../sgx_urts" }
\ No newline at end of file
+#sgx_urts = { path = "../../../sgx_urts" }
diff --git a/samplecode/unit-test/enclave/build.rs b/samplecode/unit-test/enclave/build.rs
new file mode 100644
index 0000000..1839008
--- /dev/null
+++ b/samplecode/unit-test/enclave/build.rs
@@ -0,0 +1,14 @@
+use std::env;
+
+fn main () {
+ let is_sim = env::var("SGX_MODE")
+ .unwrap_or_else(|_| "HW".to_string());
+
+ match is_sim.as_ref() {
+ "SW" => {
+ },
+ _ => { // HW by default
+ println!("cargo:rustc-cfg=feature=\"hw_test\"");
+ },
+ }
+}
diff --git a/samplecode/unit-test/enclave/src/test_exception.rs b/samplecode/unit-test/enclave/src/test_exception.rs
index a57579f..963cd46 100644
--- a/samplecode/unit-test/enclave/src/test_exception.rs
+++ b/samplecode/unit-test/enclave/src/test_exception.rs
@@ -35,7 +35,11 @@
std::intrinsics::abort()
}
+#[cfg_attr(not(feature = "hw_test"), allow(unreachable_code))]
pub fn test_exception_handler() {
+ #[cfg(not(feature = "hw_test"))]
+ return;
+
let _ = backtrace::enable_backtrace("enclave.signed.so", PrintFormat::Full);
let status = Arc::new(AtomicUsize::new(2));