Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sw/device/tests/crypto/cryptotest/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ SHAKE128_TESTVECTOR_ARGS = " ".join([

cryptotest(
name = "shake128_kat",
fpga_timeout = "eternal",
slow_test = True,
test_args = SHAKE128_TESTVECTOR_ARGS,
test_harness = "//sw/host/tests/crypto/hash_kat:harness",
Expand All @@ -305,6 +306,7 @@ SHAKE256_TESTVECTOR_ARGS = " ".join([

cryptotest(
name = "shake256_kat",
fpga_timeout = "eternal",
slow_test = True,
test_args = SHAKE256_TESTVECTOR_ARGS,
test_harness = "//sw/host/tests/crypto/hash_kat:harness",
Expand Down
15 changes: 11 additions & 4 deletions sw/device/tests/crypto/cryptotest/cryptotest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ FIRMWARE_DEPS = [
"//sw/device/tests/crypto/cryptotest/json:commands",
]

def cryptotest(name, test_vectors, test_args, test_harness, slow_test = False):
def cryptotest(
name,
test_vectors,
test_args,
test_harness,
slow_test = False,
fpga_timeout = "long",
silicon_timeout = "eternal"):
"""A macro for defining a CryptoTest test case.

Args:
Expand All @@ -62,7 +69,7 @@ def cryptotest(name, test_vectors, test_args, test_harness, slow_test = False):
name = name,
srcs = ["//sw/device/tests/crypto/cryptotest/firmware:firmware.c"],
fpga = fpga_params(
timeout = "long",
timeout = fpga_timeout,
data = test_vectors,
tags = tags,
test_cmd = """
Expand All @@ -71,7 +78,7 @@ def cryptotest(name, test_vectors, test_args, test_harness, slow_test = False):
test_harness = test_harness,
),
fpga_cw340 = fpga_params(
timeout = "long",
timeout = fpga_timeout,
tags = tags,
data = test_vectors,
test_cmd = """
Expand All @@ -81,7 +88,7 @@ def cryptotest(name, test_vectors, test_args, test_harness, slow_test = False):
),
exec_env = CRYPTOTEST_EXEC_ENVS,
silicon = silicon_params(
timeout = "eternal",
timeout = silicon_timeout,
tags = tags,
data = test_vectors,
test_cmd = """
Expand Down
8 changes: 4 additions & 4 deletions sw/host/tests/chip/pwm_smoketest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ fn test_clock_and_duty_cycle(
period_error * 100.0
);

let duty_error = (average_duty - duty_cycle).abs() / duty_cycle;
let duty_error = (average_duty - duty_cycle).abs();
println!(
"Pwm average duty: {}%, expected: {}, err: {}%",
"Pwm average duty: {}%, expected: {}, err: {}",
average_duty,
duty_cycle,
duty_error * 100.0
duty_error,
);

// The error is explained by the possible values that the clk_div can assume.
assert!(period_error < 0.02);
assert!(duty_error < 0.01);
assert!(duty_error < 1.0);

Ok(())
}
Expand Down
Loading