You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by ms...@apache.org on 2020/03/23 16:51:48 UTC

[incubator-teaclave] branch develop updated: [common] Enable all unit_test for rusty_leveldb_sgx (#244)

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 17cbf0c  [common] Enable all unit_test for rusty_leveldb_sgx (#244)
17cbf0c is described below

commit 17cbf0c1c7690736581368d9f401bc73581e9c13
Author: Zhaofeng Chen <zf...@apache.org>
AuthorDate: Mon Mar 23 09:51:41 2020 -0700

    [common] Enable all unit_test for rusty_leveldb_sgx (#244)
---
 common/rusty_leveldb_sgx/src/block.rs         | 26 +++++++++------
 common/rusty_leveldb_sgx/src/block_builder.rs | 16 +++++----
 common/rusty_leveldb_sgx/src/blockhandle.rs   | 11 ++++--
 common/rusty_leveldb_sgx/src/cache.rs         | 24 +++++++++-----
 common/rusty_leveldb_sgx/src/cmp.rs           | 23 ++++++++-----
 common/rusty_leveldb_sgx/src/db_impl.rs       | 48 +++++++++++++++------------
 common/rusty_leveldb_sgx/src/db_iter.rs       | 30 ++++++++++-------
 common/rusty_leveldb_sgx/src/filter.rs        | 16 ++++++---
 common/rusty_leveldb_sgx/src/filter_block.rs  | 16 ++++++---
 common/rusty_leveldb_sgx/src/key_types.rs     | 13 ++++----
 common/rusty_leveldb_sgx/src/lib.rs           | 33 +++++++++++++++---
 common/rusty_leveldb_sgx/src/log.rs           | 20 +++++++----
 common/rusty_leveldb_sgx/src/mem_env.rs       | 28 ++++++++++------
 common/rusty_leveldb_sgx/src/memtable.rs      | 34 +++++++++++--------
 common/rusty_leveldb_sgx/src/merging_iter.rs  | 27 +++++++++------
 common/rusty_leveldb_sgx/src/skipmap.rs       | 39 ++++++++++++----------
 common/rusty_leveldb_sgx/src/snapshot.rs      | 11 ++++--
 common/rusty_leveldb_sgx/src/table_builder.rs | 16 +++++----
 common/rusty_leveldb_sgx/src/table_cache.rs   | 17 ++++++----
 common/rusty_leveldb_sgx/src/table_reader.rs  | 36 +++++++++++---------
 common/rusty_leveldb_sgx/src/test_util.rs     | 13 ++++----
 common/rusty_leveldb_sgx/src/types.rs         | 10 ++++--
 common/rusty_leveldb_sgx/src/version.rs       | 44 ++++++++++++------------
 common/rusty_leveldb_sgx/src/version_edit.rs  | 11 ++++--
 common/rusty_leveldb_sgx/src/version_set.rs   | 31 +++++++++--------
 common/rusty_leveldb_sgx/src/write_batch.rs   | 10 ++++--
 tests/unit/enclave/Enclave.config.xml         |  2 +-
 tests/utils/src/lib.rs                        | 11 ++++--
 28 files changed, 379 insertions(+), 237 deletions(-)

diff --git a/common/rusty_leveldb_sgx/src/block.rs b/common/rusty_leveldb_sgx/src/block.rs
index 0eca3a9..842910c 100644
--- a/common/rusty_leveldb_sgx/src/block.rs
+++ b/common/rusty_leveldb_sgx/src/block.rs
@@ -302,13 +302,25 @@ impl LdbIterator for BlockIter {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
     use crate::block_builder::BlockBuilder;
+    use crate::options;
+    use crate::test_util::{test_iterator_properties, LdbIteratorIter};
     use crate::types::{current_key_val, LdbIterator};
-    use options;
-    use test_util::{test_iterator_properties, LdbIteratorIter};
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_block_iterator_properties,
+            test_block_empty,
+            test_block_build_iterate,
+            test_block_iterate_reverse,
+            test_block_seek,
+            test_block_seek_to_last,
+        )
+    }
 
     fn get_data() -> Vec<(&'static [u8], &'static [u8])> {
         vec![
@@ -324,7 +336,6 @@ mod tests {
         ]
     }
 
-    #[test]
     fn test_block_iterator_properties() {
         let o = options::for_test();
         let mut builder = BlockBuilder::new(o.clone());
@@ -339,7 +350,6 @@ mod tests {
         test_iterator_properties(block);
     }
 
-    #[test]
     fn test_block_empty() {
         let mut o = options::for_test();
         o.block_restart_interval = 16;
@@ -356,7 +366,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_block_build_iterate() {
         let data = get_data();
         let mut builder = BlockBuilder::new(options::for_test());
@@ -379,7 +388,6 @@ mod tests {
         assert_eq!(i, data.len());
     }
 
-    #[test]
     fn test_block_iterate_reverse() {
         let mut o = options::for_test();
         o.block_restart_interval = 3;
@@ -425,7 +433,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_block_seek() {
         let mut o = options::for_test();
         o.block_restart_interval = 3;
@@ -483,7 +490,6 @@ mod tests {
         assert_eq!(current_key_val(&block), None);
     }
 
-    #[test]
     fn test_block_seek_to_last() {
         let mut o = options::for_test();
 
diff --git a/common/rusty_leveldb_sgx/src/block_builder.rs b/common/rusty_leveldb_sgx/src/block_builder.rs
index cd00aee..ed20ef9 100644
--- a/common/rusty_leveldb_sgx/src/block_builder.rs
+++ b/common/rusty_leveldb_sgx/src/block_builder.rs
@@ -122,10 +122,16 @@ impl BlockBuilder {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
-    use options;
+    use crate::options;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        should_panic!(test_block_builder_panics());
+        run_tests!(test_block_builder_sanity, test_block_builder_reset,)
+    }
 
     fn get_data() -> Vec<(&'static [u8], &'static [u8])> {
         vec![
@@ -141,7 +147,6 @@ mod tests {
         ]
     }
 
-    #[test]
     fn test_block_builder_sanity() {
         let mut o = options::for_test();
         o.block_restart_interval = 3;
@@ -161,7 +166,6 @@ mod tests {
         assert_eq!(block.len(), 149);
     }
 
-    #[test]
     fn test_block_builder_reset() {
         let mut o = options::for_test();
         o.block_restart_interval = 3;
@@ -180,8 +184,6 @@ mod tests {
         assert_eq!(4, builder.size_estimate());
     }
 
-    #[test]
-    #[should_panic]
     fn test_block_builder_panics() {
         let mut d = get_data();
         // Identical key as d[3].
diff --git a/common/rusty_leveldb_sgx/src/blockhandle.rs b/common/rusty_leveldb_sgx/src/blockhandle.rs
index 10b0152..54082e3 100644
--- a/common/rusty_leveldb_sgx/src/blockhandle.rs
+++ b/common/rusty_leveldb_sgx/src/blockhandle.rs
@@ -47,11 +47,16 @@ impl BlockHandle {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
+    use std::prelude::v1::*;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(test_blockhandle,)
+    }
 
-    #[test]
     fn test_blockhandle() {
         let bh = BlockHandle::new(890, 777);
         let mut dst = [0 as u8; 128];
diff --git a/common/rusty_leveldb_sgx/src/cache.rs b/common/rusty_leveldb_sgx/src/cache.rs
index a3e7fb0..88e23bd 100644
--- a/common/rusty_leveldb_sgx/src/cache.rs
+++ b/common/rusty_leveldb_sgx/src/cache.rs
@@ -240,16 +240,28 @@ impl<T> Cache<T> {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::LRUList;
     use super::*;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_blockcache_cache_add_rm,
+            test_blockcache_cache_capacity,
+            test_blockcache_lru_remove,
+            test_blockcache_lru_1,
+            test_blockcache_lru_reinsert,
+            test_blockcache_lru_reinsert_2,
+            test_blockcache_lru_edge_cases,
+        )
+    }
 
     fn make_key(a: u8, b: u8, c: u8) -> CacheKey {
         [a, b, c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
     }
 
-    #[test]
     fn test_blockcache_cache_add_rm() {
         let mut cache = Cache::new(128);
 
@@ -277,7 +289,6 @@ mod tests {
         assert_eq!(cache.count(), 4);
     }
 
-    #[test]
     fn test_blockcache_cache_capacity() {
         let mut cache = Cache::new(3);
 
@@ -302,7 +313,6 @@ mod tests {
         assert_eq!(cache.get(&h_899), Some(&899));
     }
 
-    #[test]
     fn test_blockcache_lru_remove() {
         let mut lru = LRUList::<usize>::new();
 
@@ -322,7 +332,6 @@ mod tests {
         assert_eq!(lru.count(), 3);
     }
 
-    #[test]
     fn test_blockcache_lru_1() {
         let mut lru = LRUList::<usize>::new();
 
@@ -346,7 +355,6 @@ mod tests {
         assert_eq!(None, lru.remove_last());
     }
 
-    #[test]
     fn test_blockcache_lru_reinsert() {
         let mut lru = LRUList::<usize>::new();
 
@@ -373,7 +381,6 @@ mod tests {
         assert_eq!(lru.remove_last(), Some(22));
     }
 
-    #[test]
     fn test_blockcache_lru_reinsert_2() {
         let mut lru = LRUList::<usize>::new();
 
@@ -395,7 +402,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_blockcache_lru_edge_cases() {
         let mut lru = LRUList::<usize>::new();
 
diff --git a/common/rusty_leveldb_sgx/src/cmp.rs b/common/rusty_leveldb_sgx/src/cmp.rs
index 12e3c80..065f648 100644
--- a/common/rusty_leveldb_sgx/src/cmp.rs
+++ b/common/rusty_leveldb_sgx/src/cmp.rs
@@ -179,13 +179,23 @@ impl Cmp for MemtableKeyCmp {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
     use crate::key_types::LookupKey;
-    use types;
+    use crate::types;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        should_panic!(test_cmp_memtablekeycmp_panics());
+        run_tests!(
+            test_cmp_defaultcmp_shortest_sep,
+            test_cmp_defaultcmp_short_succ,
+            test_cmp_internalkeycmp_shortest_sep,
+            test_cmp_internalkeycmp,
+        )
+    }
 
-    #[test]
     fn test_cmp_defaultcmp_shortest_sep() {
         assert_eq!(
             DefaultCmp.find_shortest_sep("abcd".as_bytes(), "abcf".as_bytes()),
@@ -221,7 +231,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_cmp_defaultcmp_short_succ() {
         assert_eq!(
             DefaultCmp.find_short_succ("abcd".as_bytes()),
@@ -238,7 +247,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_cmp_internalkeycmp_shortest_sep() {
         let cmp = InternalKeyCmp(Rc::new(Box::new(DefaultCmp)));
         assert_eq!(
@@ -292,7 +300,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_cmp_internalkeycmp() {
         let cmp = InternalKeyCmp(Rc::new(Box::new(DefaultCmp)));
         // a < b < c
@@ -310,8 +317,6 @@ mod tests {
         assert_eq!(Ordering::Greater, cmp.cmp_inner(e, d));
     }
 
-    #[test]
-    #[should_panic]
     fn test_cmp_memtablekeycmp_panics() {
         let cmp = MemtableKeyCmp(Rc::new(Box::new(DefaultCmp)));
         cmp.cmp(&[1, 2, 3], &[4, 5, 6]);
diff --git a/common/rusty_leveldb_sgx/src/db_impl.rs b/common/rusty_leveldb_sgx/src/db_impl.rs
index 7a56758..04cb757 100644
--- a/common/rusty_leveldb_sgx/src/db_impl.rs
+++ b/common/rusty_leveldb_sgx/src/db_impl.rs
@@ -1072,7 +1072,7 @@ fn open_info_log<E: Env + ?Sized, P: AsRef<Path>>(env: &E, db: P) -> Logger {
     }
 }
 
-#[cfg(test)]
+#[cfg(feature = "enclave_unit_test")]
 pub mod testutil {
     use super::*;
 
@@ -1130,19 +1130,40 @@ pub mod testutil {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::testutil::{build_db, set_file_to_compact};
     use super::*;
 
     use crate::error::Status;
     use crate::key_types::LookupKey;
     use crate::mem_env::MemEnv;
+    use crate::options;
+    use crate::test_util::LdbIteratorIter;
     use crate::version::testutil::make_version;
-    use options;
-    use test_util::LdbIteratorIter;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_db_impl_open_info_log,
+            test_db_impl_init,
+            test_db_impl_compact_range,
+            test_db_impl_compact_range_memtable,
+            test_db_impl_locking,
+            test_db_impl_build_table,
+            test_db_impl_build_db_sanity,
+            test_db_impl_get_from_table_with_snapshot,
+            test_db_impl_delete,
+            test_db_impl_compact_single_file,
+            test_db_impl_compaction_trivial_move,
+            test_db_impl_memtable_compaction,
+            test_db_impl_compaction,
+            test_db_impl_compaction_trivial,
+            test_db_impl_compaction_state_cleanup,
+            test_db_impl_open_close_reopen,
+        )
+    }
 
-    #[test]
     fn test_db_impl_open_info_log() {
         let e = MemEnv::new();
         {
@@ -1182,7 +1203,6 @@ mod tests {
         mt
     }
 
-    #[test]
     fn test_db_impl_init() {
         // A sanity check for recovery and basic persistence.
         let opt = options::for_test();
@@ -1299,7 +1319,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_db_impl_compact_range() {
         let (mut db, opt) = build_db();
         let env = &opt.env;
@@ -1333,7 +1352,6 @@ mod tests {
         assert_eq!(b"val3".to_vec(), db.get(b"fab").unwrap());
     }
 
-    #[test]
     fn test_db_impl_compact_range_memtable() {
         let (mut db, opt) = build_db();
         let env = &opt.env;
@@ -1373,7 +1391,6 @@ mod tests {
     }
 
     #[allow(unused_variables)]
-    #[test]
     fn test_db_impl_locking() {
         let opt = options::for_test();
         let db = DB::open("db", opt.clone()).unwrap();
@@ -1384,7 +1401,6 @@ mod tests {
         assert_eq!(want_err, DB::open("db", opt.clone()).err().unwrap());
     }
 
-    #[test]
     fn test_db_impl_build_table() {
         let mut opt = options::for_test();
         opt.block_size = 128;
@@ -1440,7 +1456,6 @@ mod tests {
     }
 
     #[allow(unused_variables)]
-    #[test]
     fn test_db_impl_build_db_sanity() {
         let db = build_db().0;
         let env = &db.opt.env;
@@ -1449,7 +1464,6 @@ mod tests {
         assert!(env.exists(Path::new(&log_file_name(name, 12))).unwrap());
     }
 
-    #[test]
     fn test_db_impl_get_from_table_with_snapshot() {
         let mut db = build_db().0;
 
@@ -1501,7 +1515,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_db_impl_delete() {
         let mut db = build_db().0;
 
@@ -1520,7 +1533,6 @@ mod tests {
         assert!(db.get(b"xyz").is_some());
     }
 
-    #[test]
     fn test_db_impl_compact_single_file() {
         let mut db = build_db().0;
         set_file_to_compact(&mut db, 4);
@@ -1534,7 +1546,6 @@ mod tests {
         assert!(env.exists(Path::new(&table_file_name(name, 13))).unwrap());
     }
 
-    #[test]
     fn test_db_impl_compaction_trivial_move() {
         let mut db = DB::open("db", options::for_test()).unwrap();
 
@@ -1570,7 +1581,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_db_impl_memtable_compaction() {
         let mut opt = options::for_test();
         opt.write_buffer_size = 25;
@@ -1591,7 +1601,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_db_impl_compaction() {
         let mut db = build_db().0;
         let v = db.current();
@@ -1610,7 +1619,6 @@ mod tests {
         assert_eq!(2, v.borrow().files[2].len());
     }
 
-    #[test]
     fn test_db_impl_compaction_trivial() {
         let (mut v, opt) = make_version();
 
@@ -1633,7 +1641,6 @@ mod tests {
         assert_eq!(3, v.borrow().files[3].len());
     }
 
-    #[test]
     fn test_db_impl_compaction_state_cleanup() {
         let env: Box<dyn Env> = Box::new(MemEnv::new());
         let name = "db";
@@ -1653,7 +1660,6 @@ mod tests {
         assert!(!env.exists(Path::new("db/000001.ldb")).unwrap());
     }
 
-    #[test]
     fn test_db_impl_open_close_reopen() {
         let opt;
         {
diff --git a/common/rusty_leveldb_sgx/src/db_iter.rs b/common/rusty_leveldb_sgx/src/db_iter.rs
index 392a93b..72f2098 100644
--- a/common/rusty_leveldb_sgx/src/db_iter.rs
+++ b/common/rusty_leveldb_sgx/src/db_iter.rs
@@ -287,19 +287,31 @@ fn random_period() -> isize {
     rand::random::<isize>() % 2 * READ_BYTES_PERIOD
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
+    use crate::db_impl::testutil::*;
+    use crate::db_impl::DB;
+    use crate::test_util::LdbIteratorIter;
     use crate::types::{current_key_val, Direction};
-    use db_impl::testutil::*;
-    use db_impl::DB;
-    use test_util::LdbIteratorIter;
 
     use std::collections::HashMap;
     use std::collections::HashSet;
     use std::iter::FromIterator;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            db_iter_basic_test,
+            db_iter_reset,
+            db_iter_test_fwd_backwd,
+            db_iter_test_seek,
+            db_iter_deleted_entry_not_returned,
+            db_iter_deleted_entry_not_returned_memtable,
+            db_iter_repeated_open_close,
+        )
+    }
 
-    #[test]
     fn db_iter_basic_test() {
         let mut db = build_db().0;
         let mut iter = db.new_iter().unwrap();
@@ -318,7 +330,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn db_iter_reset() {
         let mut db = build_db().0;
         let mut iter = db.new_iter().unwrap();
@@ -331,7 +342,6 @@ mod tests {
         assert!(iter.valid());
     }
 
-    #[test]
     fn db_iter_test_fwd_backwd() {
         let mut db = build_db().0;
         let mut iter = db.new_iter().unwrap();
@@ -382,7 +392,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn db_iter_test_seek() {
         let mut db = build_db().0;
         let mut iter = db.new_iter().unwrap();
@@ -414,7 +423,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn db_iter_deleted_entry_not_returned() {
         let mut db = build_db().0;
         let mut iter = db.new_iter().unwrap();
@@ -425,7 +433,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn db_iter_deleted_entry_not_returned_memtable() {
         let mut db = build_db().0;
 
@@ -440,7 +447,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn db_iter_repeated_open_close() {
         let opt;
         {
diff --git a/common/rusty_leveldb_sgx/src/filter.rs b/common/rusty_leveldb_sgx/src/filter.rs
index 1e276a2..33d9983 100644
--- a/common/rusty_leveldb_sgx/src/filter.rs
+++ b/common/rusty_leveldb_sgx/src/filter.rs
@@ -231,10 +231,19 @@ fn offset_data_iterate<F: FnMut(&[u8])>(data: &[u8], offsets: &[usize], mut f: F
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
     use crate::key_types::LookupKey;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_filter_bloom,
+            test_filter_internal_keys_identical,
+            test_filter_bloom_hash,
+        )
+    }
 
     const _BITS_PER_KEY: u32 = 12;
 
@@ -284,7 +293,6 @@ mod tests {
         filter
     }
 
-    #[test]
     fn test_filter_bloom() {
         let f = create_filter();
         let fp = BloomPolicy::new(_BITS_PER_KEY);
@@ -296,12 +304,10 @@ mod tests {
     }
 
     /// This test verifies that InternalFilterPolicy works correctly.
-    #[test]
     fn test_filter_internal_keys_identical() {
         assert_eq!(create_filter(), create_internalkey_filter());
     }
 
-    #[test]
     fn test_filter_bloom_hash() {
         let d1 = vec![0x62];
         let d2 = vec![0xc3, 0x97];
diff --git a/common/rusty_leveldb_sgx/src/filter_block.rs b/common/rusty_leveldb_sgx/src/filter_block.rs
index b963c4f..edd4e62 100644
--- a/common/rusty_leveldb_sgx/src/filter_block.rs
+++ b/common/rusty_leveldb_sgx/src/filter_block.rs
@@ -164,14 +164,22 @@ impl FilterBlockReader {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::get_filter_index;
     use super::FILTER_BASE_LOG2;
     use super::*;
     use crate::filter::BloomPolicy;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_filter_index,
+            test_filter_block_builder,
+            test_filter_block_build_read,
+        )
+    }
 
-    #[test]
     fn test_filter_index() {
         assert_eq!(get_filter_index(3777, FILTER_BASE_LOG2), 1);
         assert_eq!(get_filter_index(10000, FILTER_BASE_LOG2), 4);
@@ -206,7 +214,6 @@ mod tests {
         bld.finish()
     }
 
-    #[test]
     fn test_filter_block_builder() {
         let result = produce_filter_block();
         // 2 blocks of 4 filters of 4 bytes plus 1B for `k`; plus three filter offsets (because of
@@ -222,7 +229,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_filter_block_build_read() {
         let result = produce_filter_block();
         let reader = FilterBlockReader::new_owned(Rc::new(Box::new(BloomPolicy::new(32))), result);
diff --git a/common/rusty_leveldb_sgx/src/key_types.rs b/common/rusty_leveldb_sgx/src/key_types.rs
index 3e6481f..6c92ddd 100644
--- a/common/rusty_leveldb_sgx/src/key_types.rs
+++ b/common/rusty_leveldb_sgx/src/key_types.rs
@@ -216,14 +216,16 @@ pub fn truncate_to_userkey(ikey: &mut Vec<u8>) {
     ikey.truncate(len - 8);
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
+    use teaclave_test_utils::*;
 
-    #[test]
-    fn test_memtable_lookupkey() {
-        use integer_encoding::VarInt;
+    pub fn run_tests() -> bool {
+        run_tests!(test_memtable_lookupkey, test_build_memtable_key,)
+    }
 
+    fn test_memtable_lookupkey() {
         let lk1 = LookupKey::new("abcde".as_bytes(), 123);
         let lk2 = LookupKey::new("xyabxy".as_bytes(), 97);
 
@@ -239,7 +241,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_build_memtable_key() {
         assert_eq!(
             build_memtable_key(
diff --git a/common/rusty_leveldb_sgx/src/lib.rs b/common/rusty_leveldb_sgx/src/lib.rs
index b305145..a5727b6 100644
--- a/common/rusty_leveldb_sgx/src/lib.rs
+++ b/common/rusty_leveldb_sgx/src/lib.rs
@@ -38,10 +38,6 @@ extern crate integer_encoding;
 extern crate rand;
 extern crate snap;
 
-#[cfg(test)]
-#[macro_use]
-extern crate time_test;
-
 mod block;
 mod block_builder;
 mod blockhandle;
@@ -97,6 +93,33 @@ pub mod tests {
     use teaclave_test_utils::check_all_passed;
 
     pub fn run_tests() -> bool {
-        check_all_passed!(disk_env::tests::run_tests())
+        check_all_passed!(
+            block::tests::run_tests(),
+            block_builder::tests::run_tests(),
+            blockhandle::tests::run_tests(),
+            cache::tests::run_tests(),
+            cmp::tests::run_tests(),
+            db_impl::tests::run_tests(),
+            db_iter::tests::run_tests(),
+            disk_env::tests::run_tests(),
+            filter::tests::run_tests(),
+            filter_block::tests::run_tests(),
+            key_types::tests::run_tests(),
+            log::tests::run_tests(),
+            mem_env::tests::run_tests(),
+            memtable::tests::run_tests(),
+            merging_iter::tests::run_tests(),
+            skipmap::tests::run_tests(),
+            snapshot::tests::run_tests(),
+            table_builder::tests::run_tests(),
+            table_cache::tests::run_tests(),
+            test_util::tests::run_tests(),
+            table_reader::tests::run_tests(),
+            types::tests::run_tests(),
+            version::tests::run_tests(),
+            version_edit::tests::run_tests(),
+            version_set::tests::run_tests(),
+            write_batch::tests::run_tests(),
+        )
     }
 }
diff --git a/common/rusty_leveldb_sgx/src/log.rs b/common/rusty_leveldb_sgx/src/log.rs
index 9c5faa2..806ce1a 100644
--- a/common/rusty_leveldb_sgx/src/log.rs
+++ b/common/rusty_leveldb_sgx/src/log.rs
@@ -215,25 +215,33 @@ pub fn unmask_crc(mc: u32) -> u32 {
     (rot.wrapping_shr(17) | rot.wrapping_shl(15))
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
     use std::io::Cursor;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_crc_mask_crc,
+            test_crc_sanity,
+            test_writer,
+            test_writer_append,
+            test_reader,
+        )
+    }
 
-    #[test]
     fn test_crc_mask_crc() {
         let crc = crc32::checksum_castagnoli("abcde".as_bytes());
         assert_eq!(crc, unmask_crc(mask_crc(crc)));
         assert!(crc != mask_crc(crc));
     }
 
-    #[test]
     fn test_crc_sanity() {
         assert_eq!(0x8a9136aa, crc32::checksum_castagnoli(&[0 as u8; 32]));
         assert_eq!(0x62a8ab43, crc32::checksum_castagnoli(&[0xff as u8; 32]));
     }
 
-    #[test]
     fn test_writer() {
         let data = &[
             "hello world. My first log entry.",
@@ -250,7 +258,6 @@ mod tests {
         assert_eq!(lw.current_block_offset, total_len + 3 * super::HEADER_SIZE);
     }
 
-    #[test]
     fn test_writer_append() {
         let data = &[
             "hello world. My first log entry.",
@@ -283,7 +290,6 @@ mod tests {
         assert_eq!(old, dst);
     }
 
-    #[test]
     fn test_reader() {
         let data = vec![
             "abcdefghi".as_bytes().to_vec(),    // fits one block of 17
diff --git a/common/rusty_leveldb_sgx/src/mem_env.rs b/common/rusty_leveldb_sgx/src/mem_env.rs
index 366df23..609e370 100644
--- a/common/rusty_leveldb_sgx/src/mem_env.rs
+++ b/common/rusty_leveldb_sgx/src/mem_env.rs
@@ -348,16 +348,30 @@ impl Env for MemEnv {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
     use crate::env;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_mem_fs_memfile_read,
+            test_mem_fs_memfile_write,
+            test_mem_fs_memfile_readat,
+            test_mem_fs_open_read_write,
+            test_mem_fs_open_read_write_append_truncate,
+            test_mem_fs_metadata_operations,
+            test_mem_fs_children,
+            test_mem_fs_lock,
+            test_memenv_all,
+        )
+    }
 
     fn new_memfile(v: Vec<u8>) -> MemFile {
         MemFile(Arc::new(Mutex::new(v)))
     }
 
-    #[test]
     fn test_mem_fs_memfile_read() {
         let f = new_memfile(vec![1, 2, 3, 4, 5, 6, 7, 8]);
         let mut buf: [u8; 1] = [0];
@@ -369,7 +383,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_mem_fs_memfile_write() {
         let f = new_memfile(vec![]);
         let mut w1 = MemFileWriter::new(f.clone(), false);
@@ -385,7 +398,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_mem_fs_memfile_readat() {
         let f = new_memfile(vec![1, 2, 3, 4, 5]);
 
@@ -406,7 +418,6 @@ mod tests {
         assert_eq!(buf2, [1, 2, 3, 4, 5, 0]);
     }
 
-    #[test]
     fn test_mem_fs_open_read_write() {
         let fs = MemFS::new();
         let path = Path::new("/a/b/hello.txt");
@@ -434,7 +445,6 @@ mod tests {
         assert!(!fs.exists_(&Path::new("/non/existing/path")).unwrap());
     }
 
-    #[test]
     fn test_mem_fs_open_read_write_append_truncate() {
         let fs = MemFS::new();
         let path = Path::new("/a/b/hello.txt");
@@ -464,7 +474,6 @@ mod tests {
         assert!(!fs.exists_(&Path::new("/non/existing/path")).unwrap());
     }
 
-    #[test]
     fn test_mem_fs_metadata_operations() {
         let fs = MemFS::new();
         let path = Path::new("/a/b/hello.file");
@@ -506,7 +515,6 @@ mod tests {
         Path::new(x).to_owned()
     }
 
-    #[test]
     fn test_mem_fs_children() {
         let fs = MemFS::new();
         let (path1, path2, path3) = (
@@ -530,7 +538,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_mem_fs_lock() {
         let fs = MemFS::new();
         let p = Path::new("/a/lock");
@@ -569,7 +576,6 @@ mod tests {
             .is_ok());
     }
 
-    #[test]
     fn test_memenv_all() {
         let me = MemEnv::new();
         let (p1, p2, p3) = (Path::new("/a/b"), Path::new("/a/c"), Path::new("/a/d"));
diff --git a/common/rusty_leveldb_sgx/src/memtable.rs b/common/rusty_leveldb_sgx/src/memtable.rs
index 467ecd5..e78764e 100644
--- a/common/rusty_leveldb_sgx/src/memtable.rs
+++ b/common/rusty_leveldb_sgx/src/memtable.rs
@@ -153,15 +153,30 @@ fn shift_left(s: &mut Vec<u8>, mid: usize) {
     s.truncate(newlen);
 }
 
-#[cfg(test)]
+#[cfg(feature = "enclave_unit_test")]
 #[allow(unused_variables)]
-mod tests {
+pub mod tests {
     use super::*;
     use crate::key_types::*;
-    use options;
-    use test_util::{test_iterator_properties, LdbIteratorIter};
+    use crate::options;
+    use crate::test_util::{test_iterator_properties, LdbIteratorIter};
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_shift_left,
+            test_memtable_parse_tag,
+            test_memtable_add,
+            test_memtable_add_get,
+            test_memtable_iterator_init,
+            test_memtable_iterator_seek,
+            test_memtable_iterator_fwd,
+            test_memtable_iterator_reverse,
+            test_memtable_parse_key,
+            test_memtable_iterator_behavior,
+        )
+    }
 
-    #[test]
     fn test_shift_left() {
         let mut v = vec![1, 2, 3, 4, 5];
         shift_left(&mut v, 1);
@@ -188,13 +203,11 @@ mod tests {
         mt
     }
 
-    #[test]
     fn test_memtable_parse_tag() {
         let tag = (12345 << 8) | 1;
         assert_eq!(parse_tag(tag), (ValueType::TypeValue, 12345));
     }
 
-    #[test]
     fn test_memtable_add() {
         let mut mt = MemTable::new(options::for_test().cmp);
         mt.add(
@@ -214,7 +227,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_memtable_add_get() {
         let mt = get_memtable();
 
@@ -257,7 +269,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_memtable_iterator_init() {
         let mt = get_memtable();
         let mut iter = mt.iter();
@@ -273,7 +284,6 @@ mod tests {
         assert!(!iter.valid());
     }
 
-    #[test]
     fn test_memtable_iterator_seek() {
         let mt = get_memtable();
         let mut iter = mt.iter();
@@ -300,7 +310,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_memtable_iterator_fwd() {
         let mt = get_memtable();
         let mut iter = mt.iter();
@@ -322,7 +331,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_memtable_iterator_reverse() {
         let mt = get_memtable();
         let mut iter = mt.iter();
@@ -367,7 +375,6 @@ mod tests {
         assert!(!iter.valid());
     }
 
-    #[test]
     fn test_memtable_parse_key() {
         let key = vec![11, 1, 2, 3, 1, 123, 0, 0, 0, 0, 0, 0, 3, 4, 5, 6];
         let (keylen, keyoff, tag, vallen, valoff) = parse_memtable_key(&key);
@@ -378,7 +385,6 @@ mod tests {
         assert_eq!(&key[valoff..valoff + vallen], vec![4, 5, 6].as_slice());
     }
 
-    #[test]
     fn test_memtable_iterator_behavior() {
         let mut mt = MemTable::new(options::for_test().cmp);
         let entries = vec![
diff --git a/common/rusty_leveldb_sgx/src/merging_iter.rs b/common/rusty_leveldb_sgx/src/merging_iter.rs
index 6c20ba3..cb02c64 100644
--- a/common/rusty_leveldb_sgx/src/merging_iter.rs
+++ b/common/rusty_leveldb_sgx/src/merging_iter.rs
@@ -197,16 +197,29 @@ impl LdbIterator for MergingIter {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
 
     use crate::cmp::DefaultCmp;
     use crate::skipmap::tests;
+    use crate::test_util::{test_iterator_properties, LdbIteratorIter, TestLdbIter};
     use crate::types::{current_key_val, LdbIterator};
-    use test_util::{test_iterator_properties, LdbIteratorIter, TestLdbIter};
 
-    #[test]
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_merging_one,
+            test_merging_two,
+            test_merging_zero,
+            test_merging_behavior,
+            test_merging_forward_backward,
+            test_merging_real,
+            test_merging_seek_reset,
+        )
+    }
+
     fn test_merging_one() {
         let skm = tests::make_skipmap();
         let iter = skm.iter();
@@ -228,7 +241,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_merging_two() {
         let skm = tests::make_skipmap();
         let iter = skm.iter();
@@ -253,13 +265,11 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_merging_zero() {
         let mut miter = MergingIter::new(Rc::new(Box::new(DefaultCmp)), vec![]);
         assert_eq!(0, LdbIteratorIter::wrap(&mut miter).count());
     }
 
-    #[test]
     fn test_merging_behavior() {
         let val = "def".as_bytes();
         let iter = TestLdbIter::new(vec![(b("aba"), val), (b("abc"), val)]);
@@ -271,7 +281,6 @@ mod tests {
         test_iterator_properties(miter);
     }
 
-    #[test]
     fn test_merging_forward_backward() {
         let val = "def".as_bytes();
         let iter = TestLdbIter::new(vec![(b("aba"), val), (b("abc"), val), (b("abe"), val)]);
@@ -317,7 +326,6 @@ mod tests {
         s.as_bytes()
     }
 
-    #[test]
     fn test_merging_real() {
         let val = "def".as_bytes();
 
@@ -337,7 +345,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_merging_seek_reset() {
         let val = "def".as_bytes();
 
diff --git a/common/rusty_leveldb_sgx/src/skipmap.rs b/common/rusty_leveldb_sgx/src/skipmap.rs
index 9976bd9..5b368f0 100644
--- a/common/rusty_leveldb_sgx/src/skipmap.rs
+++ b/common/rusty_leveldb_sgx/src/skipmap.rs
@@ -358,13 +358,32 @@ impl LdbIterator for SkipMapIter {
     }
 }
 
-#[cfg(test)]
+#[cfg(feature = "enclave_unit_test")]
 pub mod tests {
     use super::*;
     use crate::cmp::MemtableKeyCmp;
+    use crate::options;
+    use crate::test_util::{test_iterator_properties, LdbIteratorIter};
     use crate::types::current_key_val;
-    use options;
-    use test_util::{test_iterator_properties, LdbIteratorIter};
+
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        should_panic!(test_no_dupes());
+        run_tests!(
+            test_insert,
+            test_contains,
+            test_find,
+            test_empty_skipmap_find_memtable_cmp,
+            test_skipmap_iterator_0,
+            test_skipmap_iterator_init,
+            test_skipmap_iterator,
+            test_skipmap_iterator_seek_valid,
+            test_skipmap_behavior,
+            test_skipmap_iterator_prev,
+            test_skipmap_iterator_concurrent_insert,
+        )
+    }
 
     pub fn make_skipmap() -> SkipMap {
         let mut skm = SkipMap::new(options::for_test().cmp);
@@ -380,15 +399,12 @@ pub mod tests {
         skm
     }
 
-    #[test]
     fn test_insert() {
         let skm = make_skipmap();
         assert_eq!(skm.len(), 26);
         skm.map.borrow().dbg_print();
     }
 
-    #[test]
-    #[should_panic]
     fn test_no_dupes() {
         let mut skm = make_skipmap();
         // this should panic
@@ -396,7 +412,6 @@ pub mod tests {
         skm.insert("abf".as_bytes().to_vec(), "def".as_bytes().to_vec());
     }
 
-    #[test]
     fn test_contains() {
         let skm = make_skipmap();
         assert!(skm.contains(&"aby".as_bytes().to_vec()));
@@ -408,7 +423,6 @@ pub mod tests {
         assert!(!skm.contains(&"456".as_bytes().to_vec()));
     }
 
-    #[test]
     fn test_find() {
         let skm = make_skipmap();
         assert_eq!(
@@ -475,7 +489,6 @@ pub mod tests {
         );
     }
 
-    #[test]
     fn test_empty_skipmap_find_memtable_cmp() {
         // Regression test: Make sure comparator isn't called with empty key.
         let cmp: Rc<Box<dyn Cmp>> = Rc::new(Box::new(MemtableKeyCmp(options::for_test().cmp)));
@@ -486,7 +499,6 @@ pub mod tests {
         assert!(!it.valid());
     }
 
-    #[test]
     fn test_skipmap_iterator_0() {
         let skm = SkipMap::new(options::for_test().cmp);
         let mut i = 0;
@@ -499,7 +511,6 @@ pub mod tests {
         assert!(!skm.iter().valid());
     }
 
-    #[test]
     fn test_skipmap_iterator_init() {
         let skm = make_skipmap();
         let mut iter = skm.iter();
@@ -516,7 +527,6 @@ pub mod tests {
         assert!(!iter.valid());
     }
 
-    #[test]
     fn test_skipmap_iterator() {
         let skm = make_skipmap();
         let mut i = 0;
@@ -529,7 +539,6 @@ pub mod tests {
         assert_eq!(i, 26);
     }
 
-    #[test]
     fn test_skipmap_iterator_seek_valid() {
         let skm = make_skipmap();
         let mut iter = skm.iter();
@@ -560,7 +569,6 @@ pub mod tests {
         assert_eq!(current_key_val(&iter), None);
     }
 
-    #[test]
     fn test_skipmap_behavior() {
         let mut skm = SkipMap::new(options::for_test().cmp);
         let keys = vec!["aba", "abb", "abc", "abd"];
@@ -570,7 +578,6 @@ pub mod tests {
         test_iterator_properties(skm.iter());
     }
 
-    #[test]
     fn test_skipmap_iterator_prev() {
         let skm = make_skipmap();
         let mut iter = skm.iter();
@@ -587,9 +594,7 @@ pub mod tests {
         );
     }
 
-    #[test]
     fn test_skipmap_iterator_concurrent_insert() {
-        time_test!();
         // Asserts that the map can be mutated while an iterator exists; this is intentional.
         let mut skm = make_skipmap();
         let mut iter = skm.iter();
diff --git a/common/rusty_leveldb_sgx/src/snapshot.rs b/common/rusty_leveldb_sgx/src/snapshot.rs
index 395f714..486b2b9 100644
--- a/common/rusty_leveldb_sgx/src/snapshot.rs
+++ b/common/rusty_leveldb_sgx/src/snapshot.rs
@@ -115,12 +115,17 @@ impl InnerSnapshotList {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
+    use std::prelude::v1::*;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(test_snapshot_list,)
+    }
 
     #[allow(unused_variables)]
-    #[test]
     fn test_snapshot_list() {
         let mut l = SnapshotList::new();
 
diff --git a/common/rusty_leveldb_sgx/src/table_builder.rs b/common/rusty_leveldb_sgx/src/table_builder.rs
index ebaf515..bbe9d8d 100644
--- a/common/rusty_leveldb_sgx/src/table_builder.rs
+++ b/common/rusty_leveldb_sgx/src/table_builder.rs
@@ -273,13 +273,18 @@ impl<Dst: Write> TableBuilder<Dst> {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
     use crate::blockhandle::BlockHandle;
-    use options;
+    use crate::options;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        should_panic!(test_bad_input());
+        run_tests!(test_footer, test_table_builder,)
+    }
 
-    #[test]
     fn test_footer() {
         let f = Footer::new(BlockHandle::new(44, 4), BlockHandle::new(55, 5));
         let mut buf = [0; 48];
@@ -292,7 +297,6 @@ mod tests {
         assert_eq!(f2.index.size(), 5);
     }
 
-    #[test]
     fn test_table_builder() {
         let mut d = Vec::with_capacity(512);
         let mut opt = options::for_test();
@@ -328,8 +332,6 @@ mod tests {
         assert_eq!(223, actual);
     }
 
-    #[test]
-    #[should_panic]
     fn test_bad_input() {
         let mut d = Vec::with_capacity(512);
         let mut opt = options::for_test();
diff --git a/common/rusty_leveldb_sgx/src/table_cache.rs b/common/rusty_leveldb_sgx/src/table_cache.rs
index cbde776..88436d4 100644
--- a/common/rusty_leveldb_sgx/src/table_cache.rs
+++ b/common/rusty_leveldb_sgx/src/table_cache.rs
@@ -88,16 +88,21 @@ impl TableCache {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
     use crate::cache;
     use crate::mem_env::MemEnv;
+    use crate::options;
     use crate::table_builder::TableBuilder;
-    use options;
-    use test_util::LdbIteratorIter;
+    use crate::test_util::LdbIteratorIter;
+
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(test_table_file_name, test_filenum_to_key, test_table_cache,)
+    }
 
-    #[test]
     fn test_table_file_name() {
         assert_eq!(Path::new("abc/000122.ldb"), table_file_name("abc", 122));
         assert_eq!(
@@ -110,7 +115,6 @@ mod tests {
         [a, b, c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
     }
 
-    #[test]
     fn test_filenum_to_key() {
         assert_eq!(make_key(16, 0, 0), filenum_to_key(0x10));
         assert_eq!(make_key(16, 1, 0), filenum_to_key(0x0110));
@@ -134,7 +138,6 @@ mod tests {
         b.finish().unwrap();
     }
 
-    #[test]
     fn test_table_cache() {
         // Tests that a table can be written to a MemFS file, read back by the table cache and
         // parsed/iterated by the table reader.
diff --git a/common/rusty_leveldb_sgx/src/table_reader.rs b/common/rusty_leveldb_sgx/src/table_reader.rs
index cd87d87..8f424dc 100644
--- a/common/rusty_leveldb_sgx/src/table_reader.rs
+++ b/common/rusty_leveldb_sgx/src/table_reader.rs
@@ -353,16 +353,33 @@ impl LdbIterator for TableIterator {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use crate::filter::BloomPolicy;
     use crate::key_types::LookupKey;
     use crate::options::{self, CompressionType};
     use crate::table_builder::TableBuilder;
+    use crate::test_util::{test_iterator_properties, LdbIteratorIter};
     use crate::types::{current_key_val, LdbIterator};
-    use test_util::{test_iterator_properties, LdbIteratorIter};
 
     use super::*;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_table_approximate_offset,
+            test_table_block_cache_use,
+            test_table_iterator_fwd_bwd,
+            test_table_iterator_filter,
+            test_table_iterator_state_behavior,
+            test_table_iterator_behavior_standard,
+            test_table_iterator_values,
+            test_table_iterator_seek,
+            test_table_get,
+            test_table_internal_keys,
+            test_table_reader_checksum,
+        )
+    }
 
     fn build_data() -> Vec<(&'static str, &'static str)> {
         vec![
@@ -440,7 +457,6 @@ mod tests {
         Rc::new(Box::new(src))
     }
 
-    #[test]
     fn test_table_approximate_offset() {
         let (src, size) = build_table(build_data());
         let mut opt = options::for_test();
@@ -459,7 +475,6 @@ mod tests {
         assert_eq!(137, table.approx_offset_of("{aa".as_bytes()));
     }
 
-    #[test]
     fn test_table_block_cache_use() {
         let (src, size) = build_table(build_data());
         let mut opt = options::for_test();
@@ -480,7 +495,6 @@ mod tests {
         assert_eq!(opt.block_cache.borrow().count(), 2);
     }
 
-    #[test]
     fn test_table_iterator_fwd_bwd() {
         let (src, size) = build_table(build_data());
         let data = build_data();
@@ -531,7 +545,6 @@ mod tests {
         assert_eq!(j, 6);
     }
 
-    #[test]
     fn test_table_iterator_filter() {
         let (src, size) = build_table(build_data());
 
@@ -550,7 +563,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_table_iterator_state_behavior() {
         let (src, size) = build_table(build_data());
 
@@ -579,7 +591,6 @@ mod tests {
         assert_eq!(first, iter.next());
     }
 
-    #[test]
     fn test_table_iterator_behavior_standard() {
         let mut data = build_data();
         data.truncate(4);
@@ -588,7 +599,6 @@ mod tests {
         test_iterator_properties(table.iter());
     }
 
-    #[test]
     fn test_table_iterator_values() {
         let (src, size) = build_table(build_data());
         let data = build_data();
@@ -624,7 +634,6 @@ mod tests {
         assert_eq!(i, 6);
     }
 
-    #[test]
     fn test_table_iterator_seek() {
         let (src, size) = build_table(build_data());
 
@@ -651,7 +660,6 @@ mod tests {
         assert!(iter.valid());
     }
 
-    #[test]
     fn test_table_get() {
         let (src, size) = build_table(build_data());
 
@@ -683,10 +691,7 @@ mod tests {
     // InternalFilterPolicy.
     // All the other tests use raw keys that don't have any internal structure; this is fine in
     // general, but here we want to see that the other infrastructure works too.
-    #[test]
     fn test_table_internal_keys() {
-        use crate::key_types::LookupKey;
-
         let (src, size) = build_internal_table();
 
         let table = Table::new(options::for_test(), wrap_buffer(src), size).unwrap();
@@ -719,7 +724,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_table_reader_checksum() {
         let (mut src, size) = build_table(build_data());
 
diff --git a/common/rusty_leveldb_sgx/src/test_util.rs b/common/rusty_leveldb_sgx/src/test_util.rs
index 868161d..e1928ad 100644
--- a/common/rusty_leveldb_sgx/src/test_util.rs
+++ b/common/rusty_leveldb_sgx/src/test_util.rs
@@ -133,11 +133,15 @@ pub fn test_iterator_properties<It: LdbIterator>(mut it: It) {
     assert!(!it.valid());
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(test_test_util_basic, test_test_util_ldbiter_properties,)
+    }
 
-    #[test]
     fn test_test_util_basic() {
         let v = vec![
             ("abc".as_bytes(), "def".as_bytes()),
@@ -150,12 +154,9 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_test_util_ldbiter_properties() {
-        time_test!();
         let v;
         {
-            time_test!("init");
             v = vec![
                 ("abc".as_bytes(), "def".as_bytes()),
                 ("abd".as_bytes(), "deg".as_bytes()),
diff --git a/common/rusty_leveldb_sgx/src/types.rs b/common/rusty_leveldb_sgx/src/types.rs
index fc48ede..b4da1d6 100644
--- a/common/rusty_leveldb_sgx/src/types.rs
+++ b/common/rusty_leveldb_sgx/src/types.rs
@@ -185,11 +185,15 @@ pub fn parse_file_name<P: AsRef<Path>>(ff: P) -> Result<(FileNum, FileType)> {
     err(StatusCode::InvalidArgument, "unknown file type")
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(test_types_parse_file_name,)
+    }
 
-    #[test]
     fn test_types_parse_file_name() {
         for c in &[
             ("CURRENT", (0, FileType::Current)),
diff --git a/common/rusty_leveldb_sgx/src/version.rs b/common/rusty_leveldb_sgx/src/version.rs
index 171890e..db0d7c7 100644
--- a/common/rusty_leveldb_sgx/src/version.rs
+++ b/common/rusty_leveldb_sgx/src/version.rs
@@ -573,7 +573,7 @@ fn some_file_overlaps_range<'a, 'b>(
     false
 }
 
-#[cfg(test)]
+#[cfg(feature = "enclave_unit_test")]
 pub mod testutil {
     use super::*;
     use crate::cmp::DefaultCmp;
@@ -720,18 +720,34 @@ pub mod testutil {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::testutil::*;
     use super::*;
 
     use crate::cmp::DefaultCmp;
     use crate::error::Result;
     use crate::merging_iter::MergingIter;
-    use options;
-    use test_util::{test_iterator_properties, LdbIteratorIter};
+    use crate::options;
+    use crate::test_util::{test_iterator_properties, LdbIteratorIter};
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_version_max_next_level_overlapping,
+            test_version_all_iters,
+            test_version_summary,
+            test_version_get_simple,
+            test_version_get_overlapping_basic,
+            test_version_overlap_in_level,
+            test_version_pick_memtable_output_level,
+            test_version_overlapping_inputs,
+            test_version_record_read_sample,
+            test_version_key_ordering,
+            test_version_file_overlaps,
+        )
+    }
 
-    #[test]
     fn test_version_concat_iter() {
         let v = make_version().0;
 
@@ -743,20 +759,17 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_version_concat_iter_properties() {
         let v = make_version().0;
         let iter = v.new_concat_iter(3);
         test_iterator_properties(iter);
     }
 
-    #[test]
     fn test_version_max_next_level_overlapping() {
         let v = make_version().0;
         assert_eq!(218, v.max_next_level_overlapping_bytes());
     }
 
-    #[test]
     fn test_version_all_iters() {
         let v = make_version().0;
         let iters = v.new_iters().unwrap();
@@ -775,7 +788,6 @@ mod tests {
         });
     }
 
-    #[test]
     fn test_version_summary() {
         let v = make_version().0;
         let expected = "level 0: 2 files, 483 bytes ([(1, 232), (2, 251)]); level 1: 3 files, 651 \
@@ -784,7 +796,6 @@ mod tests {
         assert_eq!(expected, &v.level_summary());
     }
 
-    #[test]
     fn test_version_get_simple() {
         let v = make_version().0;
         let cases: &[(&[u8], u64, Result<Option<Vec<u8>>>)] = &[
@@ -815,7 +826,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_version_get_overlapping_basic() {
         let v = make_version().0;
 
@@ -836,7 +846,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_version_overlap_in_level() {
         let v = make_version().0;
 
@@ -856,7 +865,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_version_pick_memtable_output_level() {
         let v = make_version().0;
 
@@ -871,11 +879,9 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_version_overlapping_inputs() {
         let v = make_version().0;
 
-        time_test!("overlapping-inputs");
         {
             // Range is expanded in overlapping level-0 files.
             let from = LookupKey::new("aab".as_bytes(), MAX_SEQUENCE_NUMBER);
@@ -913,7 +919,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_version_record_read_sample() {
         let mut v = make_version().0;
         let k = LookupKey::new("aab".as_bytes(), MAX_SEQUENCE_NUMBER);
@@ -930,9 +935,7 @@ mod tests {
         assert!(v.record_read_sample(k.internal_key()));
     }
 
-    #[test]
     fn test_version_key_ordering() {
-        time_test!();
         let fmh = new_file(1, &[1, 0, 0], 0, &[2, 0, 0], 1);
         let cmp = InternalKeyCmp(Rc::new(Box::new(DefaultCmp)));
 
@@ -959,10 +962,7 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_version_file_overlaps() {
-        time_test!();
-
         let files_disjoint = [
             new_file(1, &[2, 0, 0], 0, &[3, 0, 0], 1),
             new_file(2, &[3, 0, 1], 0, &[4, 0, 0], 1),
diff --git a/common/rusty_leveldb_sgx/src/version_edit.rs b/common/rusty_leveldb_sgx/src/version_edit.rs
index 860b2dc..81eab83 100644
--- a/common/rusty_leveldb_sgx/src/version_edit.rs
+++ b/common/rusty_leveldb_sgx/src/version_edit.rs
@@ -297,15 +297,20 @@ impl VersionEdit {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::CompactionPointer;
     use super::VersionEdit;
+    use super::*;
 
     use crate::cmp::{Cmp, DefaultCmp};
     use crate::types::FileMetaData;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(test_version_edit_encode_decode,)
+    }
 
-    #[test]
     fn test_version_edit_encode_decode() {
         let mut ve = VersionEdit::new();
 
diff --git a/common/rusty_leveldb_sgx/src/version_set.rs b/common/rusty_leveldb_sgx/src/version_set.rs
index 21976e0..50bb1b2 100644
--- a/common/rusty_leveldb_sgx/src/version_set.rs
+++ b/common/rusty_leveldb_sgx/src/version_set.rs
@@ -977,14 +977,28 @@ fn get_range<'a, C: Cmp, I: Iterator<Item = &'a FileMetaHandle>>(
     (smallest.unwrap(), largest.unwrap())
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
     use crate::cmp::DefaultCmp;
     use crate::key_types::LookupKey;
+    use crate::test_util::LdbIteratorIter;
     use crate::types::FileMetaData;
     use crate::version::testutil::make_version;
-    use test_util::LdbIteratorIter;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(
+            test_version_set_merge_iters,
+            test_version_set_total_size,
+            test_version_set_get_range,
+            test_version_set_builder,
+            test_version_set_log_and_apply,
+            test_version_set_utils,
+            test_version_set_pick_compaction,
+            test_version_set_compaction,
+        )
+    }
 
     fn example_files() -> Vec<FileMetaHandle> {
         let mut f1 = FileMetaData::default();
@@ -1010,7 +1024,6 @@ mod tests {
         vec![f1, f2, f3, f4].into_iter().map(share).collect()
     }
 
-    #[test]
     fn test_version_set_merge_iters() {
         let v1 = vec![2, 4, 6, 8, 10];
         let v2 = vec![1, 3, 5, 7];
@@ -1020,12 +1033,10 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_version_set_total_size() {
         assert_eq!(100, total_size(example_files().iter()));
     }
 
-    #[test]
     fn test_version_set_get_range() {
         let cmp = DefaultCmp;
         let fs = example_files();
@@ -1035,7 +1046,6 @@ mod tests {
         );
     }
 
-    #[test]
     fn test_version_set_builder() {
         let (v, opt) = make_version();
         let v = share(v);
@@ -1057,6 +1067,7 @@ mod tests {
         ve.delete_file(0, 2);
         ve.set_compact_pointer(2, LookupKey::new("xxx".as_bytes(), 123).internal_key());
 
+        println!("XXXXXXXXXXXXXXXXXXXXXXXX");
         let mut b = Builder::new();
         let mut ptrs: [Vec<u8>; NUM_LEVELS] = Default::default();
         b.apply(&ve, &mut ptrs);
@@ -1080,7 +1091,6 @@ mod tests {
         assert_eq!(21, v2.files[1][3].borrow().num);
     }
 
-    #[test]
     fn test_version_set_log_and_apply() {
         let (_, opt) = make_version();
         let mut vs = VersionSet::new(
@@ -1151,7 +1161,6 @@ mod tests {
         }
     }
 
-    #[test]
     fn test_version_set_utils() {
         let (v, opt) = make_version();
         let mut vs = VersionSet::new("db", opt.clone(), share(TableCache::new("db", opt, 100)));
@@ -1175,7 +1184,6 @@ mod tests {
         assert_eq!(3, vs.new_file_number());
     }
 
-    #[test]
     fn test_version_set_pick_compaction() {
         let (mut v, opt) = make_version();
         let mut vs = VersionSet::new("db", opt.clone(), share(TableCache::new("db", opt, 100)));
@@ -1224,11 +1232,9 @@ mod tests {
         assert_eq!(len, count);
     }
 
-    #[test]
     fn test_version_set_compaction() {
         let (v, opt) = make_version();
         let mut vs = VersionSet::new("db", opt.clone(), share(TableCache::new("db", opt, 100)));
-        time_test!();
         vs.add_version(v);
 
         {
@@ -1250,7 +1256,6 @@ mod tests {
         // The following tests reuse the same version set and verify that various compactions work
         // like they should.
         {
-            time_test!("compaction tests");
             // compact level 0 with a partial range.
             let from = LookupKey::new("000".as_bytes(), 1000);
             let to = LookupKey::new("ab".as_bytes(), 1010);
diff --git a/common/rusty_leveldb_sgx/src/write_batch.rs b/common/rusty_leveldb_sgx/src/write_batch.rs
index 5e900fe..826e713 100644
--- a/common/rusty_leveldb_sgx/src/write_batch.rs
+++ b/common/rusty_leveldb_sgx/src/write_batch.rs
@@ -144,12 +144,16 @@ impl<'a> Iterator for WriteBatchIter<'a> {
     }
 }
 
-#[cfg(test)]
-mod tests {
+#[cfg(feature = "enclave_unit_test")]
+pub mod tests {
     use super::*;
     use std::iter::Iterator;
+    use teaclave_test_utils::*;
+
+    pub fn run_tests() -> bool {
+        run_tests!(test_write_batch,)
+    }
 
-    #[test]
     fn test_write_batch() {
         let mut b = WriteBatch::new();
         let entries = vec![
diff --git a/tests/unit/enclave/Enclave.config.xml b/tests/unit/enclave/Enclave.config.xml
index 705edcd..2c4cfca 100644
--- a/tests/unit/enclave/Enclave.config.xml
+++ b/tests/unit/enclave/Enclave.config.xml
@@ -3,7 +3,7 @@
   <ProdID>0</ProdID>
   <ISVSVN>0</ISVSVN>
   <StackMaxSize>0x200000</StackMaxSize>
-  <HeapMaxSize>0x1000000</HeapMaxSize>
+  <HeapMaxSize>0x8000000</HeapMaxSize>
   <TCSNum>22</TCSNum>
   <TCSPolicy>0</TCSPolicy>
   <DisableDebug>0</DisableDebug>
diff --git a/tests/utils/src/lib.rs b/tests/utils/src/lib.rs
index 1d4741e..d631d5a 100644
--- a/tests/utils/src/lib.rs
+++ b/tests/utils/src/lib.rs
@@ -26,8 +26,15 @@ use std::vec::Vec;
 #[macro_export]
 macro_rules! should_panic {
     ($fmt:expr) => {{
-        match panic::catch_unwind(|| $fmt).is_err() {
-            true => {}
+        match ::std::panic::catch_unwind(|| $fmt).is_err() {
+            true => {
+                println!(
+                    "{} {} ... {}!",
+                    "testing_should_panic",
+                    stringify!($fmt),
+                    "\x1B[1;32mok\x1B[0m"
+                );
+            }
             false => {
                 ::std::rt::begin_panic($fmt, {
                     // static requires less code at runtime, more constant data


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org