Skip to content

Commit

Permalink
Add missing targets for Rust unit tests
Browse files Browse the repository at this point in the history
BUG: 334941229
Change-Id: I25b57a3c6df79a21aa1daeef0dd7d012b57306f5
  • Loading branch information
ernoc committed Jul 15, 2024
1 parent 5811410 commit 9c87c7a
Show file tree
Hide file tree
Showing 23 changed files with 268 additions and 35 deletions.
1 change: 1 addition & 0 deletions Cargo.bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ dependencies = [
"opentelemetry-otlp",
"opentelemetry-proto 0.6.0",
"opentelemetry_sdk 0.22.1",
"os_pipe",
"ouroboros",
"p256",
"p384",
Expand Down
2 changes: 1 addition & 1 deletion FORCE_CI
Original file line number Diff line number Diff line change
@@ -1 +1 @@
36
37
1 change: 1 addition & 0 deletions bazel/crates/oak_crates_index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def oak_crates_index(cargo_lockfile, lockfile):
],
version = "0.22.1",
),
"os_pipe": crate.spec(version = "*"),
"ouroboros": crate.spec(version = "*"),
"portpicker": crate.spec(version = "*"),
"p256": crate.spec(
Expand Down
12 changes: 12 additions & 0 deletions bazel/test_workspace/Cargo-test.bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,16 @@ dependencies = [
"tokio",
]

[[package]]
name = "command-group"
version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a68fa787550392a9d58f44c21a3022cfb3ea3e2458b7f85d3b399d0ceeccf409"
dependencies = [
"nix 0.27.1",
"winapi",
]

[[package]]
name = "const-default"
version = "1.0.0"
Expand Down Expand Up @@ -1071,6 +1081,7 @@ dependencies = [
"clap_complete",
"colored",
"command-fds",
"command-group",
"coset",
"criterion",
"criterion-macro",
Expand Down Expand Up @@ -1104,6 +1115,7 @@ dependencies = [
"opentelemetry-otlp",
"opentelemetry-proto 0.6.0",
"opentelemetry_sdk 0.22.1",
"os_pipe",
"ouroboros",
"p256",
"p384",
Expand Down
80 changes: 78 additions & 2 deletions bazel/test_workspace/cargo-bazel-test-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "7ab5cd9ce27d8d8fb2eeb0d636d2ad59d34eaaa6cd571e31f5a1a5aef9cf70a0",
"checksum": "caa064aaf8742a3fe2995442765f12fcc2adb7db82addd9e0affc2417b887a42",
"crates": {
"acpi 5.0.0": {
"name": "acpi",
Expand Down Expand Up @@ -3714,6 +3714,68 @@
],
"license_file": "LICENSE"
},
"command-group 5.0.1": {
"name": "command-group",
"version": "5.0.1",
"package_url": "https://github.com/watchexec/command-group",
"repository": {
"Http": {
"url": "https://static.crates.io/crates/command-group/5.0.1/download",
"sha256": "a68fa787550392a9d58f44c21a3022cfb3ea3e2458b7f85d3b399d0ceeccf409"
}
},
"targets": [
{
"Library": {
"crate_name": "command_group",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"include": [
"**/*.rs"
]
}
}
}
],
"library_target_name": "command_group",
"common_attrs": {
"compile_data_glob": [
"**"
],
"crate_features": {
"common": [
"default"
],
"selects": {}
},
"deps": {
"common": [],
"selects": {
"cfg(unix)": [
{
"id": "nix 0.27.1",
"target": "nix"
}
],
"cfg(windows)": [
{
"id": "winapi 0.3.9",
"target": "winapi"
}
]
}
},
"edition": "2021",
"version": "5.0.1"
},
"license": "Apache-2.0 OR MIT",
"license_ids": [
"Apache-2.0",
"MIT"
],
"license_file": "LICENSE-APACHE"
},
"const-default 1.0.0": {
"name": "const-default",
"version": "1.0.0",
Expand Down Expand Up @@ -6466,6 +6528,10 @@
"id": "command-fds 0.3.0",
"target": "command_fds"
},
{
"id": "command-group 5.0.1",
"target": "command_group"
},
{
"id": "coset 0.3.7",
"target": "coset"
Expand Down Expand Up @@ -6594,6 +6660,10 @@
"id": "opentelemetry_sdk 0.22.1",
"target": "opentelemetry_sdk"
},
{
"id": "os_pipe 1.2.0",
"target": "os_pipe"
},
{
"id": "ouroboros 0.18.4",
"target": "ouroboros"
Expand Down Expand Up @@ -13809,7 +13879,11 @@
"uio",
"user"
],
"selects": {}
"selects": {
"x86_64-unknown-linux-gnu": [
"poll"
]
}
},
"deps": {
"common": [
Expand Down Expand Up @@ -31275,6 +31349,7 @@
"clap_complete 4.5.7",
"colored 2.1.0",
"command-fds 0.3.0",
"command-group 5.0.1",
"coset 0.3.7",
"criterion 0.5.1",
"criterion-macro 0.4.0",
Expand Down Expand Up @@ -31308,6 +31383,7 @@
"opentelemetry-otlp 0.15.0",
"opentelemetry-proto 0.6.0",
"opentelemetry_sdk 0.22.1",
"os_pipe 1.2.0",
"ouroboros 0.18.4",
"p256 0.13.2",
"p384 0.13.0",
Expand Down
7 changes: 6 additions & 1 deletion cargo-bazel-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "c8419db8f6a1f07175d84d2971eae3dd0969acce2ac9bfe24efb3b3417ae6d8b",
"checksum": "d4d2e1d93bb189e8cbeb8e9d140fbb6358c27f1b7ebccc310bea41cdd4003452",
"crates": {
"acpi 5.0.0": {
"name": "acpi",
Expand Down Expand Up @@ -6654,6 +6654,10 @@
"id": "opentelemetry_sdk 0.22.1",
"target": "opentelemetry_sdk"
},
{
"id": "os_pipe 1.2.0",
"target": "os_pipe"
},
{
"id": "ouroboros 0.18.4",
"target": "ouroboros"
Expand Down Expand Up @@ -31390,6 +31394,7 @@
"opentelemetry-otlp 0.15.0",
"opentelemetry-proto 0.6.0",
"opentelemetry_sdk 0.22.1",
"os_pipe 1.2.0",
"ouroboros 0.18.4",
"p256 0.13.2",
"p384 0.13.0",
Expand Down
20 changes: 19 additions & 1 deletion oak_attestation_verification/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

load("@rules_rust//rust:defs.bzl", "rust_library")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")

package(
default_visibility = ["//visibility:public"],
Expand Down Expand Up @@ -51,6 +51,15 @@ rust_library(
],
)

rust_test(
name = "oak_attestation_verification_test",
crate = ":oak_attestation_verification",
crate_features = ["bazel"], # TODO: b/333064338 remove.
data = [
"//oak_attestation_verification/testdata:endorsement.json",
],
)

rust_library(
name = "oak_attestation_verification_with_regex",
srcs = glob(["src/**"]),
Expand Down Expand Up @@ -82,3 +91,12 @@ rust_library(
"@oak_crates_index//:zerocopy",
],
)

rust_test(
name = "oak_attestation_verification_with_reged_test",
crate = ":oak_attestation_verification_with_regex",
crate_features = ["bazel"], # TODO: b/333064338 remove.
data = [
"//oak_attestation_verification/testdata:endorsement.json",
],
)
3 changes: 3 additions & 0 deletions oak_attestation_verification/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ mod tests {
use super::get_digest;
use crate::claims::{parse_endorsement_statement, validate_endorsement};

#[cfg(feature = "bazel")]
const ENDORSEMENT_PATH: &str = "oak_attestation_verification/testdata/endorsement.json";
#[cfg(not(feature = "bazel"))]
const ENDORSEMENT_PATH: &str = "testdata/endorsement.json";

#[test]
Expand Down
7 changes: 6 additions & 1 deletion oak_channel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

load("@rules_rust//rust:defs.bzl", "rust_library")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")

package(
default_visibility = ["//visibility:public"],
Expand Down Expand Up @@ -46,6 +46,11 @@ rust_library(
deps = _OAK_CHANNEL_DEPS,
)

rust_test(
name = "oak_channel_test",
crate = ":oak_channel",
)

rust_library(
name = "oak_channel_client",
srcs = glob(["src/**"]),
Expand Down
12 changes: 11 additions & 1 deletion oak_crypto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

load("@rules_rust//rust:defs.bzl", "rust_library")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel:defs.bzl", "either_platform")

package(
Expand Down Expand Up @@ -72,3 +72,13 @@ rust_library(
],
}),
)

rust_test(
name = "oak_crypto_test",
size = "small",
crate = ":oak_crypto",
deps = [
"@oak_crates_index//:hex",
"@oak_crates_index//:tokio",
],
)
8 changes: 7 additions & 1 deletion oak_functions_launcher/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")

package(
default_visibility = ["//visibility:public"],
Expand Down Expand Up @@ -51,6 +51,12 @@ rust_library(
],
)

rust_test(
name = "oak_functions_launcher_test",
size = "small",
crate = ":lib",
)

rust_binary(
name = "oak_functions_launcher",
srcs = ["src/main.rs"],
Expand Down
50 changes: 42 additions & 8 deletions oak_functions_service/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# limitations under the License.
#

load("@rules_rust//rust:defs.bzl", "rust_library")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel:defs.bzl", "either_platform")

package(
default_visibility = ["//visibility:public"],
Expand All @@ -31,24 +32,57 @@ DEPS = [
"@oak_no_std_crates_index//:prost",
"@oak_no_std_crates_index//:rand_core",
"@oak_no_std_crates_index//:wasmi",
]
] + select({
"@platforms//os:none": [
"@oak_no_std_crates_index//:prost",
],
"//conditions:default": [
"@oak_crates_index//:prost",
],
})

rust_library(
name = "oak_functions_service",
srcs = glob(["src/**"]),
# The features are inverted on purpose; this means the "default" package will not have sensitive logging enabled.
crate_features = ["deny_sensitive_logging"],
target_compatible_with = [
"@platforms//os:none",
],
target_compatible_with = either_platform([
"//:x86_64-none-setting",
"//:x86_64-linux-setting", # Needed to run unit tests.
]),
deps = DEPS,
)

rust_test(
name = "oak_functions_service_test",
crate = ":oak_functions_service",
crate_features = ["bazel"], # TODO: b/333064338 remove.
data = ["//oak_functions/examples/echo"],
deps = [
"//oak_functions_test_utils",
"@oak_crates_index//:bytes",
"@oak_crates_index//:prost",
],
)

rust_library(
name = "oak_functions_service_allow_sensitive_logging",
srcs = glob(["src/**"]),
target_compatible_with = [
"@platforms//os:none",
],
target_compatible_with = either_platform([
"//:x86_64-none-setting",
"//:x86_64-linux-setting", # Needed to run unit tests.
]),
deps = DEPS,
)

rust_test(
name = "oak_functions_service_allow_sensitive_logging_test",
crate = ":oak_functions_service_allow_sensitive_logging",
crate_features = ["bazel"], # TODO: b/333064338 remove.
data = ["//oak_functions/examples/echo"],
deps = [
"//oak_functions_test_utils",
"@oak_crates_index//:bytes",
"@oak_crates_index//:prost",
],
)
Loading

0 comments on commit 9c87c7a

Please sign in to comment.