A crate helps to testing enclaves written based on the teaclave-sgx-sdk.
The official sgx_unittest helps us to write unit tests for crates ported to teaclave-sgx-sdk. The library crate is a great tool. The bad thing is that I'm too lazy to do the manual chores when using it in practice like official samplecode:( However, it can be bettered as suggested by teaclave-sgx-sdk issue#232. Thanks to the prototype implemented by mssum, here comes my implementation.
When porting crates to teaclave-sgx-sdk, we should minimize the change to unit tests of the ported crates. That's to say, following macros/attributes should remain untouched and function as close as that of the official rust
#[test]
#[should_panic(expected = "your expected panicking message")]
#[ignore]
However, it has following limits I find no way to address for now
#[should_panic(expected = "...")]
and#[ignore]
must come after#[test]
but not before to take effects.- The
generate_runner!();
macro has to declared the exportedtests
under the crate root
Currently, the supported version of teaclave-sgx-sdk is v1.1.2 only.
Please check the source code and docs to see the crate's usage.
FYI: To avoid optimization (which will prune away some test cases) by the compiler, solution proposed by teaclave-sgx-sdk issue#232 needs taking.
- cargo-teaclave: A tool helps to test teaclave-sgx-sdk-ported crates by generating testing drivers automatically
- Since the local
proc_macro
depends onregex@=v1.3.9
, it would cause vendoring failed if your enclave crates depends the EXACTLY version of a teaclave-sgx-sdk-ported variant of thisregex
crate. This is because cargo doesn't allow us vendor two crates bearing the SAME name and the SAME version.This is why we disable the default features of
regex
used by ourproc_macro
to make its as slim as possible, to avoid potential conflicts propogating to indirect dependencies.