This is an automated email from the ASF dual-hosted git repository.

dingyu pushed a commit to branch v1.1.1-testing
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-sgx-sdk.git


The following commit(s) were added to refs/heads/v1.1.1-testing by this push:
     new 783f04c  Fix unit tests
783f04c is described below

commit 783f04c002e243d1022c5af8a982f9c2a7138f32
Author: Yu Ding <[email protected]>
AuthorDate: Tue Mar 17 21:55:14 2020 -0700

    Fix unit tests
---
 samplecode/unit-test/enclave/Cargo.toml            |  7 +-
 samplecode/unit-test/enclave/src/lib.rs            |  8 ++-
 samplecode/unit-test/enclave/src/test_alignbox.rs  | 80 ++++++++++-----------
 .../unit-test/enclave/src/test_alignstruct.rs      | 82 ++++++++++++++++++++++
 samplecode/unit-test/enclave/src/test_rts.rs       |  2 +-
 5 files changed, 133 insertions(+), 46 deletions(-)

diff --git a/samplecode/unit-test/enclave/Cargo.toml 
b/samplecode/unit-test/enclave/Cargo.toml
index 21ce279..0eddbb4 100644
--- a/samplecode/unit-test/enclave/Cargo.toml
+++ b/samplecode/unit-test/enclave/Cargo.toml
@@ -19,14 +19,16 @@ sgx_trts = { git = 
"https://github.com/apache/teaclave-sgx-sdk.git"; }
 sgx_rand = { git = "https://github.com/apache/teaclave-sgx-sdk.git"; }
 sgx_tseal = { git = "https://github.com/apache/teaclave-sgx-sdk.git"; }
 sgx_serialize = { git = "https://github.com/apache/teaclave-sgx-sdk.git"; }
-sgx_tse= { git = "https://github.com/apache/teaclave-sgx-sdk.git"; }
+sgx_alloc = { git = "https://github.com/apache/teaclave-sgx-sdk.git"; }
 
 [dependencies]
 sgx_serialize_derive = { git = 
"https://github.com/apache/teaclave-sgx-sdk.git"; }
 rand = { version = "0.5.5", default-features = false }
 memoffset = "0.5"
+sgx_align_struct_attribute = { git = 
"https://github.com/apache/teaclave-sgx-sdk.git"; }
 
 [patch.'https://github.com/apache/teaclave-sgx-sdk.git']
+sgx_align_struct_attribute = { path = "../../../sgx_align_struct_attribute" }
 sgx_alloc = { path = "../../../sgx_alloc" }
 sgx_backtrace = { path = "../../../sgx_backtrace" }
 sgx_backtrace_sys = { path = "../../../sgx_backtrace_sys" }
@@ -35,6 +37,7 @@ sgx_cov = { path = "../../../sgx_cov" }
 sgx_crypto_helper = { path = "../../../sgx_crypto_helper" }
 sgx_demangle = { path = "../../../sgx_demangle" }
 sgx_libc = { path = "../../../sgx_libc" }
+sgx_no_tstd = { path = "../../../sgx_no_tstd" }
 sgx_rand = { path = "../../../sgx_rand" }
 sgx_rand_derive = { path = "../../../sgx_rand_derive" }
 sgx_serialize = { path = "../../../sgx_serialize" }
@@ -53,4 +56,4 @@ sgx_tunittest = { path = "../../../sgx_tunittest" }
 sgx_types = { path = "../../../sgx_types" }
 #sgx_ucrypto = { path = "../../../sgx_ucrypto" }
 sgx_unwind = { path = "../../../sgx_unwind" }
-#sgx_urts = { path = "../../../sgx_urts" }
+#sgx_urts = { path = "../../../sgx_urts" }
\ No newline at end of file
diff --git a/samplecode/unit-test/enclave/src/lib.rs 
b/samplecode/unit-test/enclave/src/lib.rs
index c04cb4d..50ca3d4 100644
--- a/samplecode/unit-test/enclave/src/lib.rs
+++ b/samplecode/unit-test/enclave/src/lib.rs
@@ -36,12 +36,11 @@ extern crate sgx_tunittest;
 extern crate sgx_trts;
 extern crate sgx_rand;
 extern crate sgx_tseal;
+extern crate sgx_alloc;
+extern crate sgx_align_struct_attribute;
 extern crate rand;
-
 #[macro_use]
 extern crate memoffset;
-extern crate sgx_tse;
-
 extern crate sgx_serialize;
 pub use sgx_serialize::*;
 #[macro_use]
@@ -101,6 +100,9 @@ use test_mpsc::*;
 mod test_alignbox;
 use test_alignbox::*;
 
+mod test_alignstruct;
+
+
 #[no_mangle]
 pub extern "C"
 fn test_main_entrance() -> size_t {
diff --git a/samplecode/unit-test/enclave/src/test_alignbox.rs 
b/samplecode/unit-test/enclave/src/test_alignbox.rs
index 9fe59e7..f9431c4 100644
--- a/samplecode/unit-test/enclave/src/test_alignbox.rs
+++ b/samplecode/unit-test/enclave/src/test_alignbox.rs
@@ -16,7 +16,7 @@
 // under the License..
 
 use std::mem;
-use sgx_tse::alignbox::*;
+use sgx_alloc::alignbox::*;
 use sgx_types::*;
 
 impl_struct! {
@@ -64,22 +64,22 @@ impl_struct! {
     }
     //no align
     {
-        let str_slice: &[align_req_t] = &[];
+        let str_slice: &[AlignReq] = &[];
         let aligned_box: Option<AlignBox<user_struct>> = 
AlignBox::<user_struct>::new_with_req(1, &str_slice);
         assert!(aligned_box.is_none());
     }
     //align
     {
-        let str_slice: &[align_req_t] = &[
-            align_req_t {
+        let str_slice: &[AlignReq] = &[
+            AlignReq {
                 offset:offset_of!(user_struct, a),
                 len:mem::size_of::<u8>(),
             },
-            align_req_t {
+            AlignReq {
                 offset:offset_of!(user_struct, b),
                 len:mem::size_of::<[u16; 2]>(),
             },
-            align_req_t {
+            AlignReq {
                 offset: offset_of!(user_struct, d),
                 len:mem::size_of::<[u64; 6]>(),
             }
@@ -89,16 +89,16 @@ impl_struct! {
     }
     //no align
     {
-        let str_slice: &[align_req_t] = &[
-            align_req_t {
+        let str_slice: &[AlignReq] = &[
+            AlignReq {
                 offset:offset_of!(user_struct, a),
                 len:mem::size_of::<u8>(),
             },
-            align_req_t {
+            AlignReq {
                 offset:offset_of!(user_struct, b),
                 len:mem::size_of::<[u16; 2]>(),
             },
-            align_req_t {
+            AlignReq {
                 offset: offset_of!(user_struct, d),
                 len:mem::size_of::<[u64; 6]>(),
             }
@@ -108,20 +108,20 @@ impl_struct! {
     }
     //no align
     {
-        let str_slice: &[align_req_t] = &[
-            align_req_t {
+        let str_slice: &[AlignReq] = &[
+            AlignReq {
                 offset:offset_of!(struct_align_t, key1),
                 len:mem::size_of::<sgx_key_128bit_t>(),
             },
-            align_req_t {
+            AlignReq {
                 offset: offset_of!(struct_align_t, key2),
                 len:mem::size_of::<sgx_key_128bit_t>(),
             },
-            align_req_t {
+            AlignReq {
                 offset:offset_of!(struct_align_t, key3),
                 len:mem::size_of::<sgx_key_128bit_t>(),
             },
-            align_req_t {
+            AlignReq {
                 offset: offset_of!(struct_align_t, key4),
                 len:mem::size_of::<sgx_key_128bit_t>(),
             }
@@ -131,20 +131,20 @@ impl_struct! {
     }
     //align
     {
-        let str_slice: &[align_req_t] = &[
-            align_req_t {
+        let str_slice: &[AlignReq] = &[
+            AlignReq {
                 offset:offset_of!(struct_align_t, key1),
                 len:mem::size_of::<sgx_key_128bit_t>(),
             },
-            align_req_t {
+            AlignReq {
                 offset: offset_of!(struct_align_t, key2),
                 len:mem::size_of::<sgx_key_128bit_t>(),
             },
-            align_req_t {
+            AlignReq {
                 offset:offset_of!(struct_align_t, key3),
                 len:mem::size_of::<sgx_key_128bit_t>(),
             },
-            align_req_t {
+            AlignReq {
                 offset: offset_of!(struct_align_t, key4),
                 len:mem::size_of::<sgx_key_128bit_t>(),
             }
@@ -155,20 +155,20 @@ impl_struct! {
 }
 
 pub fn test_alignbox_heap_init() {
-    let str_slice: &[align_req_t] = &[
-        align_req_t {
+    let str_slice: &[AlignReq] = &[
+        AlignReq {
             offset:offset_of!(struct_align_t, key1),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset: offset_of!(struct_align_t, key2),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset:offset_of!(struct_align_t, key3),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset: offset_of!(struct_align_t, key4),
             len:mem::size_of::<sgx_key_128bit_t>(),
         }
@@ -197,20 +197,20 @@ pub fn test_alignbox_heap_init() {
 }
 
 pub fn test_alignbox_clone() {
-    let str_slice: &[align_req_t] = &[
-        align_req_t {
+    let str_slice: &[AlignReq] = &[
+        AlignReq {
             offset:offset_of!(struct_align_t, key1),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset: offset_of!(struct_align_t, key2),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset:offset_of!(struct_align_t, key3),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset: offset_of!(struct_align_t, key4),
             len:mem::size_of::<sgx_key_128bit_t>(),
         }
@@ -230,20 +230,20 @@ pub fn test_alignbox_clone() {
 }
 
 pub fn test_alignbox_clonefrom() {
-    let str_slice: &[align_req_t] = &[
-        align_req_t {
+    let str_slice: &[AlignReq] = &[
+        AlignReq {
             offset:offset_of!(struct_align_t, key1),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset: offset_of!(struct_align_t, key2),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset:offset_of!(struct_align_t, key3),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset: offset_of!(struct_align_t, key4),
             len:mem::size_of::<sgx_key_128bit_t>(),
         }
@@ -266,20 +266,20 @@ pub fn test_alignbox_clonefrom() {
 }
 
 pub fn test_alignbox_clonefrom_no_eq_size() {
-    let str_slice: &[align_req_t] = &[
-        align_req_t {
+    let str_slice: &[AlignReq] = &[
+        AlignReq {
             offset:offset_of!(struct_align_t, key1),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset: offset_of!(struct_align_t, key2),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset:offset_of!(struct_align_t, key3),
             len:mem::size_of::<sgx_key_128bit_t>(),
         },
-        align_req_t {
+        AlignReq {
             offset: offset_of!(struct_align_t, key4),
             len:mem::size_of::<sgx_key_128bit_t>(),
         }
diff --git a/samplecode/unit-test/enclave/src/test_alignstruct.rs 
b/samplecode/unit-test/enclave/src/test_alignstruct.rs
new file mode 100644
index 0000000..6fe53f5
--- /dev/null
+++ b/samplecode/unit-test/enclave/src/test_alignstruct.rs
@@ -0,0 +1,82 @@
+// 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 sgx_align_struct_attribute::sgx_align;
+use sgx_types::*;
+
+//no repr c
+// #[sgx_align(align=1, size=64)]
+// pub struct user_struct {
+//     pub a: u8,
+//     pub b: [u16; 2], 
+//     pub c: u32,
+//     pub d: [u64; 6],
+// }
+
+// Attributes illegal
+// #[sgx_align(align=1, size=64)]
+// #[repr(align(4))]
+// pub struct user_struct {
+//     pub a: u8,
+//     pub b: [u16; 2], 
+//     pub c: u32,
+//     pub d: [u64; 6],
+// }
+
+// //no align
+// s! {
+//     #[sgx_align(align=1, size=64)]
+//     pub struct user_struct {
+//         pub a: u8,
+//         pub b: [u16; 2], 
+//         pub c: u32,
+//         pub d: [u64; 6],
+//     }
+// }
+
+// //no align
+// s! {
+//     #[sgx_align(align=16, size=64)]
+//     pub struct user_struct {
+//         pub a: u8,
+//         pub b: [u16; 2], 
+//         pub c: u32,
+//         pub d: [u64; 6],
+//     }
+// }
+
+//align
+s! {
+    #[sgx_align(align=1, size=16)]
+    pub struct struct_align_128_t {
+        pub key: sgx_key_128bit_t,
+    }
+}
+
+// //no align
+// s! {
+//     #[sgx_align(align=32, size=64)]
+//     pub struct struct_no_align_t {
+//         pub key1: sgx_key_128bit_t,
+//         pub key2: sgx_key_128bit_t,
+//         pub key3: sgx_key_128bit_t,
+//         pub key4: sgx_key_128bit_t,
+//     }
+// }
+
+
+
diff --git a/samplecode/unit-test/enclave/src/test_rts.rs 
b/samplecode/unit-test/enclave/src/test_rts.rs
index 18fb8d5..5fb37fa 100644
--- a/samplecode/unit-test/enclave/src/test_rts.rs
+++ b/samplecode/unit-test/enclave/src/test_rts.rs
@@ -36,7 +36,7 @@ global_ctors_object! {
 }
 
 // veh
-extern "C" fn sample_exception_handler(_ : *mut sgx_exception_info_t) -> 
uint32_t {
+extern "C" fn sample_exception_handler(_ : *mut sgx_exception_info_t) -> 
int32_t {
     0
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to