diff --git a/Cargo.lock b/Cargo.lock index cdfa00165f5..e8d5e47c213 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,12 +196,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" -[[package]] -name = "assert_matches" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" - [[package]] name = "assertables" version = "7.0.1" @@ -2858,7 +2852,6 @@ name = "oak_functions_sdk_abi_test_get_storage_item" version = "0.1.0" dependencies = [ "anyhow", - "assert_matches", "maplit", "oak_functions_abi", "oak_functions_sdk", diff --git a/Cargo_no_std.bazel.lock b/Cargo_no_std.bazel.lock index 710a63d35de..608fee20fd4 100644 --- a/Cargo_no_std.bazel.lock +++ b/Cargo_no_std.bazel.lock @@ -331,6 +331,7 @@ dependencies = [ "hkdf", "hpke", "log", + "maplit", "p256", "pkcs8", "primeorder", @@ -553,6 +554,12 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "opaque-debug" version = "0.3.1" diff --git a/bazel/crates/oak_crates_index.bzl b/bazel/crates/oak_crates_index.bzl index 862311bed06..03b9a4412db 100644 --- a/bazel/crates/oak_crates_index.bzl +++ b/bazel/crates/oak_crates_index.bzl @@ -15,7 +15,7 @@ # # """ - Defines the no_std crates repository. + Defines the std crates repository. After being defined, it should be loaded using: load("@oak_crates_index//:defs.bzl", oak_crate_repositories = "crate_repositories") diff --git a/bazel/crates/oak_no_std_crates_index.bzl b/bazel/crates/oak_no_std_crates_index.bzl index f6754803e64..79cd00214b7 100644 --- a/bazel/crates/oak_no_std_crates_index.bzl +++ b/bazel/crates/oak_no_std_crates_index.bzl @@ -120,6 +120,10 @@ def oak_no_std_crates_index(cargo_lockfile, lockfile): features = [], version = "*", ), + "maplit": crate.spec( + features = [], + version = "*", + ), "p256": crate.spec( default_features = False, features = [ diff --git a/cargo-no-std-bazel-lock.json b/cargo-no-std-bazel-lock.json index cb1a8f32c8f..f6df409e724 100644 --- a/cargo-no-std-bazel-lock.json +++ b/cargo-no-std-bazel-lock.json @@ -1,5 +1,5 @@ { - "checksum": "042c964203d897aec6bb490e61ab62d9385669207bd03993bc7c36a169556cc7", + "checksum": "8067eab2b6523b268748a8ef5c70a84c1e174a05ce66217c98cf679826c59bc0", "crates": { "acpi 5.0.0": { "name": "acpi", @@ -1976,6 +1976,10 @@ "id": "log 0.4.21", "target": "log" }, + { + "id": "maplit 1.0.2", + "target": "maplit" + }, { "id": "p256 0.13.2", "target": "p256" @@ -3314,6 +3318,45 @@ ], "license_file": "LICENSE-APACHE" }, + "maplit 1.0.2": { + "name": "maplit", + "version": "1.0.2", + "package_url": "https://github.com/bluss/maplit", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/maplit/1.0.2/download", + "sha256": "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + } + }, + "targets": [ + { + "Library": { + "crate_name": "maplit", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": false, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "maplit", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2015", + "version": "1.0.2" + }, + "license": "MIT/Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, "opaque-debug 0.3.1": { "name": "opaque-debug", "version": "0.3.1", @@ -6148,6 +6191,7 @@ "hkdf 0.12.4", "hpke 0.11.0", "log 0.4.21", + "maplit 1.0.2", "p256 0.13.2", "pkcs8 0.10.2", "primeorder 0.13.6", diff --git a/oak_functions_sdk/tests/lookup_module/BUILD b/oak_functions_sdk/tests/lookup_module/BUILD new file mode 100644 index 00000000000..79bf744919b --- /dev/null +++ b/oak_functions_sdk/tests/lookup_module/BUILD @@ -0,0 +1,36 @@ +# +# Copyright 2024 The Project Oak Authors +# +# Licensed 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. +# + +load("@rules_rust//rust:defs.bzl", "rust_shared_library") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +exports_files(["README.md"]) + +rust_shared_library( + name = "lookup_module", + srcs = glob(["src/*.rs"]), + platform = "//:wasm32-unknown-unknown", + deps = [ + "//oak_functions_abi", + "//oak_functions_sdk", + "@oak_no_std_crates_index//:anyhow", + "@oak_no_std_crates_index//:maplit", + ], +) diff --git a/oak_functions_sdk/tests/lookup_module/Cargo.toml b/oak_functions_sdk/tests/lookup_module/Cargo.toml index 67e1fa9a7f9..048deb38f55 100644 --- a/oak_functions_sdk/tests/lookup_module/Cargo.toml +++ b/oak_functions_sdk/tests/lookup_module/Cargo.toml @@ -11,6 +11,5 @@ crate-type = ["cdylib", "rlib"] [dependencies] anyhow = "*" maplit = "*" -assert_matches = "*" oak_functions_abi = { path = "../../../oak_functions_abi" } oak_functions_sdk = { path = "../../../oak_functions_sdk" } diff --git a/oak_functions_sdk/tests/lookup_module/src/lib.rs b/oak_functions_sdk/tests/lookup_module/src/lib.rs index c1ab5d5db25..d82a7b179cb 100644 --- a/oak_functions_sdk/tests/lookup_module/src/lib.rs +++ b/oak_functions_sdk/tests/lookup_module/src/lib.rs @@ -16,10 +16,12 @@ //! Oak Functions ABI test. +#![feature(assert_matches)] + +use core::assert_matches::assert_matches; use std::collections::HashMap; -use anyhow::{anyhow, Context}; -use assert_matches::assert_matches; +use anyhow::anyhow; use maplit::hashmap; type TestFn = fn(&str) -> (); @@ -46,7 +48,8 @@ impl TestManager<'static> { fn run_test(&self) -> anyhow::Result<()> { let request = oak_functions_sdk::read_request() .map_err(|error| anyhow!("couldn't read request: {:?}", error))?; - let test_name = String::from_utf8(request).context("couldn't parse request")?; + let test_name = String::from_utf8(request) + .map_err(|err| anyhow::anyhow!("couldn't parse request: {err}"))?; let test = self .tests .get(&test_name as &str) diff --git a/oak_functions_sdk/tests/testing_module/BUILD b/oak_functions_sdk/tests/testing_module/BUILD new file mode 100644 index 00000000000..0a34b5e90c3 --- /dev/null +++ b/oak_functions_sdk/tests/testing_module/BUILD @@ -0,0 +1,34 @@ +# +# Copyright 2024 The Project Oak Authors +# +# Licensed 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. +# + +load("@rules_rust//rust:defs.bzl", "rust_shared_library") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +exports_files(["README.md"]) + +rust_shared_library( + name = "testing_module", + srcs = glob(["src/*.rs"]), + platform = "//:wasm32-unknown-unknown", + deps = [ + "//oak_functions_abi", + "//oak_functions_sdk", + ], +)