@samitouri / QOSAMI-WSL / commits / d7a05edf

Use TAEF ignore properties to skip tests for WSL1 / WSL2 based on testpass version property (#40459)

* Use TAEF ignore properties to skip tests for WSL1 / WSL2 based on testpass version * Fix condition * Update comment * Fix mixed filters

Blue committed May 11, 2026 at 13:09 UTC d7a05edf508aa008aa7335091ecf2b07ba09c26a
6 files changed +11 -67
cloudtest/CMakeLists.txt
+5 -16
@@ -36,27 +36,16 @@ else()
36 set(TEST_PACKAGE_FILE "installer.msix")
37 endif()
38
39 -function(add_test_group image version)
40 - set(DIR ${OUT}/${image}-wsl${version})
41 -
39 +function(add_test_group image version suffix filter)
40 + set(DIR ${OUT}/${image}-${suffix})
41 file(MAKE_DIRECTORY ${DIR})
42
43 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TestMap.xml.in ${DIR}/TestMap.xml)
44 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TestGroup.xml.in ${DIR}/TestGroup.xml)
45 endfunction()
46
48 -function(add_wslc_test_group image)
49 - set(version "c")
50 - set(DIR ${OUT}/${image}-wslc)
51 -
52 - file(MAKE_DIRECTORY ${DIR})
53 -
54 - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TestMap.xml.in ${DIR}/TestMap.xml)
55 - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TestGroup-wslc.xml.in ${DIR}/TestGroup.xml)
56 -endfunction()
57 -
47 foreach(image ${CLOUDTEST_IMAGES})
59 - add_test_group("${image}" "1")
60 - add_test_group("${image}" "2")
61 - add_wslc_test_group("${image}")
48 + add_test_group("${image}" "1" "wsl1" "not (@TestCategory='WSLC')")
49 + add_test_group("${image}" "2" "wsl2" "not (@TestCategory='WSLC')")
50 + add_test_group("${image}" "2" "wslc" "@TestCategory='WSLC'")
51 endforeach()
cloudtest/TestGroup-wslc.xml.in deleted
-27
@@ -1,27 +0,0 @@
1 -<?xml version="1.0" encoding="utf-8"?>
2 -<TestJobGroup EnableProcessJobObjectBreakaway="true">
3 - <ResourceSpec>
4 - <Resource SKU="Standard_D4_v3" Image="${image}"/>
5 - </ResourceSpec>
6 - <Setup TimeoutMins="30">
7 - <BuildFiles>
8 - <Copy Src="${TEST_PACKAGE_PROVIDER}\${TEST_PACKAGE_PATH}" Dest="[WorkingDirectory]" IsRecursive="false"/>
9 - <Copy Src="[drop]\testbin\${TARGET_PLATFORM}\release\*" Dest="[WorkingDirectory]\" IsRecursive="true" Writable="true"/>
10 - <Copy Src="[drop]\testbin\${TARGET_PLATFORM}\test_distro.tar.xz" Dest="[WorkingDirectory]" IsRecursive="false" Writable="true"/>
11 - <Copy Src="[drop]\testbin\${TARGET_PLATFORM}\test_data\*" Dest="[WorkingDirectory]\test_data" IsRecursive="true" Writable="true"/>
12 - <Copy Src="[drop]\testbin\test-setup.ps1" Dest="[WorkingDirectory]\" IsRecursive="false" />
13 - <Copy Src="[drop]\testbin\CloudTest-Setup.bat" Dest="[WorkingDirectory]\" IsRecursive="false" />
14 - <Copy Src="[drop]\testbin\wsl.wprp" Dest="[WorkingDirectory]\" IsRecursive="false" />
15 - <Copy Src="[drop]\testbin\unit_tests\*" Dest="[WorkingDirectory]\unit_tests" IsRecursive="true" Writable="true"/>
16 - <Copy Src="[test_packages]\*" Dest="[WorkingDirectory]" IsRecursive="false" />
17 - <Copy Src="[dump_tool]\DumpTool.exe" Dest="[WorkingDirectory]" IsRecursive="false" />
18 - </BuildFiles>
19 - <Scripts>
20 - <Script Path="[WorkingDirectory]\CloudTest-Setup.bat" Args="[WorkingDirectory] [LoggingDirectory]" />
21 - </Scripts>
22 - </Setup>
23 -
24 - <TestJob Name="CloudTest.Taef" TimeoutMins="120">
25 - <Execution Type="TAEF" Path="[WorkingDirectory]\wsltests.dll" Args="/p:bugReportDirectory=[LoggingDirectory]\BugReportOutput /errorOnCrash /testmode:etwlogger /EtwLogger:WPRProfileFile=[WorkingDirectory]\wsl.wprp /EtwLogger:WPRProfile=WSL /EtwLogger:SavePoint=ExecutionComplete /EtwLogger:RecordingScope=Execution /p:SetupScript=.\test-setup.ps1 /p:Package=[WorkingDirectory]\${TEST_PACKAGE_FILE} /p:Version=2 /p:AllowUnsigned=${ALLOW_UNSIGNED_PACKAGE} /p:UnitTestsPath=[WorkingDirectory]\unit_tests /p:DistroPath=[WorkingDirectory]\test_distro.tar.xz /p:TestDataPath=[WorkingDirectory]\test_data /p:DistroName=test_distro /logOutput:High /p:RedirectStdout=[LoggingDirectory]\stdout.txt /p:RedirectStderr=[LoggingDirectory]\stderr.txt /p:KernelLogs=[LoggingDirectory]\dmesg.txt /p:DumpFolder=[LoggingDirectory] /p:WerReport /p:LogDmesg /p:PipelineBuildId=${PIPELINE_BUILD_ID} /p:DumpTool=DumpTool.exe /select:&quot;@TestCategory='WSLC' and (@WSLVersion='2' or not(@WSLVersion='*'))&quot;" />
26 - </TestJob>
27 -</TestJobGroup>
cloudtest/TestGroup.xml.in
+1 -1
@@ -22,6 +22,6 @@
22 </Setup>
23
24 <TestJob Name="CloudTest.Taef" TimeoutMins="240">
25 - <Execution Type="TAEF" Path="[WorkingDirectory]\wsltests.dll" Args="/p:bugReportDirectory=[LoggingDirectory]\BugReportOutput /errorOnCrash /testmode:etwlogger /EtwLogger:WPRProfileFile=[WorkingDirectory]\wsl.wprp /EtwLogger:WPRProfile=WSL /EtwLogger:SavePoint=ExecutionComplete /EtwLogger:RecordingScope=Execution /p:SetupScript=.\test-setup.ps1 /p:Package=[WorkingDirectory]\${TEST_PACKAGE_FILE} /p:Version=${version} /p:AllowUnsigned=${ALLOW_UNSIGNED_PACKAGE} /p:UnitTestsPath=[WorkingDirectory]\unit_tests /p:DistroPath=[WorkingDirectory]\test_distro.tar.xz /p:TestDataPath=[WorkingDirectory]\test_data /p:DistroName=test_distro /logOutput:High /p:RedirectStdout=[LoggingDirectory]\stdout.txt /p:RedirectStderr=[LoggingDirectory]\stderr.txt /p:KernelLogs=[LoggingDirectory]\dmesg.txt /p:DumpFolder=[LoggingDirectory] /p:WerReport /p:LogDmesg /p:PipelineBuildId=${PIPELINE_BUILD_ID} /p:DumpTool=DumpTool.exe /select:&quot;not(@TestCategory='WSLC') and (@WSLVersion='${version}' or not(@WSLVersion='*'))&quot;" />
25 + <Execution Type="TAEF" Path="[WorkingDirectory]\wsltests.dll" Args="/p:bugReportDirectory=[LoggingDirectory]\BugReportOutput /errorOnCrash /testmode:etwlogger /EtwLogger:WPRProfileFile=[WorkingDirectory]\wsl.wprp /EtwLogger:WPRProfile=WSL /EtwLogger:SavePoint=ExecutionComplete /EtwLogger:RecordingScope=Execution /p:SetupScript=.\test-setup.ps1 /p:Package=[WorkingDirectory]\${TEST_PACKAGE_FILE} /p:Version=${version} /p:AllowUnsigned=${ALLOW_UNSIGNED_PACKAGE} /p:UnitTestsPath=[WorkingDirectory]\unit_tests /p:DistroPath=[WorkingDirectory]\test_distro.tar.xz /p:TestDataPath=[WorkingDirectory]\test_data /p:DistroName=test_distro /logOutput:High /p:RedirectStdout=[LoggingDirectory]\stdout.txt /p:RedirectStderr=[LoggingDirectory]\stderr.txt /p:KernelLogs=[LoggingDirectory]\dmesg.txt /p:DumpFolder=[LoggingDirectory] /p:WerReport /p:LogDmesg /p:PipelineBuildId=${PIPELINE_BUILD_ID} /p:DumpTool=DumpTool.exe /select:&quot;${filter}&quot;" />
26 </TestJob>
27 </TestJobGroup>
cloudtest/TestMap.xml.in
+1 -1
@@ -1,6 +1,6 @@
1 <?xml version="1.0" encoding="utf-8"?>
2 <TestMap>
3 - <TestJobGroup Name="TaefTestsGroup" TestSystem="Default" ConfigPath="[BuildRoot]\testbin\${TARGET_PLATFORM}\cloudtest\${image}-wsl${version}\TestGroup.xml" IsActive="true"/>
3 + <TestJobGroup Name="TaefTestsGroup" TestSystem="Default" ConfigPath="[BuildRoot]\testbin\${TARGET_PLATFORM}\cloudtest\${image}-${suffix}\TestGroup.xml" IsActive="true"/>
4 <Providers>
5 <Provider Type="PipelineArtifacts">
6 <Properties>
test/windows/Common.h
+4 -6
@@ -40,25 +40,23 @@ using namespace std::chrono_literals;
40
41 //
42 // Test method declaration macros that tag tests with TAEF metadata for version-based selection.
43 -// Use these instead of TEST_METHOD() for tests that only apply to a specific WSL version.
44 -// When run via run-tests.ps1 or CloudTest, inapplicable tests are excluded from the run
45 -// entirely (no "skipped" noise) via TAEF /select: queries.
43 +// If the test version doesn't match the version passed to te.exe, the test is ignored.
44 //
45 #define WSL1_TEST_METHOD(_name) \
46 TAEF_BEGIN_TEST_METHOD_PROPERTIES_IN_CLASS_SCOPE(_name) \
49 - TEST_METHOD_PROPERTY(L"WSLVersion", L"1") \
47 + TEST_METHOD_PROPERTY(L"Ignore[not(@Version=1)]", L"true") \
48 TAEF_END_TEST_METHOD_PROPERTIES_IN_CLASS_SCOPE() \
49 TEST_METHOD(_name)
50
51 #define WSL2_TEST_METHOD(_name) \
52 TAEF_BEGIN_TEST_METHOD_PROPERTIES_IN_CLASS_SCOPE(_name) \
55 - TEST_METHOD_PROPERTY(L"WSLVersion", L"2") \
53 + TEST_METHOD_PROPERTY(L"Ignore[not(@Version=2)]", L"true") \
54 TAEF_END_TEST_METHOD_PROPERTIES_IN_CLASS_SCOPE() \
55 TEST_METHOD(_name)
56
57 #define WSLC_TEST_METHOD(_name) \
58 TAEF_BEGIN_TEST_METHOD_PROPERTIES_IN_CLASS_SCOPE(_name) \
61 - TEST_METHOD_PROPERTY(L"WSLVersion", L"2") \
59 + TEST_METHOD_PROPERTY(L"Ignore[not(@Version=2)]", L"true") \
60 TAEF_END_TEST_METHOD_PROPERTIES_IN_CLASS_SCOPE() \
61 TEST_METHOD(_name)
62
tools/test/run-tests.ps1
-16
@@ -70,25 +70,9 @@ if ($TeArgs -and ($TeArgs -icontains '/attachdebugger'))
70 }
71 }
72
73 -# If the user provided a /name: or /select: filter, don't add automatic version filtering.
74 -$HasUserSelection = $false
75 -foreach ($arg in $TeArgs)
76 -{
77 - if ($arg -like '/name:*' -or $arg -like '/select:*' -or $arg -like '-name:*' -or $arg -like '-select:*')
78 - {
79 - $HasUserSelection = $true
80 - break
81 - }
82 -}
83 -
73 $teArgList = @($TestDllPath, "/p:SetupScript=$SetupScript", "/p:Version=$Version", "/p:DistroPath=$DistroPath", "/p:TestDataPath=$TestDataPath",
74 "/p:Package=$Package", "/p:UnitTestsPath=$UnitTestsPath", "/p:PullRequest=$PullRequest", "/p:AllowUnsigned=1") + $TeArgs
75
87 -if (-not $HasUserSelection)
88 -{
89 - $teArgList += "/select:`"@WSLVersion='$Version' or not(@WSLVersion='*')`""
90 -}
91 -
76 if ($AttachDebugger)
77 {
78 $teProcess = Start-Process -FilePath "te.exe" -ArgumentList $teArgList -PassThru -NoNewWindow