Skip to content

Commit 4ac82da

Browse files
committed
Update sample guests to accept features that enable tracing
- Update CI to test the tracing functionality - Add features for the Justfile to be able to build guests with features Signed-off-by: Doru Blânzeanu <[email protected]>
1 parent 1dea1fd commit 4ac82da

File tree

10 files changed

+391
-41
lines changed

10 files changed

+391
-41
lines changed

.github/workflows/dep_rust.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ jobs:
137137
cargo check -p hyperlight-host --features crashdump
138138
cargo check -p hyperlight-host --features print_debug
139139
cargo check -p hyperlight-host --features gdb
140+
cargo check -p hyperlight-host --features trace_guest,unwind_guest,mem_profile
140141
141142
# without any features
142143
just test-compilation-no-default-features ${{ matrix.config }}
@@ -169,6 +170,13 @@ jobs:
169170
RUST_LOG: debug
170171
run: just test-rust-crashdump ${{ matrix.config }} ${{ matrix.hypervisor == 'mshv' && 'mshv2' || ''}}
171172

173+
- name: Run Rust Tracing tests - linux
174+
if: runner.os == 'Linux'
175+
env:
176+
CARGO_TERM_COLOR: always
177+
RUST_LOG: debug
178+
run: just test-rust-tracing ${{ matrix.config }} ${{ matrix.hypervisor == 'mshv2' && 'mshv2' || ''}}
179+
172180
- name: Download benchmarks from "latest"
173181
run: just bench-download ${{ runner.os }} ${{ matrix.hypervisor }} ${{ matrix.cpu}} dev-latest # compare to prerelease
174182
env:

Justfile

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ witguest-wit:
3838
cargo install --locked wasm-tools
3939
cd src/tests/rust_guests/witguest && wasm-tools component wit guest.wit -w -o interface.wasm
4040

41-
build-rust-guests target=default-target: (witguest-wit)
42-
cd src/tests/rust_guests/callbackguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
43-
cd src/tests/rust_guests/simpleguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
44-
cd src/tests/rust_guests/dummyguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
45-
cd src/tests/rust_guests/witguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
41+
build-rust-guests target=default-target features="": (witguest-wit)
42+
cd src/tests/rust_guests/callbackguest && cargo build {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" { "dev" } else { target } }}
43+
cd src/tests/rust_guests/simpleguest && cargo build {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" { "dev" } else { target } }}
44+
cd src/tests/rust_guests/dummyguest && cargo build {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" { "dev" } else { target } }}
45+
cd src/tests/rust_guests/witguest && cargo build {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" { "dev" } else { target } }}
4646

4747
@move-rust-guests target=default-target:
4848
cp {{ callbackguest_source }}/{{ target }}/callbackguest* {{ rust_guests_bin_dir }}/{{ target }}/
@@ -82,13 +82,17 @@ test-like-ci config=default-target hypervisor="kvm":
8282
cargo check -p hyperlight-host --features crashdump
8383
cargo check -p hyperlight-host --features print_debug
8484
cargo check -p hyperlight-host --features gdb
85+
cargo check -p hyperlight-host --features trace_guest,unwind_guest,mem_profile
8586

8687
@# without any driver (should fail to compile)
8788
just test-compilation-no-default-features {{config}}
8889

8990
@# test the crashdump feature
9091
just test-rust-crashdump {{config}}
9192

93+
@# test the tracing related features
94+
just test-rust-tracing {{config}} {{ if hypervisor == "mshv3" {"mshv3"} else {""} }}
95+
9296
# runs all tests
9397
test target=default-target features="": (test-unit target features) (test-isolated target features) (test-integration "rust" target features) (test-integration "c" target features) (test-seccomp target features)
9498

@@ -141,6 +145,25 @@ test-rust-gdb-debugging target=default-target features="":
141145
test-rust-crashdump target=default-target features="":
142146
cargo test --profile={{ if target == "debug" { "dev" } else { target } }} {{ if features =="" {'--features crashdump'} else { "--features crashdump," + features } }} -- test_crashdump
143147

148+
# rust test for tracing
149+
test-rust-tracing target=default-target features="":
150+
# Run tests for the tracing guest and macro
151+
cargo test -p hyperlight-guest-tracing --profile={{ if target == "debug" { "dev" } else { target } }}
152+
cargo test -p hyperlight-guest-tracing-macro --profile={{ if target == "debug" { "dev" } else { target } }}
153+
154+
# Prepare the tracing guest for testing
155+
just build-rust-guests {{ target }} trace_guest
156+
just move-rust-guests {{ target }}
157+
# Run hello-world example with tracing enabled to get the trace output
158+
# Capture the trace file path and print use it afterwards to run cargo run -p trace_dump
159+
cargo run --profile={{ if target == "debug" { "dev" } else { target } }} --example hello-world --features {{ if features =="" {'trace_guest'} else { "trace_guest," + features } }} \
160+
| sed -n 's/.*Creating trace file at: \(.*\)/\1/p' \
161+
| xargs -I {} cargo run -p trace_dump ./{{ simpleguest_source }}/{{ target }}/simpleguest {} list_frames
162+
163+
# Rebuild the tracing guests without the tracing feature
164+
# This is to ensure that the tracing feature does not affect the other tests
165+
just build-rust-guests {{ target }}
166+
just move-rust-guests {{ target }}
144167

145168
################
146169
### LINTING ####

src/tests/rust_guests/callbackguest/Cargo.lock

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

src/tests/rust_guests/callbackguest/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ edition = "2021"
66
[dependencies]
77
hyperlight-guest = { path = "../../../hyperlight_guest" }
88
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin" }
9-
hyperlight-common = { path = "../../../hyperlight_common", default-features = false }
9+
hyperlight-common = { path = "../../../hyperlight_common", default-features = false }
10+
11+
[features]
12+
default = []
13+
trace_guest = ["hyperlight-guest-bin/trace_guest"]
14+
unwind_guest = ["hyperlight-common/unwind_guest"]
15+
mem_profile = ["hyperlight-common/mem_profile", "hyperlight-guest-bin/mem_profile"]

0 commit comments

Comments
 (0)