Skip to content

tests: fix execution on WSL2, Ubuntu 24.04#8235

Merged
sylvestre merged 4 commits intouutils:mainfrom
martinkunkel2:wsl2_test_compatibility
Aug 3, 2025
Merged

tests: fix execution on WSL2, Ubuntu 24.04#8235
sylvestre merged 4 commits intouutils:mainfrom
martinkunkel2:wsl2_test_compatibility

Conversation

@martinkunkel2
Copy link
Contributor

I tried to run

cargo nextest run --features unix

in WSL2, which results in a few failing tests

     Summary [  53.695s] 3949 tests run: 3939 passed, 10 failed, 46 skipped
        FAIL [   0.029s] coreutils::tests test_cp::test_cp_debug_default_sparse_virtual_file
        FAIL [   0.045s] coreutils::tests test_cp::test_cp_debug_sparse_always_sparse_virtual_file
        FAIL [   0.057s] coreutils::tests test_cp::test_cp_default_virtual_file
        FAIL [   0.356s] coreutils::tests test_date::test_date_tz
        FAIL [   0.155s] coreutils::tests test_date::test_date_tz_various_formats
        FAIL [   0.043s] coreutils::tests test_head::test_read_backwards_bytes_proc_fs_modules
        FAIL [   0.024s] coreutils::tests test_head::test_read_backwards_bytes_sys_kernel_profiling
        FAIL [   0.042s] coreutils::tests test_head::test_read_backwards_lines_proc_fs_modules
        FAIL [   0.041s] coreutils::tests test_logname::test_normal
        FAIL [   0.022s] coreutils::tests test_wc::test_files_from_pseudo_filesystem

This pull request skips incompatible parts of tests to ensure that they execute 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.

Test environment:

$ cat /proc/sys/kernel/osrelease 
5.15.167.4-microsoft-standard-WSL2

$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 24.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.2 LTS (Noble Numbat)"
VERSION_CODENAME=noble

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

Would it be possible to add a job in github to verify that we don't regress?

@martinkunkel2
Copy link
Contributor Author

Would it be possible to add a job in github to verify that we don't regress?

Never tried to run WSL2 in github actions, but I will try.

I see that there exists action https://github.com/vedantmgoyal9/setup-wsl2 to setup WSL2 on windows runners.
Am I allowed to use this setup-wsl2 action?

If yes, I would create a new workflow file, a bit similar to freebsd or android and execute the tests based on the setup-wsl2 action.

@martinkunkel2
Copy link
Contributor Author

will also check https://github.com/marketplace/actions/setup-wsl. This supports setting user instead of root, which should make this even more compatible with local exection.

@sylvestre
Copy link
Contributor

yeah, no worries for the action

@martinkunkel2
Copy link
Contributor Author

@sylvestre : I added a new workflow for WSL2.
It uses Vampire/setup-wsl to install WSL2 on windows-latest runners.

Here is a test execution: https://github.com/martinkunkel2/coreutils/actions/runs/15799503167/job/44535926995

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@martinkunkel2
Copy link
Contributor Author

@sylvestre : this is ready from my side. Please provide feedback if the new workflow should be added or not.

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

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.
This will setup WSL2 on windows-latest runner, install
Ubuntu-24.04, and run the feat_os_unix tests.
@martinkunkel2 martinkunkel2 force-pushed the wsl2_test_compatibility branch from 28ffdbc to bee1c22 Compare July 16, 2025 20:21
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

Copilot AI review requested due to automatic review settings August 3, 2025 07:39

This comment was marked as outdated.

@github-actions
Copy link

github-actions bot commented Aug 3, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes test execution issues on WSL2 with Ubuntu 24.04 by adding compatibility checks and skipping tests for features not available in the default WSL2 configuration.

  • Adds WSL2 compatibility checks for tests that depend on kernel features not available by default
  • Skips tests requiring /sys/kernel/profiling when the file doesn't exist
  • Handles empty /proc/modules file in WSL2 environments
  • Extends logname test skip condition to cover both WSL1 and WSL2

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/by-util/test_wc.rs Adds check for /sys/kernel/profiling existence before running profiling-related test
tests/by-util/test_logname.rs Changes WSL skip condition from WSL1-only to both WSL1 and WSL2
tests/by-util/test_head.rs Adds checks for file existence and non-empty content for /proc/modules and /sys/kernel/profiling
tests/by-util/test_cp.rs Adds /sys/kernel/profiling existence checks for three virtual file copy tests
src/uucore/src/lib/mods/os.rs Adds new is_wsl() function that combines WSL1 and WSL2 detection
.github/workflows/wsl2.yml Adds GitHub Actions workflow for testing on WSL2 environment
Comments suppressed due to low confidence (1)

tests/by-util/test_wc.rs:482

  • This closing brace appears to be misplaced. It should be part of the conditional block above, not a separate statement.
}

@github-actions
Copy link

github-actions bot commented Aug 3, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

@sylvestre sylvestre merged commit 3b4b769 into uutils:main Aug 3, 2025
78 of 79 checks passed
@martinkunkel2 martinkunkel2 deleted the wsl2_test_compatibility branch August 3, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants