sccommunity / crates-sgx

crates-sgx is a monorepo of all Rust crates ported for Teaclave SGX SDK targeting Intel SGX.
https://sccommunity.github.io/crates-sgx
Apache License 2.0
12 stars 2 forks source link

feature: add rust-fnv@v1.0.6 #9

Closed sammyne closed 4 years ago

sammyne commented 4 years ago

Add Crates

Description

Port in rust-fnv@1.0.6

Crate Meta

Diff of Changes

diff -Naur '--exclude=.git' '--exclude=sgx-tests' crates/rust-fnv/Cargo.toml ../rust-fnv/Cargo.toml
--- crates/rust-fnv/Cargo.toml  2020-04-03 11:38:11.184539990 +0000
+++ ../rust-fnv/Cargo.toml  2020-04-03 11:44:22.459337505 +0000
@@ -7,17 +7,7 @@
 readme = "README.md"
 repository = "https://github.com/servo/rust-fnv"
 documentation = "https://doc.servo.org/fnv/"
-edition = "2018"

 [lib]
 name = "fnv"
 path = "lib.rs"
-
-[features]
-default = ["mesalock_sgx"]
-mesalock_sgx = ["sgx_tstd"]
-enclave_unit_test = ["sgx_tunittest"]
-
-[dependencies]
-sgx_tstd        = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk.git", tag = "v1.1.1", optional = true }
-sgx_tunittest   = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk.git", tag = "v1.1.1", optional = true }
diff -Naur '--exclude=.git' '--exclude=sgx-tests' crates/rust-fnv/lib.rs ../rust-fnv/lib.rs
--- crates/rust-fnv/lib.rs  2020-04-03 11:38:11.185540059 +0000
+++ ../rust-fnv/lib.rs  2020-04-03 11:44:22.460337576 +0000
@@ -64,11 +64,6 @@
 //! [faq]: https://www.rust-lang.org/en-US/faq.html#why-are-rusts-hashmaps-slow
 //! [graphs]: http://cglab.ca/~abeinges/blah/hash-rs/

-#![cfg_attr(all(feature = "mesalock_sgx",
-                not(target_env = "sgx")), no_std)]
-#![cfg_attr(all(target_env = "sgx", target_vendor = "mesalock"), feature(rustc_private))]
-#[cfg(all(feature = "mesalock_sgx", not(target_env = "sgx")))]
-extern crate sgx_tstd as std;

 use std::default::Default;
 use std::hash::{Hasher, BuildHasherDefault};
@@ -126,19 +121,11 @@
 pub type FnvHashSet<T> = HashSet<T, FnvBuildHasher>;

-#[cfg(feature = "enclave_unit_test")]
-pub mod test {
-    use std::prelude::v1::*;
-
+#[cfg(test)]
+mod test {
     use super::*;
     use std::hash::Hasher;

-    use sgx_tunittest::*;
-
-    pub fn run_tests() {
-        rsgx_unit_tests!(basic_tests);
-    }
-
     fn fnv1a(bytes: &[u8]) -> u64 {
         let mut hasher = FnvHasher::default();
         hasher.write(bytes);
@@ -153,7 +140,7 @@
         (0..500).flat_map(|_| bytes.iter().cloned()).collect()
     }

-    //#[test]
+    #[test]
     fn basic_tests() {
         assert_eq!(fnv1a(b""), 0xcbf29ce484222325);
         assert_eq!(fnv1a(b"a"), 0xaf63dc4c8601ec8c);
mssun commented 4 years ago

Can you use the test template for the unit/functional tests? https://github.com/universal-secure-computing-community/crates-sgx/tree/sgx1.1.1/utils/sgx-tests-template

The new template removes some redundant header files, irrelevant code and provide a minimal framework.

sammyne commented 4 years ago

Check it again~ I have removed the redundant files now 😄 @mssun

mssun commented 4 years ago

Is you change based on https://github.com/servo/rust-fnv/tree/v1.0.6 (948b9d3b3e71743a2884165af6d18bfdc9095f76)? I found a lot differences.

sammyne commented 4 years ago

Is you change based on https://github.com/servo/rust-fnv/tree/v1.0.6 (948b9d3b3e71743a2884165af6d18bfdc9095f76)? I found a lot differences.

I have rebased on https://github.com/servo/rust-fnv/tree/v1.0.6 now~

sammyne commented 4 years ago

Now, another update as recommended~ @mssun

mssun commented 4 years ago

Can you verify that the utility files of sgx-tests are same with template? This is important because we want to make sure all crates are created in the same process and have similar structure.

sammyne commented 4 years ago

Can you verify that the utility files of sgx-tests are same with template? This is important because we want to make sure all crates are created in the same process and have similar structure.

Now, it should be consistent = = @mssun

mssun commented 4 years ago

Merged. Thanks!