Skip to content

Commit fb5cf3c

Browse files
committed
Unignore floating point tests
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 7ca0a78 commit fb5cf3c

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

Justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ tar-headers: (build-rust-capi) # build-rust-capi is a dependency because we need
314314
tar -zcvf include.tar.gz -C {{root}}/src/hyperlight_guest_bin/third_party/ musl/include musl/arch/x86_64 printf/printf.h -C {{root}}/src/hyperlight_guest_capi include
315315

316316
tar-static-lib: (build-rust-capi "release") (build-rust-capi "debug")
317-
tar -zcvf hyperlight-guest-c-api-linux.tar.gz -C {{root}}/target/x86_64-unknown-none/ release/libhyperlight_guest_capi.a -C {{root}}/target/x86_64-unknown-none/ debug/libhyperlight_guest_capi.a
317+
tar -zcvf hyperlight-guest-c-api-linux.tar.gz -C {{root}}/target/x86_64-hyperlight-none/ release/libhyperlight_guest_capi.a -C {{root}}/target/x86_64-hyperlight-none/ debug/libhyperlight_guest_capi.a
318318

319319
# Create release notes for the given tag. The expected format is a v-prefixed version number, e.g. v0.2.0
320320
# For prereleases, the version should be "dev-latest"

c.just

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ c-flags-release-elf := '-O3'
1111
build-c-guests target=default-target: (build-rust-capi target) (compile-c-guest target) (link-c-guest target)
1212

1313
build-rust-capi target=default-target:
14-
cd src/hyperlight_guest_capi && cargo build --profile {{ if target == "debug" { "dev" } else { target } }}
14+
cd src/hyperlight_guest_capi && cargo hyperlight build --profile {{ if target == "debug" { "dev" } else { target } }}
1515

1616
compile-c-guest target=default-target:
1717
# elf
1818
cd src/tests/c_guests/c_simpleguest && {{ mkdir }} "./out/{{target}}" && clang -c {{ c-compile-options-elf }} {{ if target == "debug" { c-flags-debug-elf } else { c-flags-release-elf } }} main.c {{c-include-flags-elf}} -o "out/{{ target }}/main.o"
1919

2020
link-c-guest target=default-target:
2121
# elf
22-
cd src/tests/c_guests/c_simpleguest && ld.lld -o out/{{target}}/simpleguest {{c-linker-options-elf}} out/{{target}}/main.o -l hyperlight_guest_capi -L "{{justfile_directory()}}/target/x86_64-unknown-none/{{target}}"
22+
cd src/tests/c_guests/c_simpleguest && ld.lld -o out/{{target}}/simpleguest {{c-linker-options-elf}} out/{{target}}/main.o -l hyperlight_guest_capi -L "{{justfile_directory()}}/target/x86_64-hyperlight-none/{{target}}"
2323

2424
move-c-guests target=default-target:
2525
# elf

src/hyperlight_guest_capi/.cargo/config.toml

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/hyperlight_host/tests/sandbox_host_tests.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ fn pass_byte_array() {
4545
}
4646

4747
#[test]
48-
#[ignore = "Fails with mismatched float only when c .exe guest?!"]
4948
fn float_roundtrip() {
5049
let doubles = [
5150
0.0,
@@ -83,8 +82,11 @@ fn float_roundtrip() {
8382
for f in doubles.iter() {
8483
let res: f64 = sandbox.call("EchoDouble", *f).unwrap();
8584

85+
// Use == for comparison (handles -0.0 == 0.0) with special case for NaN.
86+
// Note: FlatBuffers doesn't preserve -0.0 (-0.0 round-trips to 0.0) because FlatBuffers skips
87+
// storing values equal to the default (as an optimization), and -0.0 == 0.0 in IEEE 754.
8688
assert!(
87-
res.total_cmp(f).is_eq(),
89+
(res.is_nan() && f.is_nan()) || res == *f,
8890
"Expected {:?} but got {:?}",
8991
f,
9092
res
@@ -93,8 +95,11 @@ fn float_roundtrip() {
9395
for f in floats.iter() {
9496
let res: f32 = sandbox.call("EchoFloat", *f).unwrap();
9597

98+
// Use == for comparison (handles -0.0 == 0.0) with special case for NaN.
99+
// Note: FlatBuffers doesn't preserve -0.0 (it returns 0.0) because it skips
100+
// storing values equal to the default, and -0.0 == 0.0 in IEEE 754.
96101
assert!(
97-
res.total_cmp(f).is_eq(),
102+
(res.is_nan() && f.is_nan()) || res == *f,
98103
"Expected {:?} but got {:?}",
99104
f,
100105
res

src/tests/rust_guests/witguest/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)