This is an automated email from the ASF dual-hosted git repository.
mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git
The following commit(s) were added to refs/heads/develop by this push:
new ae797aa [tests] Reorganize tests
ae797aa is described below
commit ae797aa5447b7a2b45285d15f2f0d147ac432af6
Author: Mingshen Sun <[email protected]>
AuthorDate: Thu Jan 16 23:08:43 2020 -0800
[tests] Reorganize tests
---
cmake/scripts/parse_cargo_packages.py | 2 +-
cmake/scripts/test.sh | 19 +++++--
cmake/tomls/Cargo.sgx_trusted_lib.toml | 7 +--
cmake/tomls/Cargo.sgx_untrusted_app.toml | 7 +--
ipc/src/protos/command.rs | 9 +--
ipc/src/protos/ecall.rs | 27 +--------
tests/README.md | 5 ++
.../functional_tests}/app/Cargo.toml | 2 +-
.../functional_tests}/app/build.rs | 0
.../functional_tests}/app/src/main.rs | 9 +--
.../functional_tests}/enclave/Cargo.toml | 4 +-
.../functional_tests}/enclave/Enclave.config.xml | 0
.../functional_tests}/enclave/src/lib.rs | 14 ++---
.../enclave/src/teaclave_authentication_service.rs | 2 +-
.../enclave/src/teaclave_database_service.rs | 30 +++++-----
.../integration_tests}/app/Cargo.toml | 4 +-
.../integration_tests}/app/build.rs | 0
.../integration_tests}/app/src/main.rs | 9 +--
.../integration_tests}/enclave/Cargo.toml | 8 ++-
.../integration_tests}/enclave/Enclave.config.xml | 0
.../integration_tests}/enclave/src/lib.rs | 16 +++---
.../enclave/src/protected_fs_rs.rs | 0
.../enclave/src/rusty_leveldb_sgx.rs | 0
{testsuite => tests}/test.py | 0
.../unit_tests}/app/Cargo.toml | 2 +-
.../unit_tests}/app/build.rs | 0
.../unit_tests}/app/src/main.rs | 9 +--
.../unit_tests}/enclave/Cargo.toml | 4 +-
.../unit_tests}/enclave/Enclave.config.xml | 0
.../unit_tests}/enclave/src/lib.rs | 16 +++---
testsuite/enclave_unit_test/app/build.rs | 51 -----------------
testsuite/enclave_unit_test/app/src/main.rs | 46 ---------------
.../enclave_unit_test/enclave/Enclave.config.xml | 12 ----
testsuite/enclave_unit_test/enclave/src/lib.rs | 66 ----------------------
testsuite/leveldb_tests/enclave/Cargo.toml | 48 ----------------
testsuite/protected_fs_tests/app/Cargo.toml | 19 -------
36 files changed, 93 insertions(+), 354 deletions(-)
diff --git a/cmake/scripts/parse_cargo_packages.py
b/cmake/scripts/parse_cargo_packages.py
index deeef00..edbc595 100644
--- a/cmake/scripts/parse_cargo_packages.py
+++ b/cmake/scripts/parse_cargo_packages.py
@@ -59,7 +59,7 @@ def pkg_path_2_category(pkg_path):
return 'services'
elif pkg_path.startswith('examples/'):
return 'examples'
- elif pkg_path.startswith('testsuite/'):
+ elif pkg_path.startswith('tests/'):
return 'tests'
elif pkg_path == 'cli':
return 'bin'
diff --git a/cmake/scripts/test.sh b/cmake/scripts/test.sh
index 3a0c238..5d2c8c2 100755
--- a/cmake/scripts/test.sh
+++ b/cmake/scripts/test.sh
@@ -1,5 +1,6 @@
#!/bin/bash
set -e
+
if [ -z "${MESATEE_PROJECT_ROOT}" ] \
|| [ -z "${SGX_SDK}" ] || [ -z "${SGX_MODE}" ]; then
echo "Please set MESATEE_PROJECT_ROOT, SGX_SDK and SGX_MODE";
@@ -24,14 +25,22 @@ echo_title() {
pushd ${MESATEE_TEST_INSTALL_DIR}
echo_title "encalve unit tests"
-./teaclave_enclave_unit_test
+./teaclave_unit_tests
-echo_title "leveldb tests"
-./teaclave_leveldb_tests
+echo_title "integration tests"
+./teaclave_integration_tests
-echo_title "protect_fs tests"
-./teaclave_protected_fs_tests
+echo_title "protect_fs_rs tests (untrusted)"
cargo test --manifest-path
${MESATEE_PROJECT_ROOT}/common/protected_fs_rs/Cargo.toml \
--target-dir ${MESATEE_TARGET_DIR}/untrusted
+echo_title "functional tests"
+trap 'kill $(jobs -p)' EXIT
+pushd ${MESATEE_SERVICE_INSTALL_DIR}
+./teaclave_authentication_service &
+./teaclave_database_service &
+popd
+sleep 3
+./teaclave_functional_tests
+
popd
diff --git a/cmake/tomls/Cargo.sgx_trusted_lib.toml
b/cmake/tomls/Cargo.sgx_trusted_lib.toml
index efb7da6..d464b4e 100644
--- a/cmake/tomls/Cargo.sgx_trusted_lib.toml
+++ b/cmake/tomls/Cargo.sgx_trusted_lib.toml
@@ -3,10 +3,9 @@
members = [
"services/authentication/enclave",
"services/database/enclave",
- "testsuite/enclave_unit_test/enclave",
- "testsuite/service_functional_test/enclave",
- "testsuite/leveldb_tests/enclave",
- "testsuite/protected_fs_tests/enclave",
+ "tests/unit_tests/enclave",
+ "tests/functional_tests/enclave",
+ "tests/integration_tests/enclave",
]
exclude = [
diff --git a/cmake/tomls/Cargo.sgx_untrusted_app.toml
b/cmake/tomls/Cargo.sgx_untrusted_app.toml
index 41ab8d2..033ec34 100644
--- a/cmake/tomls/Cargo.sgx_untrusted_app.toml
+++ b/cmake/tomls/Cargo.sgx_untrusted_app.toml
@@ -3,10 +3,9 @@
members = [
"services/authentication/app",
"services/database/app",
- "testsuite/enclave_unit_test/app",
- "testsuite/service_functional_test/app",
- "testsuite/leveldb_tests/app",
- "testsuite/protected_fs_tests/app",
+ "tests/unit_tests/app",
+ "tests/functional_tests/app",
+ "tests/integration_tests/app",
]
exclude = [
diff --git a/ipc/src/protos/command.rs b/ipc/src/protos/command.rs
index fc55967..51bcdc1 100644
--- a/ipc/src/protos/command.rs
+++ b/ipc/src/protos/command.rs
@@ -20,9 +20,8 @@ pub enum ECallCommand {
StartService,
InitEnclave,
FinalizeEnclave,
- RunEnclaveUnitTest,
+ RunTest,
ServeConnection,
- RunFunctionalTest,
Unimplemented,
}
@@ -33,9 +32,8 @@ impl From<u32> for ECallCommand {
0x0000_1000 => ECallCommand::StartService,
0x0000_1001 => ECallCommand::InitEnclave,
0x0000_1002 => ECallCommand::FinalizeEnclave,
- 0x0000_1003 => ECallCommand::RunEnclaveUnitTest,
+ 0x0000_1003 => ECallCommand::RunTest,
0x0000_1004 => ECallCommand::ServeConnection,
- 0x0000_1005 => ECallCommand::RunFunctionalTest,
_ => ECallCommand::Unimplemented,
}
}
@@ -48,9 +46,8 @@ impl Into<u32> for ECallCommand {
ECallCommand::StartService => 0x0000_1000,
ECallCommand::InitEnclave => 0x0000_1001,
ECallCommand::FinalizeEnclave => 0x0000_1002,
- ECallCommand::RunEnclaveUnitTest => 0x0000_1003,
+ ECallCommand::RunTest => 0x0000_1003,
ECallCommand::ServeConnection => 0x0000_1004,
- ECallCommand::RunFunctionalTest => 0x0000_1005,
ECallCommand::Unimplemented => 0xffff_ffff,
}
}
diff --git a/ipc/src/protos/ecall.rs b/ipc/src/protos/ecall.rs
index 785f3b8..fa491ca 100644
--- a/ipc/src/protos/ecall.rs
+++ b/ipc/src/protos/ecall.rs
@@ -15,19 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-// Insert std prelude in the top for the sgx feature
-
-// use cfg_if::cfg_if;
use serde_derive::{Deserialize, Serialize};
-
-// Use target specific definitions here
-// cfg_if! {
-// if #[cfg(feature = "mesalock_sgx")] {
-// use sgx_types::c_int;
-// } else {
use std::os::raw::c_int;
-// }
-// }
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
pub struct StartServiceInput {
@@ -50,19 +39,13 @@ pub struct FinalizeEnclaveInput;
pub struct FinalizeEnclaveOutput;
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
-pub struct RunEnclaveUnitTestInput;
+pub struct RunTestInput;
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
-pub struct RunEnclaveUnitTestOutput {
+pub struct RunTestOutput {
pub failed_count: usize,
}
-#[derive(Clone, Serialize, Deserialize, Debug, Default)]
-pub struct RunFunctionalTestInput;
-
-#[derive(Clone, Serialize, Deserialize, Debug, Default)]
-pub struct RunFunctionalTestOutput;
-
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct ServeConnectionInput {
pub socket_fd: c_int,
@@ -72,12 +55,6 @@ pub struct ServeConnectionInput {
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
pub struct ServeConnectionOutput;
-impl RunEnclaveUnitTestOutput {
- pub fn new(failed_count: usize) -> RunEnclaveUnitTestOutput {
- RunEnclaveUnitTestOutput { failed_count }
- }
-}
-
impl ServeConnectionInput {
pub fn new(socket_fd: c_int, port: u16) -> ServeConnectionInput {
ServeConnectionInput { socket_fd, port }
diff --git a/tests/README.md b/tests/README.md
new file mode 100644
index 0000000..93f483b
--- /dev/null
+++ b/tests/README.md
@@ -0,0 +1,5 @@
+# Tests in Teaclave
+
+```
+make run-test
+```
diff --git a/testsuite/enclave_unit_test/app/Cargo.toml
b/tests/functional_tests/app/Cargo.toml
similarity index 93%
rename from testsuite/enclave_unit_test/app/Cargo.toml
rename to tests/functional_tests/app/Cargo.toml
index 0e4c8ce..df64f86 100644
--- a/testsuite/enclave_unit_test/app/Cargo.toml
+++ b/tests/functional_tests/app/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "teaclave_enclave_unit_test"
+name = "teaclave_functional_tests"
version = "0.1.0"
authors = ["Teaclave Contributors <[email protected]>"]
description = "Enclave test driver"
diff --git a/testsuite/service_functional_test/app/build.rs
b/tests/functional_tests/app/build.rs
similarity index 100%
rename from testsuite/service_functional_test/app/build.rs
rename to tests/functional_tests/app/build.rs
diff --git a/testsuite/protected_fs_tests/app/src/main.rs
b/tests/functional_tests/app/src/main.rs
similarity index 83%
rename from testsuite/protected_fs_tests/app/src/main.rs
rename to tests/functional_tests/app/src/main.rs
index 5f4fb60..a3d4909 100644
--- a/testsuite/protected_fs_tests/app/src/main.rs
+++ b/tests/functional_tests/app/src/main.rs
@@ -18,7 +18,7 @@
use anyhow;
use std::sync::Arc;
use teaclave_binder::TeeBinder;
-use teaclave_ipc::protos::ecall::{RunFunctionalTestInput,
RunFunctionalTestOutput};
+use teaclave_ipc::protos::ecall::{RunTestInput, RunTestOutput};
use teaclave_ipc::protos::ECallCommand;
use teaclave_service_app_utils::ServiceEnclaveBuilder;
@@ -30,11 +30,8 @@ fn main() -> anyhow::Result<()> {
}
fn start_enclave_unit_test_driver(tee: Arc<TeeBinder>) -> anyhow::Result<()> {
- let cmd = ECallCommand::RunFunctionalTest;
- let _ = tee.invoke::<RunFunctionalTestInput, RunFunctionalTestOutput>(
- cmd.into(),
- RunFunctionalTestInput,
- );
+ let cmd = ECallCommand::RunTest;
+ let _ = tee.invoke::<RunTestInput, RunTestOutput>(cmd.into(),
RunTestInput);
Ok(())
}
diff --git a/testsuite/service_functional_test/enclave/Cargo.toml
b/tests/functional_tests/enclave/Cargo.toml
similarity index 93%
rename from testsuite/service_functional_test/enclave/Cargo.toml
rename to tests/functional_tests/enclave/Cargo.toml
index c4763af..b494b2f 100644
--- a/testsuite/service_functional_test/enclave/Cargo.toml
+++ b/tests/functional_tests/enclave/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "teaclave_service_functional_test_enclave"
+name = "teaclave_functional_tests_enclave"
version = "0.1.0"
authors = ["Teaclave Contributors <[email protected]>"]
description = "Service Functional Test"
@@ -7,7 +7,7 @@ license = "Apache-2.0"
edition = "2018"
[lib]
-name = "teaclave_service_functional_test_enclave"
+name = "teaclave_functional_tests_enclave"
crate-type = ["staticlib"]
[features]
diff --git a/testsuite/service_functional_test/enclave/Enclave.config.xml
b/tests/functional_tests/enclave/Enclave.config.xml
similarity index 100%
rename from testsuite/service_functional_test/enclave/Enclave.config.xml
rename to tests/functional_tests/enclave/Enclave.config.xml
diff --git a/testsuite/service_functional_test/enclave/src/lib.rs
b/tests/functional_tests/enclave/src/lib.rs
similarity index 82%
rename from testsuite/service_functional_test/enclave/src/lib.rs
rename to tests/functional_tests/enclave/src/lib.rs
index e4b0f29..ddfaae0 100644
--- a/testsuite/service_functional_test/enclave/src/lib.rs
+++ b/tests/functional_tests/enclave/src/lib.rs
@@ -29,8 +29,8 @@ use anyhow::Result;
use teaclave_types;
use teaclave_ipc::protos::ecall::{
- FinalizeEnclaveInput, FinalizeEnclaveOutput, InitEnclaveInput,
InitEnclaveOutput,
- RunFunctionalTestInput, RunFunctionalTestOutput,
+ FinalizeEnclaveInput, FinalizeEnclaveOutput, InitEnclaveInput,
InitEnclaveOutput, RunTestInput,
+ RunTestOutput,
};
use teaclave_ipc::protos::ECallCommand;
use teaclave_ipc::{handle_ecall, register_ecall_handler};
@@ -40,10 +40,10 @@ mod teaclave_authentication_service;
mod teaclave_database_service;
#[handle_ecall]
-fn handle_run_enclave_unit_test(_args: &RunFunctionalTestInput) ->
Result<RunFunctionalTestOutput> {
- teaclave_authentication_service::run_functional_tests();
- teaclave_database_service::run_functional_tests();
- Ok(RunFunctionalTestOutput::default())
+fn handle_run_test(_args: &RunTestInput) -> Result<RunTestOutput> {
+ teaclave_authentication_service::run_tests();
+ teaclave_database_service::run_tests();
+ Ok(RunTestOutput::default())
}
#[handle_ecall]
@@ -60,7 +60,7 @@ fn handle_finalize_enclave(_args: &FinalizeEnclaveInput) ->
Result<FinalizeEncla
register_ecall_handler!(
type ECallCommand,
- (ECallCommand::RunFunctionalTest, RunFunctionalTestInput,
RunFunctionalTestOutput),
+ (ECallCommand::RunTest, RunTestInput, RunTestOutput),
(ECallCommand::InitEnclave, InitEnclaveInput, InitEnclaveOutput),
(ECallCommand::FinalizeEnclave, FinalizeEnclaveInput,
FinalizeEnclaveOutput),
);
diff --git
a/testsuite/service_functional_test/enclave/src/teaclave_authentication_service.rs
b/tests/functional_tests/enclave/src/teaclave_authentication_service.rs
similarity index 98%
rename from
testsuite/service_functional_test/enclave/src/teaclave_authentication_service.rs
rename to tests/functional_tests/enclave/src/teaclave_authentication_service.rs
index b3f46f2..8cf3d70 100644
---
a/testsuite/service_functional_test/enclave/src/teaclave_authentication_service.rs
+++ b/tests/functional_tests/enclave/src/teaclave_authentication_service.rs
@@ -8,7 +8,7 @@ use teaclave_rpc::config::SgxTrustedTlsClientConfig;
use teaclave_rpc::endpoint::Endpoint;
use teaclave_types::EnclaveInfo;
-pub fn run_functional_tests() {
+pub fn run_tests() {
rsgx_unit_tests!(
test_login_success,
test_login_fail,
diff --git
a/testsuite/service_functional_test/enclave/src/teaclave_database_service.rs
b/tests/functional_tests/enclave/src/teaclave_database_service.rs
similarity index 91%
rename from
testsuite/service_functional_test/enclave/src/teaclave_database_service.rs
rename to tests/functional_tests/enclave/src/teaclave_database_service.rs
index 1b4a91e..14483f3 100644
--- a/testsuite/service_functional_test/enclave/src/teaclave_database_service.rs
+++ b/tests/functional_tests/enclave/src/teaclave_database_service.rs
@@ -3,19 +3,19 @@ use std::prelude::v1::*;
use teaclave_proto::teaclave_database_service::*;
use teaclave_rpc::endpoint::Endpoint;
-pub fn run_functional_tests() {
+pub fn run_tests() {
rsgx_unit_tests!(
- test_get_successful,
- test_get_failed,
- test_put_successful,
- test_delete_successful,
- test_enqueue_successful,
- test_dequeue_successful,
- test_dequeue_failed,
+ test_get_success,
+ test_get_fail,
+ test_put_success,
+ test_delete_success,
+ test_enqueue_success,
+ test_dequeue_success,
+ test_dequeue_fail,
);
}
-fn test_get_successful() {
+fn test_get_success() {
let channel = Endpoint::new("localhost:7778").connect().unwrap();
let mut client = TeaclaveDatabaseClient::new(channel).unwrap();
let request = GetRequest {
@@ -27,7 +27,7 @@ fn test_get_successful() {
assert!(response_result.is_ok());
}
-fn test_get_failed() {
+fn test_get_fail() {
let channel = Endpoint::new("localhost:7778").connect().unwrap();
let mut client = TeaclaveDatabaseClient::new(channel).unwrap();
let request = GetRequest {
@@ -38,7 +38,7 @@ fn test_get_failed() {
assert!(response_result.is_err());
}
-fn test_put_successful() {
+fn test_put_success() {
let channel = Endpoint::new("localhost:7778").connect().unwrap();
let mut client = TeaclaveDatabaseClient::new(channel).unwrap();
let request = PutRequest {
@@ -60,7 +60,7 @@ fn test_put_successful() {
assert_eq!(response_result.unwrap().value, b"test_put_value");
}
-fn test_delete_successful() {
+fn test_delete_success() {
let channel = Endpoint::new("localhost:7778").connect().unwrap();
let mut client = TeaclaveDatabaseClient::new(channel).unwrap();
let request = DeleteRequest {
@@ -79,7 +79,7 @@ fn test_delete_successful() {
assert!(response_result.is_err());
}
-fn test_enqueue_successful() {
+fn test_enqueue_success() {
let channel = Endpoint::new("localhost:7778").connect().unwrap();
let mut client = TeaclaveDatabaseClient::new(channel).unwrap();
let request = EnqueueRequest {
@@ -92,7 +92,7 @@ fn test_enqueue_successful() {
assert!(response_result.is_ok());
}
-fn test_dequeue_successful() {
+fn test_dequeue_success() {
let channel = Endpoint::new("localhost:7778").connect().unwrap();
let mut client = TeaclaveDatabaseClient::new(channel).unwrap();
let request = DequeueRequest {
@@ -131,7 +131,7 @@ fn test_dequeue_successful() {
assert_eq!(response_result.unwrap().value, b"2");
}
-fn test_dequeue_failed() {
+fn test_dequeue_fail() {
let channel = Endpoint::new("localhost:7778").connect().unwrap();
let mut client = TeaclaveDatabaseClient::new(channel).unwrap();
let request = DequeueRequest {
diff --git a/testsuite/leveldb_tests/app/Cargo.toml
b/tests/integration_tests/app/Cargo.toml
similarity index 87%
rename from testsuite/leveldb_tests/app/Cargo.toml
rename to tests/integration_tests/app/Cargo.toml
index c345a2b..574ddec 100644
--- a/testsuite/leveldb_tests/app/Cargo.toml
+++ b/tests/integration_tests/app/Cargo.toml
@@ -1,8 +1,8 @@
[package]
-name = "teaclave_leveldb_tests"
+name = "teaclave_integration_tests"
version = "0.1.0"
authors = ["Teaclave Contributors <[email protected]>"]
-description = "LevelDB functional tests"
+description = "Integration tests"
license = "Apache-2.0"
build = "build.rs"
edition = "2018"
diff --git a/testsuite/protected_fs_tests/app/build.rs
b/tests/integration_tests/app/build.rs
similarity index 100%
rename from testsuite/protected_fs_tests/app/build.rs
rename to tests/integration_tests/app/build.rs
diff --git a/testsuite/leveldb_tests/app/src/main.rs
b/tests/integration_tests/app/src/main.rs
similarity index 83%
rename from testsuite/leveldb_tests/app/src/main.rs
rename to tests/integration_tests/app/src/main.rs
index 5f4fb60..a3d4909 100644
--- a/testsuite/leveldb_tests/app/src/main.rs
+++ b/tests/integration_tests/app/src/main.rs
@@ -18,7 +18,7 @@
use anyhow;
use std::sync::Arc;
use teaclave_binder::TeeBinder;
-use teaclave_ipc::protos::ecall::{RunFunctionalTestInput,
RunFunctionalTestOutput};
+use teaclave_ipc::protos::ecall::{RunTestInput, RunTestOutput};
use teaclave_ipc::protos::ECallCommand;
use teaclave_service_app_utils::ServiceEnclaveBuilder;
@@ -30,11 +30,8 @@ fn main() -> anyhow::Result<()> {
}
fn start_enclave_unit_test_driver(tee: Arc<TeeBinder>) -> anyhow::Result<()> {
- let cmd = ECallCommand::RunFunctionalTest;
- let _ = tee.invoke::<RunFunctionalTestInput, RunFunctionalTestOutput>(
- cmd.into(),
- RunFunctionalTestInput,
- );
+ let cmd = ECallCommand::RunTest;
+ let _ = tee.invoke::<RunTestInput, RunTestOutput>(cmd.into(),
RunTestInput);
Ok(())
}
diff --git a/testsuite/protected_fs_tests/enclave/Cargo.toml
b/tests/integration_tests/enclave/Cargo.toml
similarity index 85%
rename from testsuite/protected_fs_tests/enclave/Cargo.toml
rename to tests/integration_tests/enclave/Cargo.toml
index 06fdcbc..1396d75 100644
--- a/testsuite/protected_fs_tests/enclave/Cargo.toml
+++ b/tests/integration_tests/enclave/Cargo.toml
@@ -1,13 +1,13 @@
[package]
-name = "teaclave_protected_fs_tests_enclave"
+name = "teaclave_integration_tests_enclave"
version = "0.1.0"
authors = ["Teaclave Contributors <[email protected]>"]
-description = "Service Functional Test"
+description = "Integration Test"
license = "Apache-2.0"
edition = "2018"
[lib]
-name = "teaclave_protected_fs_tests_enclave"
+name = "teaclave_integration_tests_enclave"
crate-type = ["staticlib"]
[features]
@@ -21,6 +21,7 @@ mesalock_sgx = [
"teaclave_service_config/mesalock_sgx",
"teaclave_service_enclave_utils/mesalock_sgx",
"teaclave_types/mesalock_sgx",
+ "rusty-leveldb/mesalock_sgx",
"protected_fs_rs/mesalock_sgx",
]
cov = ["teaclave_service_enclave_utils/cov"]
@@ -32,6 +33,7 @@ serde = { version = "1.0.92" }
thiserror = { version = "1.0.9" }
rand = { version = "0.7.0" }
+rusty-leveldb = { path = "../../../common/rusty_leveldb_sgx", default-features
= false, optional = true }
protected_fs_rs = { path = "../../../common/protected_fs_rs",
default-features = false, optional = true }
teaclave_attestation = { path = "../../../attestation" }
diff --git a/testsuite/protected_fs_tests/enclave/Enclave.config.xml
b/tests/integration_tests/enclave/Enclave.config.xml
similarity index 100%
rename from testsuite/protected_fs_tests/enclave/Enclave.config.xml
rename to tests/integration_tests/enclave/Enclave.config.xml
diff --git a/testsuite/leveldb_tests/enclave/src/lib.rs
b/tests/integration_tests/enclave/src/lib.rs
similarity index 83%
rename from testsuite/leveldb_tests/enclave/src/lib.rs
rename to tests/integration_tests/enclave/src/lib.rs
index 781d539..d46f635 100644
--- a/testsuite/leveldb_tests/enclave/src/lib.rs
+++ b/tests/integration_tests/enclave/src/lib.rs
@@ -28,19 +28,21 @@ use anyhow::Result;
use teaclave_types;
use teaclave_ipc::protos::ecall::{
- FinalizeEnclaveInput, FinalizeEnclaveOutput, InitEnclaveInput,
InitEnclaveOutput,
- RunFunctionalTestInput, RunFunctionalTestOutput,
+ FinalizeEnclaveInput, FinalizeEnclaveOutput, InitEnclaveInput,
InitEnclaveOutput, RunTestInput,
+ RunTestOutput,
};
use teaclave_ipc::protos::ECallCommand;
use teaclave_ipc::{handle_ecall, register_ecall_handler};
use teaclave_service_enclave_utils::ServiceEnclave;
-mod leveldb_tests;
+mod protected_fs_rs;
+mod rusty_leveldb_sgx;
#[handle_ecall]
-fn handle_run_functional_test(_args: &RunFunctionalTestInput) ->
Result<RunFunctionalTestOutput> {
- leveldb_tests::run_tests();
- Ok(RunFunctionalTestOutput::default())
+fn handle_run_test(_args: &RunTestInput) -> Result<RunTestOutput> {
+ rusty_leveldb_sgx::run_tests();
+ protected_fs_rs::run_tests();
+ Ok(RunTestOutput::default())
}
#[handle_ecall]
@@ -57,7 +59,7 @@ fn handle_finalize_enclave(_args: &FinalizeEnclaveInput) ->
Result<FinalizeEncla
register_ecall_handler!(
type ECallCommand,
- (ECallCommand::RunFunctionalTest, RunFunctionalTestInput,
RunFunctionalTestOutput),
+ (ECallCommand::RunTest, RunTestInput, RunTestOutput),
(ECallCommand::InitEnclave, InitEnclaveInput, InitEnclaveOutput),
(ECallCommand::FinalizeEnclave, FinalizeEnclaveInput,
FinalizeEnclaveOutput),
);
diff --git a/testsuite/protected_fs_tests/enclave/src/protected_fs_tests.rs
b/tests/integration_tests/enclave/src/protected_fs_rs.rs
similarity index 100%
rename from testsuite/protected_fs_tests/enclave/src/protected_fs_tests.rs
rename to tests/integration_tests/enclave/src/protected_fs_rs.rs
diff --git a/testsuite/leveldb_tests/enclave/src/leveldb_tests.rs
b/tests/integration_tests/enclave/src/rusty_leveldb_sgx.rs
similarity index 100%
rename from testsuite/leveldb_tests/enclave/src/leveldb_tests.rs
rename to tests/integration_tests/enclave/src/rusty_leveldb_sgx.rs
diff --git a/testsuite/test.py b/tests/test.py
similarity index 100%
rename from testsuite/test.py
rename to tests/test.py
diff --git a/testsuite/service_functional_test/app/Cargo.toml
b/tests/unit_tests/app/Cargo.toml
similarity index 92%
rename from testsuite/service_functional_test/app/Cargo.toml
rename to tests/unit_tests/app/Cargo.toml
index 0b0936c..5fb72d9 100644
--- a/testsuite/service_functional_test/app/Cargo.toml
+++ b/tests/unit_tests/app/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "teaclave_service_functional_test"
+name = "teaclave_unit_tests"
version = "0.1.0"
authors = ["Teaclave Contributors <[email protected]>"]
description = "Enclave test driver"
diff --git a/testsuite/leveldb_tests/app/build.rs
b/tests/unit_tests/app/build.rs
similarity index 100%
rename from testsuite/leveldb_tests/app/build.rs
rename to tests/unit_tests/app/build.rs
diff --git a/testsuite/service_functional_test/app/src/main.rs
b/tests/unit_tests/app/src/main.rs
similarity index 83%
rename from testsuite/service_functional_test/app/src/main.rs
rename to tests/unit_tests/app/src/main.rs
index 5f4fb60..a3d4909 100644
--- a/testsuite/service_functional_test/app/src/main.rs
+++ b/tests/unit_tests/app/src/main.rs
@@ -18,7 +18,7 @@
use anyhow;
use std::sync::Arc;
use teaclave_binder::TeeBinder;
-use teaclave_ipc::protos::ecall::{RunFunctionalTestInput,
RunFunctionalTestOutput};
+use teaclave_ipc::protos::ecall::{RunTestInput, RunTestOutput};
use teaclave_ipc::protos::ECallCommand;
use teaclave_service_app_utils::ServiceEnclaveBuilder;
@@ -30,11 +30,8 @@ fn main() -> anyhow::Result<()> {
}
fn start_enclave_unit_test_driver(tee: Arc<TeeBinder>) -> anyhow::Result<()> {
- let cmd = ECallCommand::RunFunctionalTest;
- let _ = tee.invoke::<RunFunctionalTestInput, RunFunctionalTestOutput>(
- cmd.into(),
- RunFunctionalTestInput,
- );
+ let cmd = ECallCommand::RunTest;
+ let _ = tee.invoke::<RunTestInput, RunTestOutput>(cmd.into(),
RunTestInput);
Ok(())
}
diff --git a/testsuite/enclave_unit_test/enclave/Cargo.toml
b/tests/unit_tests/enclave/Cargo.toml
similarity index 95%
rename from testsuite/enclave_unit_test/enclave/Cargo.toml
rename to tests/unit_tests/enclave/Cargo.toml
index 268a396..71e7270 100644
--- a/testsuite/enclave_unit_test/enclave/Cargo.toml
+++ b/tests/unit_tests/enclave/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "teaclave_enclave_unit_test_enclave"
+name = "teaclave_unit_tests_enclave"
version = "0.1.0"
authors = ["Teaclave Contributors <[email protected]>"]
description = "Enclave Unit Test"
@@ -7,7 +7,7 @@ license = "Apache-2.0"
edition = "2018"
[lib]
-name = "teaclave_enclave_unit_test_enclave"
+name = "teaclave_unit_tests_enclave"
crate-type = ["staticlib"]
[features]
diff --git a/testsuite/leveldb_tests/enclave/Enclave.config.xml
b/tests/unit_tests/enclave/Enclave.config.xml
similarity index 100%
rename from testsuite/leveldb_tests/enclave/Enclave.config.xml
rename to tests/unit_tests/enclave/Enclave.config.xml
diff --git a/testsuite/protected_fs_tests/enclave/src/lib.rs
b/tests/unit_tests/enclave/src/lib.rs
similarity index 82%
rename from testsuite/protected_fs_tests/enclave/src/lib.rs
rename to tests/unit_tests/enclave/src/lib.rs
index 07c71a0..c7493ac 100644
--- a/testsuite/protected_fs_tests/enclave/src/lib.rs
+++ b/tests/unit_tests/enclave/src/lib.rs
@@ -27,20 +27,20 @@ use std::prelude::v1::*;
use anyhow::Result;
use teaclave_types;
+use teaclave_authentication_service_enclave;
use teaclave_ipc::protos::ecall::{
- FinalizeEnclaveInput, FinalizeEnclaveOutput, InitEnclaveInput,
InitEnclaveOutput,
- RunFunctionalTestInput, RunFunctionalTestOutput,
+ FinalizeEnclaveInput, FinalizeEnclaveOutput, InitEnclaveInput,
InitEnclaveOutput, RunTestInput,
+ RunTestOutput,
};
use teaclave_ipc::protos::ECallCommand;
use teaclave_ipc::{handle_ecall, register_ecall_handler};
use teaclave_service_enclave_utils::ServiceEnclave;
-mod protected_fs_tests;
-
#[handle_ecall]
-fn handle_run_functional_test(_args: &RunFunctionalTestInput) ->
Result<RunFunctionalTestOutput> {
- protected_fs_tests::run_tests();
- Ok(RunFunctionalTestOutput::default())
+fn handle_run_test(_args: &RunTestInput) -> Result<RunTestOutput> {
+ teaclave_authentication_service_enclave::tests::run_tests();
+ teaclave_database_service_enclave::tests::run_tests();
+ Ok(RunTestOutput::default())
}
#[handle_ecall]
@@ -57,7 +57,7 @@ fn handle_finalize_enclave(_args: &FinalizeEnclaveInput) ->
Result<FinalizeEncla
register_ecall_handler!(
type ECallCommand,
- (ECallCommand::RunFunctionalTest, RunFunctionalTestInput,
RunFunctionalTestOutput),
+ (ECallCommand::RunTest, RunTestInput, RunTestOutput),
(ECallCommand::InitEnclave, InitEnclaveInput, InitEnclaveOutput),
(ECallCommand::FinalizeEnclave, FinalizeEnclaveInput,
FinalizeEnclaveOutput),
);
diff --git a/testsuite/enclave_unit_test/app/build.rs
b/testsuite/enclave_unit_test/app/build.rs
deleted file mode 100644
index b92afb5..0000000
--- a/testsuite/enclave_unit_test/app/build.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use std::env;
-use std::path::PathBuf;
-
-fn choose_sgx_dylib(is_sim: bool) {
- if is_sim {
- println!("cargo:rustc-link-lib=dylib=sgx_urts_sim");
- println!("cargo:rustc-link-lib=dylib=sgx_uae_service_sim");
- } else {
- println!("cargo:rustc-link-lib=dylib=sgx_urts");
- println!("cargo:rustc-link-lib=dylib=sgx_uae_service");
- }
-}
-
-fn main() {
- let sdk_dir = env::var("SGX_SDK").unwrap_or("/opt/intel/sgxsdk".into());
- println!("cargo:rustc-link-search=native={}/lib64", sdk_dir);
-
- let out_path = env::var_os("ENCLAVE_OUT_DIR").unwrap_or("out".into());
- let out_dir = &PathBuf::from(out_path);
-
- println!("cargo:rustc-link-search=native={}", out_dir.display());
- println!("cargo:rustc-link-lib=static=Enclave_u");
-
- let is_sim = match env::var("SGX_MODE") {
- Ok(ref v) if v == "SW" => true,
- Ok(ref v) if v == "HW" => false,
- Err(env::VarError::NotPresent) => false,
- _ => {
- panic!("Stop build process, wrong SGX_MODE env provided.");
- }
- };
-
- choose_sgx_dylib(is_sim);
-}
diff --git a/testsuite/enclave_unit_test/app/src/main.rs
b/testsuite/enclave_unit_test/app/src/main.rs
deleted file mode 100644
index ae5fb6b..0000000
--- a/testsuite/enclave_unit_test/app/src/main.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use anyhow;
-use std::sync::Arc;
-use teaclave_binder::TeeBinder;
-use teaclave_ipc::protos::ecall::{RunEnclaveUnitTestInput,
RunEnclaveUnitTestOutput};
-use teaclave_ipc::protos::ECallCommand;
-use teaclave_service_app_utils::ServiceEnclaveBuilder;
-
-fn main() -> anyhow::Result<()> {
- let tee = ServiceEnclaveBuilder::init_tee_binder(env!("CARGO_PKG_NAME"))?;
- run(tee)?;
-
- Ok(())
-}
-
-fn start_enclave_unit_test_driver(tee: Arc<TeeBinder>) -> anyhow::Result<()> {
- let cmd = ECallCommand::RunEnclaveUnitTest;
- let _ = tee.invoke::<RunEnclaveUnitTestInput, RunEnclaveUnitTestOutput>(
- cmd.into(),
- RunEnclaveUnitTestInput,
- );
-
- Ok(())
-}
-
-fn run(tee: Arc<TeeBinder>) -> anyhow::Result<()> {
- start_enclave_unit_test_driver(tee)?;
-
- Ok(())
-}
diff --git a/testsuite/enclave_unit_test/enclave/Enclave.config.xml
b/testsuite/enclave_unit_test/enclave/Enclave.config.xml
deleted file mode 100644
index 705edcd..0000000
--- a/testsuite/enclave_unit_test/enclave/Enclave.config.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<!-- Please refer to User's Guide for the explanation of each field -->
-<EnclaveConfiguration>
- <ProdID>0</ProdID>
- <ISVSVN>0</ISVSVN>
- <StackMaxSize>0x200000</StackMaxSize>
- <HeapMaxSize>0x1000000</HeapMaxSize>
- <TCSNum>22</TCSNum>
- <TCSPolicy>0</TCSPolicy>
- <DisableDebug>0</DisableDebug>
- <MiscSelect>0</MiscSelect>
- <MiscMask>0xFFFFFFFF</MiscMask>
-</EnclaveConfiguration>
diff --git a/testsuite/enclave_unit_test/enclave/src/lib.rs
b/testsuite/enclave_unit_test/enclave/src/lib.rs
deleted file mode 100644
index 14f5274..0000000
--- a/testsuite/enclave_unit_test/enclave/src/lib.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#![cfg_attr(feature = "mesalock_sgx", no_std)]
-#[cfg(feature = "mesalock_sgx")]
-extern crate sgx_tstd as std;
-
-#[macro_use]
-extern crate log;
-
-use std::prelude::v1::*;
-
-use anyhow::Result;
-use teaclave_types;
-
-use teaclave_authentication_service_enclave;
-use teaclave_ipc::protos::ecall::{
- FinalizeEnclaveInput, FinalizeEnclaveOutput, InitEnclaveInput,
InitEnclaveOutput,
- RunEnclaveUnitTestInput, RunEnclaveUnitTestOutput,
-};
-use teaclave_ipc::protos::ECallCommand;
-use teaclave_ipc::{handle_ecall, register_ecall_handler};
-use teaclave_service_enclave_utils::ServiceEnclave;
-
-#[handle_ecall]
-fn handle_run_enclave_unit_test(
- _args: &RunEnclaveUnitTestInput,
-) -> Result<RunEnclaveUnitTestOutput> {
- let mut failed_count = 0;
- failed_count +=
teaclave_authentication_service_enclave::tests::run_tests();
- failed_count += teaclave_database_service_enclave::tests::run_tests();
- Ok(RunEnclaveUnitTestOutput { failed_count })
-}
-
-#[handle_ecall]
-fn handle_init_enclave(_args: &InitEnclaveInput) -> Result<InitEnclaveOutput> {
- ServiceEnclave::init(env!("CARGO_PKG_NAME"))?;
- Ok(InitEnclaveOutput::default())
-}
-
-#[handle_ecall]
-fn handle_finalize_enclave(_args: &FinalizeEnclaveInput) ->
Result<FinalizeEnclaveOutput> {
- ServiceEnclave::finalize()?;
- Ok(FinalizeEnclaveOutput::default())
-}
-
-register_ecall_handler!(
- type ECallCommand,
- (ECallCommand::RunEnclaveUnitTest, RunEnclaveUnitTestInput,
RunEnclaveUnitTestOutput),
- (ECallCommand::InitEnclave, InitEnclaveInput, InitEnclaveOutput),
- (ECallCommand::FinalizeEnclave, FinalizeEnclaveInput,
FinalizeEnclaveOutput),
-);
diff --git a/testsuite/leveldb_tests/enclave/Cargo.toml
b/testsuite/leveldb_tests/enclave/Cargo.toml
deleted file mode 100644
index f7c273a..0000000
--- a/testsuite/leveldb_tests/enclave/Cargo.toml
+++ /dev/null
@@ -1,48 +0,0 @@
-[package]
-name = "teaclave_leveldb_tests_enclave"
-version = "0.1.0"
-authors = ["Teaclave Contributors <[email protected]>"]
-description = "Service Functional Test"
-license = "Apache-2.0"
-edition = "2018"
-
-[lib]
-name = "teaclave_leveldb_tests_enclave"
-crate-type = ["staticlib"]
-
-[features]
-default = []
-mesalock_sgx = [
- "sgx_tstd",
- "teaclave_attestation/mesalock_sgx",
- "teaclave_proto/mesalock_sgx",
- "teaclave_ipc/mesalock_sgx",
- "teaclave_rpc/mesalock_sgx",
- "teaclave_service_config/mesalock_sgx",
- "teaclave_service_enclave_utils/mesalock_sgx",
- "teaclave_types/mesalock_sgx",
- "rusty-leveldb/mesalock_sgx",
-]
-cov = ["teaclave_service_enclave_utils/cov"]
-
-[dependencies]
-log = { version = "0.4.6" }
-anyhow = { version = "1.0.26" }
-serde = { version = "1.0.92" }
-thiserror = { version = "1.0.9" }
-rand = { version = "0.7.0" }
-
-rusty-leveldb = { path = "../../../common/rusty_leveldb_sgx", default-features
= false, optional = true }
-
-teaclave_attestation = { path = "../../../attestation" }
-teaclave_config = { path = "../../../config" }
-teaclave_ipc = { path = "../../../ipc" }
-teaclave_rpc = { path = "../../../rpc" }
-teaclave_service_config = { path = "../../../utils/service_config" }
-teaclave_service_enclave_utils = { path =
"../../../utils/service_enclave_utils" }
-teaclave_types = { path = "../../../types" }
-teaclave_proto = { path = "../../../services/proto" }
-
-sgx_tstd = { version = "1.1.0", features = ["net", "thread",
"backtrace"], optional = true }
-sgx_tunittest = { version = "1.1.0" }
-sgx_types = { version = "1.1.0" }
diff --git a/testsuite/protected_fs_tests/app/Cargo.toml
b/testsuite/protected_fs_tests/app/Cargo.toml
deleted file mode 100644
index 7dba439..0000000
--- a/testsuite/protected_fs_tests/app/Cargo.toml
+++ /dev/null
@@ -1,19 +0,0 @@
-[package]
-name = "teaclave_protected_fs_tests"
-version = "0.1.0"
-authors = ["Teaclave Contributors <[email protected]>"]
-description = "Protected FS functional tests"
-license = "Apache-2.0"
-build = "build.rs"
-edition = "2018"
-
-[dependencies]
-log = { version = "0.4.6" }
-env_logger = { version = "0.7.1" }
-anyhow = { version = "1.0.26" }
-
-teaclave_ipc = { path = "../../../ipc" }
-teaclave_service_app_utils = { path = "../../../utils/service_app_utils" }
-teaclave_binder = { path = "../../../binder" }
-
-sgx_types = { version = "1.1.0" }
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]