sccommunity / teaclave-testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

teaclave-testing

build

A crate helps to testing enclaves written based on the teaclave-sgx-sdk.

Why

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 exported tests under the crate root

Environment

Currently, the supported version of teaclave-sgx-sdk is v1.1.2 only.

Examples

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.

Recommendation

  • cargo-teaclave: A tool helps to test teaclave-sgx-sdk-ported crates by generating testing drivers automatically

Heads Up

  • Since the local proc_macro depends on regex@=v1.3.9, it would cause vendoring failed if your enclave crates depends the EXACTLY version of a teaclave-sgx-sdk-ported variant of this regex 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 our proc_macro to make its as slim as possible, to avoid potential conflicts propogating to indirect dependencies.

References

About


Languages

Language:Rust 79.9%Language:CMake 20.1%