Skip to content

Commit 68558af

Browse files
committed
simulate prohibited instructions
Signed-off-by: Jun Kimura <[email protected]>
1 parent b071a20 commit 68558af

File tree

11 files changed

+778
-39
lines changed

11 files changed

+778
-39
lines changed

Makefile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,27 @@ clippy:
2929
check: fmt-check clippy
3030

3131
.PHONY: test
32-
test:
33-
@echo "Building and running unit tests..."
32+
test: enclave-test untrusted-test
33+
@echo "All tests completed successfully!"
34+
35+
.PHONY: enclave-test
36+
enclave-test:
37+
@echo "Building and running enclave unit tests..."
3438
@cd unit-test && make clean all
3539
@cd unit-test/bin && ./app
3640

41+
.PHONY: untrusted-test
42+
untrusted-test:
43+
@echo "Running untrusted crate tests..."
44+
@echo "Testing sgx-types..."
45+
@cd sgx-types && cargo test --features urts
46+
@echo "Testing sgx-urts..."
47+
@cd sgx-urts && cargo test --features simulate_utils
48+
@echo "Testing sgx-build..."
49+
@cd sgx-build && cargo test
50+
@echo "Testing cargo-sgx..."
51+
@cd cargo-sgx && cargo test
52+
3753
.PHONY: toml-fmt
3854
toml-fmt:
3955
@echo "Formatting TOML files..."

samples/hello-rust/app/src/main.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,15 @@ extern "C" {
3636
fn init_enclave() -> SgxResult<SgxEnclave> {
3737
let mut launch_token: sgx_launch_token_t = [0; 1024];
3838
let mut launch_token_updated: i32 = 0;
39-
let debug = match env::var("SGX_DEBUG") {
40-
Ok(val) => match val.as_str() {
41-
"1" => 1,
42-
_ => 0,
43-
},
44-
Err(_) => 0,
45-
};
39+
let debug = env::var("SGX_DEBUG").unwrap_or_default() == "1";
4640
let mut misc_attr = sgx_misc_attribute_t {
4741
secs_attr: sgx_attributes_t { flags: 0, xfrm: 0 },
4842
misc_select: 0,
4943
};
5044
// call sgx_create_enclave to initialize an enclave instance
5145
SgxEnclave::create(
5246
ENCLAVE_FILE,
53-
debug,
47+
debug.into(),
5448
&mut launch_token,
5549
&mut launch_token_updated,
5650
&mut misc_attr,

sgx-urts/Cargo.toml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
[package]
2-
name = "sgx-urts"
3-
version = "1.2.0"
4-
authors = ["The Teaclave Authors", "The SGX-SDK-RS Authors"]
5-
repository = "https://github.com/datachainlab/sgx-sdk-rs"
6-
license = "Apache-2.0"
7-
description = "Rust SGX SDK provides the ability to write Intel SGX applications in Rust Programming Language."
8-
edition = "2021"
2+
name = "sgx-urts"
3+
version = "1.2.0"
4+
authors = ["The Teaclave Authors", "The SGX-SDK-RS Authors"]
5+
repository = "https://github.com/datachainlab/sgx-sdk-rs"
6+
license = "Apache-2.0"
7+
description = "Rust SGX SDK provides the ability to write Intel SGX applications in Rust Programming Language."
8+
edition = "2021"
99

1010
[lib]
1111
name = "sgx_urts"
1212
crate-type = ["rlib"]
1313

1414
[features]
15-
default = []
16-
global_init = ["global_exit"]
17-
global_exit = ["global_init"]
15+
default = []
16+
global_init = ["global_exit"]
17+
global_exit = ["global_init"]
18+
simulate_utils = ["tracing", "object", "iced-x86"]
1819

1920
[dependencies]
21+
tracing = { version = "0.1", optional = true }
2022
sgx-types = { path = "../sgx-types", default-features = false, features = ["urts"] }
21-
libc = "0.2"
23+
libc = { version = "0.2" }
24+
object = { version = "0.37", optional = true }
25+
iced-x86 = { version = "1.21", optional = true }

sgx-urts/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub mod net;
2828
pub mod pipe;
2929
pub mod process;
3030
pub mod signal;
31+
#[cfg(feature = "simulate_utils")]
32+
pub mod simulate;
3133
pub mod socket;
3234
pub mod sys;
3335
pub mod thread;

0 commit comments

Comments
 (0)