rust-wasi-smoke-test: Support all wasi targets
* Updated script to test all the installed wasi targets * Updated tmt metadata to install the new wasip1 target when relevant * Moved nodejs dependency to tmt metadata on distro != rhel-8
This commit is contained in:
parent
7ff77ffed0
commit
1b22a7bf43
2 changed files with 48 additions and 29 deletions
|
|
@ -1,4 +1,5 @@
|
|||
summary: Compile and run a wasi app from rust
|
||||
description: Test the WASI targets currently shipped with rust
|
||||
require+:
|
||||
- rust-std-static-wasm32-wasi
|
||||
duration: 5m
|
||||
|
|
@ -9,14 +10,20 @@ link:
|
|||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1980080
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1980082
|
||||
adjust+:
|
||||
- because: "WASI target not supported in s390x"
|
||||
- because: "wasm32-wasip1 target added in rust 1.78"
|
||||
require+:
|
||||
- rust-std-static-wasm32-wasip1
|
||||
when: distro >= fedora-39,rhel-9.5,rhel-10
|
||||
|
||||
- because: "WASI target not supported in s390x older RHEL"
|
||||
enabled: false
|
||||
when: arch == s390x
|
||||
continue: false
|
||||
- because: "WASI target not shipped in RHEL older than 8"
|
||||
enabled: false
|
||||
when: distro < rhel-8
|
||||
when: arch == s390x and distro < rhel-9.5
|
||||
continue: false
|
||||
|
||||
- because: "nodejs needs to be installed differently in RHEL-8"
|
||||
require+:
|
||||
- "nodejs"
|
||||
when: distro != rhel-8
|
||||
extra-nitrate: TC#0612641
|
||||
extra-summary: /tools/rust/Sanity/rust-wasi-smoke-test
|
||||
extra-task: /tools/rust/Sanity/rust-wasi-smoke-test
|
||||
|
|
|
|||
|
|
@ -28,21 +28,28 @@
|
|||
# Include Beaker environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGES="$(rpm -qf $(which rustc)) rust-std-static-wasm32-wasi"
|
||||
PACKAGES="$(rpm -qf $(which rustc))"
|
||||
PACKAGES+=" $(rlGetYAMLdeps)"
|
||||
|
||||
# TMT will decide which targets to install depending on the distro/arch context.
|
||||
# Here we only check which ones were installed.
|
||||
ALL_TARGETS=(wasm32-wasi wasm32-wasip1 wasm32-wasip2)
|
||||
TEST_TARGETS=()
|
||||
for target in "${ALL_TARGETS[@]}"; do
|
||||
rpm -q rust-std-static-"$target" && TEST_TARGETS+=("$target")
|
||||
done
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm --all
|
||||
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
||||
# Because we need a specific nodejs version that supports WASI, we need
|
||||
# to install it explicitly here.
|
||||
# Because we need a specific nodejs version (>=16) that supports WASI.
|
||||
# In RHEL 8 we need to do it via modules, which tmt does not support,
|
||||
# so we need to do it right in the script.
|
||||
if rlIsRHEL 8; then
|
||||
# nodejs-16 has support for wasi.
|
||||
rlRun "yum -y module switch-to nodejs:16"
|
||||
rlRun "yum -y module install nodejs"
|
||||
else # RHEL > 8
|
||||
# We ship nodejs-16 in rhel-9.
|
||||
rlRun "yum -y install nodejs"
|
||||
fi
|
||||
# Example taken from WASI documentation:
|
||||
# https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-tutorial.md#from-rust
|
||||
|
|
@ -51,27 +58,32 @@ rlJournalStart
|
|||
rlRun "pushd $TmpDir"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "rustc --target wasm32-wasi demo.rs -o demo.wasm" 0 "Building WASI binary"
|
||||
rlAssertExists "demo.wasm"
|
||||
for target in "${TEST_TARGETS[@]}"; do
|
||||
rlPhaseStartTest "Target $target"
|
||||
rlRun "rustc --target $target demo.rs -o demo.wasm" 0 "Building WASI binary"
|
||||
rlAssertExists "demo.wasm"
|
||||
|
||||
### Test sandboxing
|
||||
### Test sandboxing
|
||||
|
||||
TESTSTR="This is a test string"
|
||||
rlRun "echo \"$TESTSTR\" > input.txt"
|
||||
TESTSTR="This is a test string"
|
||||
rlRun "echo \"$TESTSTR\" > input.txt"
|
||||
|
||||
# Test without preopening
|
||||
rlRun "node --experimental-wasi-unstable-preview1 wasi_test_no_preopen.js 2> node.out"
|
||||
rlAssertGrep "error opening" node.out
|
||||
rlAssertGrep "failed to find a pre-opened file descriptor" node.out
|
||||
rlAssertNotExists "output.txt"
|
||||
# Test without preopening
|
||||
rlRun "node --experimental-wasi-unstable-preview1 wasi_test_no_preopen.js 2> node.out"
|
||||
rlAssertGrep "error opening" node.out
|
||||
rlAssertGrep "failed to find a pre-opened file descriptor" node.out
|
||||
rlAssertNotExists "output.txt"
|
||||
|
||||
# Test with pre-opened directory
|
||||
rlRun "node --experimental-wasi-unstable-preview1 wasi_test_preopen.js 2> node.out"
|
||||
rlAssertNotGrep "error opening" node.out
|
||||
rlAssertExists "output.txt"
|
||||
rlAssertGrep "$TESTSTR" output.txt
|
||||
rlPhaseEnd
|
||||
# Test with pre-opened directory
|
||||
rlRun "node --experimental-wasi-unstable-preview1 wasi_test_preopen.js 2> node.out"
|
||||
rlAssertNotGrep "error opening" node.out
|
||||
rlAssertExists "output.txt"
|
||||
rlAssertGrep "$TESTSTR" output.txt
|
||||
|
||||
# Cleanup
|
||||
rlRun "rm -rf demo.wasm node.out output.txt"
|
||||
rlPhaseEnd
|
||||
done
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue