Skip to content
Open
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
55 changes: 53 additions & 2 deletions .github/workflows/daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,55 @@ jobs:
. "$HOME/.cargo/env"
cargo build --locked --all-targets && cargo test --locked && cargo test --locked -- --ignored stress && cargo test --locked -p noq-udp --benches

test-fuchsia:
# noq-udp's tests on a Fuchsia emulator (x64, KVM), each test executable
# as a test component; see fuchsia-run-tests-on-emulator.sh
timeout-minutes: 45
name: test noq-udp on fuchsia
runs-on: ubuntu-latest
env:
FUCHSIA_SDK_VERSION: "34.20261204.5.1"
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
persist-credentials: false

- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # v1
with:
toolchain: stable
targets: x86_64-unknown-fuchsia

- name: Download the Fuchsia SDK
run: |
sdk="$RUNNER_TEMP/fuchsia-sdk"
curl -sSfL -o "$RUNNER_TEMP/sdk.zip" \
"https://chrome-infra-packages.appspot.com/dl/fuchsia/sdk/core/linux-amd64/+/version:$FUCHSIA_SDK_VERSION"
# The x64 tools, sysroot and libraries are enough; the rest is most of its 9 GB.
# The emulator is aemu_internal (it boots with qemu_uefi_internal's firmware), so
# qemu_internal is left out as well.
unzip -q "$RUNNER_TEMP/sdk.zip" -d "$sdk" \
-x 'obj/*' 'packages/*' 'arch/arm64/*' 'arch/riscv64/*' 'tools/arm64/*' 'tools/x64/qemu_internal/*'
rm "$RUNNER_TEMP/sdk.zip"
echo "FUCHSIA_SDK=$sdk" >>"$GITHUB_ENV"
echo "RUSTFLAGS=$RUSTFLAGS -Lnative=$sdk/arch/x64/sysroot/lib -Lnative=$sdk/arch/x64/lib" >>"$GITHUB_ENV"

- name: Build noq-udp's tests for Fuchsia
run: cargo test --locked -p noq-udp --target x86_64-unknown-fuchsia --no-run

- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Run noq-udp's tests on the Fuchsia emulator
env:
FUCHSIA_WORK: ${{ runner.temp }}/fx
run: |
tests=$(cargo test --locked -p noq-udp --target x86_64-unknown-fuchsia --no-run --message-format=json \
| jq -r 'select(.executable != null and .profile.test) | .executable')
.github/workflows/fuchsia-run-tests-on-emulator.sh $tests

features:
name: Feature powerset check
timeout-minutes: 60
Expand Down Expand Up @@ -177,7 +226,7 @@ jobs:

notify:
timeout-minutes: 45
needs: [proptests, test-freebsd, build-solaris, test-illumos, features]
needs: [proptests, test-freebsd, build-solaris, test-illumos, test-fuchsia, features]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
Expand All @@ -191,10 +240,11 @@ jobs:
freebsd_result=$(echo "$NEEDS_JSON" | jq -r '.["test-freebsd"].result')
solaris_result=$(echo "$NEEDS_JSON" | jq -r '.["build-solaris"].result')
illumos_result=$(echo "$NEEDS_JSON" | jq -r '.["test-illumos"].result')
fuchsia_result=$(echo "$NEEDS_JSON" | jq -r '.["test-fuchsia"].result')
features_result=$(echo "$NEEDS_JSON" | jq -r '.features.result')

# Check if any failed
if [ "$proptests_result" = "failure" ] || [ "$freebsd_result" = "failure" ] || [ "$solaris_result" = "failure" ] || [ "$illumos_result" = "failure" ] || [ "$features_result" = "failure" ]; then
if [ "$proptests_result" = "failure" ] || [ "$freebsd_result" = "failure" ] || [ "$solaris_result" = "failure" ] || [ "$illumos_result" = "failure" ] || [ "$fuchsia_result" = "failure" ] || [ "$features_result" = "failure" ]; then
echo "TESTS_RESULT=failure" >>"$GITHUB_ENV"
else
echo "TESTS_RESULT=success" >>"$GITHUB_ENV"
Expand All @@ -206,6 +256,7 @@ jobs:
[ "$freebsd_result" = "failure" ] && details="${details}- FreeBSD tests failed\n"
[ "$solaris_result" = "failure" ] && details="${details}- Solaris build failed\n"
[ "$illumos_result" = "failure" ] && details="${details}- Illumos tests failed\n"
[ "$fuchsia_result" = "failure" ] && details="${details}- Fuchsia tests failed\n"
[ "$features_result" = "failure" ] && details="${details}- Feature powerset check failed\n"

echo "FAILURE_DETAILS<<EOF" >>"$GITHUB_ENV"
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/fuchsia-run-tests-on-emulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
# Runs test executables on a Fuchsia emulator, each as a test component of its
# own through `ffx test run`.
#
# Usage: fuchsia-run-tests-on-emulator.sh TEST_EXECUTABLE...
#
# FUCHSIA_SDK is an unpacked Fuchsia core SDK. The emulator runs the minimal
# product of the same version, downloaded here. FUCHSIA_WORK is where the
# product, the package repository and ffx's state go; keep it short, as qemu
# takes sockets under it.
set -euo pipefail

sdk=${FUCHSIA_SDK:?set FUCHSIA_SDK to an unpacked Fuchsia core SDK}
work=${FUCHSIA_WORK:-/tmp/fx}
if [[ $# -eq 0 ]]; then
echo "no test executables given" >&2
exit 1
fi

mkdir -p "$work/home" "$work/isolate" "$work/pkg"
export HOME="$work/home" FFX_ISOLATE_DIR="$work/isolate"
ffx() { "$sdk/tools/x64/ffx" "$@"; }
json() { python3 -c "import json, sys; print(json.load(sys.stdin)$1)"; }

ffx config analytics disable >/dev/null
ffx config set log.dir "$work/log"

version=$(json '["id"]' <"$sdk/meta/manifest.json")
url=$(ffx --machine json product lookup minimal.x64 "$version" \
--base-url "gs://fuchsia/development/$version" | json '["transfer_manifest_url"]')
ffx product download "$url" "$work/product"

ffx emu start "$work/product" --headless --net user --accel auto --log "$work/emulator.log"
trap 'ffx emu stop --all || true; ffx repository server stop --all || true' EXIT

repo=noq-tests
ffx repository create "$work/repo"
ffx repository server start --background --address '[::]:0' --repo-path "$work/repo" --repository "$repo"
ffx target repository register --repository "$repo"
api_level=$(ffx --machine json version | json '["tool_version"]["api_level"]')

any_failures=0
for test in "$@"; do
# Package names take lowercase letters, digits, `-`, `_` and `.`: drop
# cargo's hash suffix, the rest of a crate's name fits.
name=$(basename "$test" | sed 's/-[0-9a-f]*$//' | tr '[:upper:]' '[:lower:]')
pkg="$work/pkg/$name"
mkdir -p "$pkg/meta"
printf '{"name": "%s", "version": "0"}\n' "$name" >"$pkg/meta/package"
# elf_test_runner passes the suite when the binary exits with 0. A system
# test may use the system's netstack, which the tests' sockets need.
cat >"$pkg/$name.cml" <<EOF
{
program: {
runner: "elf_test_runner",
binary: "bin/$name",
args: [ "--test-threads=1" ],
environ: [ "RUST_BACKTRACE=1" ],
},
capabilities: [
{ protocol: "fuchsia.test.Suite" },
],
expose: [
{ protocol: "fuchsia.test.Suite", from: "self" },
],
use: [
{ protocol: [ "fuchsia.posix.socket.Provider", "fuchsia.process.Launcher" ] },
],
facets: {
"fuchsia.test": { type: "system" },
},
}
EOF
"$sdk/tools/x64/cmc" compile "$pkg/$name.cml" --includepath "$pkg" -o "$pkg/meta/$name.cm"
cat >"$pkg/manifest" <<EOF
bin/$name=$test
lib/ld.so.1=$sdk/arch/x64/sysroot/dist/lib/ld.so.1
lib/libfdio.so=$sdk/arch/x64/dist/libfdio.so
meta/package=$pkg/meta/package
meta/$name.cm=$pkg/meta/$name.cm
EOF
ffx package build "$pkg/manifest" -o "$pkg/out" --api-level "$api_level"
ffx repository publish --package "$pkg/out/package_manifest.json" "$work/repo"
ffx test run "fuchsia-pkg://$repo/$name#meta/$name.cm" || any_failures=1
done

exit $any_failures
2 changes: 1 addition & 1 deletion noq-udp/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ fn main() {
apple_slow: { all(apple, not(feature = "fast-apple-datapath")) },
wasm_browser: { all(target_family = "wasm", target_os = "unknown") },
// Platforms that lack advanced socket APIs (cmsg, recvmmsg, etc.)
posix_minimal: { any(target_os = "espidf", target_os = "wasi") },
posix_minimal: { any(target_os = "espidf", target_os = "wasi", target_os = "fuchsia") },
}
}