tests: fix execution on WSL2, Ubuntu 24.04 (#8235)

* tests: fix execution on WSL2, Ubuntu 24.04

Skip incompatible parts of tests to ensure that
    cargo nextest run --features unix
executes successfully in WSL2, Ubuntu 24.04 distribution.

Changes
* Skip tests that required sys/kernel/profiling which is not
available in WSL2 default configuration.
* Use timezones in tests that are part of the standard tzdata
list and not only available in backwards list. Backwards list is
not installed by default in Ubuntu 24.04 (package tzdata-legacy).
* check that /proc/modules is not empty when expecting content,
because it is empty in WSL2 default configuration.
* Skip logname test not only in WSL1, also in WSL2.

* Add workflow for WSL2

This will setup WSL2 on windows-latest runner, install
Ubuntu-24.04, and run the feat_os_unix tests.

* wsl2: implemented review findings

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
This commit is contained in:
Martin Kunkel 2025-08-03 14:38:49 +02:00 committed by GitHub
parent cf796758be
commit 3b4b769976
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 120 additions and 10 deletions

69
.github/workflows/wsl2.yml vendored Normal file
View file

@ -0,0 +1,69 @@
name: WSL2
# spell-checker:ignore nextest noprofile norc
on:
pull_request:
push:
branches:
- '*'
permissions:
contents: read # to fetch code (actions/checkout)
# End the current execution if there is a new changeset in the PR.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
test:
name: Test
runs-on: ${{ matrix.job.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
job:
- { os: windows-latest, distribution: Ubuntu-24.04, features: feat_os_unix}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install WSL2
uses: Vampire/setup-wsl@v6.0.0
with:
additional-packages: build-essential
distribution: ${{ matrix.job.distribution }}
use-cache: 'true'
wsl-version: 2
- name: Set up WSL2 user
shell: wsl-bash {0}
run: |
useradd -m -p password user
- name: Set up WSL2 shell command
uses: Vampire/setup-wsl@v6.0.0
with:
distribution: ${{ matrix.job.distribution }}
wsl-shell-command: bash -c "sudo -u user bash --noprofile --norc -euo pipefail '{0}'"
# it is required to use WSL2's linux file system, so we do a second checkout there
- name: Checkout source in WSL2
shell: wsl-bash {0}
run: |
git clone "$(pwd)" "$HOME/src"
- name: Install rust and nextest
shell: wsl-bash {0}
run: |
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --profile=minimal
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C "$HOME/.cargo/bin"
- name: Test
shell: wsl-bash {0}
run: |
cd "$HOME/src"
# chmod tests expect umask 0022
umask 0022
. "$HOME/.cargo/env"
export CARGO_TERM_COLOR=always
export RUST_BACKTRACE=1
cargo nextest run --hide-progress-bar --profile ci --features '${{ matrix.job.features }}'