summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGangzheng Tong <tonggangzheng@gmail.com>2025-05-16 14:51:46 -0700
committerGitHub <noreply@github.com>2025-05-16 16:51:46 -0500
commit8f20632a0ba45c3bfada293842e55129949a2ae9 (patch)
tree1c725aa8595780f067f5ad8cf60d6334bd9a1797
parentda951e06e7eb8ad1b9c91d6176be8165ea4f2b45 (diff)
Enable Windows full debug testsuite in CI (#7085)
* Unify Debug Layer Control Logic and Add Disable Option for Debug Builds This PR refactors and unifies the debug layer control logic in slang-test. A new `-disable-debug-layers` option is introduced, allowing debug builds to skip enabling the validation (debug) layer. This is currently needed to ensure stability in the debug test suite. Previously, different toggles such as ENABLE_VALIDATION_LAYER, ENABLE_DEBUG_LAYER, and debugLayerEnabled were used inconsistently across different components of slang-test. This PR standardizes the logic by using a single variable, debugLayerEnabled, to control the enabling/disabling of the debug layer internally. Notes: By default, the debug/validation layer is enabled in debug builds and is not supported in release builds of slang-test. Fixes: #7132 * Disable spirv-opt for the DebugFunctionDefinition issue * Run debug build only in GCP machines * Fix VUID-vkCmdPipelineBarrier-pBufferMemoryBarriers-02818 dstAcessMask can't include VK_ACCESS_TRANSFER_READ_BIT when stage mask has VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR * Set failed retry limit to 32 --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
-rw-r--r--.github/workflows/ci.yml28
-rw-r--r--examples/example-base/example-base.cpp2
-rw-r--r--examples/reflection-parameter-blocks/main.cpp2
-rw-r--r--include/slang-gfx.h2
-rw-r--r--tests/language-feature/defer/deferred-loop.slang2
-rw-r--r--tests/language-feature/defer/scoped.slang2
-rw-r--r--tools/gfx-unit-test/buffer-barrier-test.cpp1
-rw-r--r--tools/gfx-unit-test/existing-device-handle-test.cpp1
-rw-r--r--tools/gfx-unit-test/get-buffer-resource-handle-test.cpp1
-rw-r--r--tools/gfx-unit-test/get-cmd-buffer-handle-test.cpp1
-rw-r--r--tools/gfx-unit-test/get-cmd-queue-handle-test.cpp1
-rw-r--r--tools/gfx-unit-test/get-texture-resource-handle-test.cpp1
-rw-r--r--tools/gfx-unit-test/gfx-test-util.cpp8
-rw-r--r--tools/gfx/d3d12/d3d12-device.cpp13
-rw-r--r--tools/gfx/d3d12/d3d12-helper-functions.cpp7
-rw-r--r--tools/gfx/render.cpp12
-rw-r--r--tools/gfx/vulkan/vk-device.cpp5
-rw-r--r--tools/gfx/vulkan/vk-helper-functions.cpp3
-rw-r--r--tools/gfx/vulkan/vk-helper-functions.h7
-rw-r--r--tools/slang-test/options.cpp12
-rw-r--r--tools/slang-test/options.h9
-rw-r--r--tools/slang-test/slang-test-main.cpp28
-rw-r--r--tools/slang-test/test-context.h2
-rw-r--r--tools/slang-test/test-reporter.cpp2
-rw-r--r--tools/unit-test/slang-unit-test.h1
25 files changed, 90 insertions, 63 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e2598cd73..8a4007183 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -61,7 +61,7 @@ jobs:
runs-on: ubuntu-24.04-arm
has-gpu: false
build-llvm: false
- # Self-hosted full gpu build
+ # Self-hosted full gpu build - release
- os: windows
config: release
compiler: cl
@@ -70,6 +70,17 @@ jobs:
full-gpu-tests: true
runs-on: [Windows, self-hosted]
has-gpu: true
+ server-count: 8
+ # Self-hosted full gpu build - debug
+ - os: windows
+ config: debug
+ compiler: cl
+ platform: x86_64
+ test-category: full
+ full-gpu-tests: true
+ runs-on: [Windows, self-hosted, "GCP-T4"]
+ has-gpu: true
+ server-count: 8
fail-fast: false
runs-on: ${{ matrix.runs-on }}
@@ -176,12 +187,13 @@ jobs:
if [[ "${{matrix.full-gpu-tests}}" == "true" ]]; then
"$bin_dir/slang-test" \
-use-test-server \
- -server-count 8 \
+ -server-count ${{ matrix.server-count }} \
-category ${{ matrix.test-category }} \
-api all-cpu \
-expected-failure-list tests/expected-failure-github.txt \
-skip-reference-image-generation \
- -show-adapter-info
+ -show-adapter-info \
+ ${{ matrix.config == 'debug' && '-disable-debug-layers' || '' }}
elif [[ "${{matrix.has-gpu}}" == "true" ]]; then
"$bin_dir/slang-test" \
-use-test-server \
@@ -191,7 +203,8 @@ jobs:
-expected-failure-list tests/expected-failure-record-replay-tests.txt \
-expected-failure-list tests/expected-failure-github-runner.txt \
-skip-reference-image-generation \
- -show-adapter-info
+ -show-adapter-info \
+ ${{ matrix.config == 'debug' && '-disable-debug-layers' || '' }}
else
"$bin_dir/slang-test" \
-use-test-server \
@@ -201,7 +214,8 @@ jobs:
-expected-failure-list tests/expected-failure-record-replay-tests.txt \
-expected-failure-list tests/expected-failure-github-runner.txt \
-skip-reference-image-generation \
- -show-adapter-info
+ -show-adapter-info \
+ ${{ matrix.config == 'debug' && '-disable-debug-layers' || '' }}
fi
- name: Run Slang examples
if: steps.filter.outputs.should-run == 'true' && matrix.platform != 'wasm' && matrix.full-gpu-tests
@@ -217,13 +231,13 @@ jobs:
run: |
PATH=$bin_dir:$PATH tools/slangc-test/test.sh
- name: Test Slang via glsl
- if: steps.filter.outputs.should-run == 'true' && matrix.full-gpu-tests && matrix.platform != 'wasm'
+ if: steps.filter.outputs.should-run == 'true' && matrix.full-gpu-tests && matrix.platform != 'wasm' && matrix.config != 'debug'
run: |
export SLANG_RUN_SPIRV_VALIDATION=1
export SLANG_USE_SPV_SOURCE_LANGUAGE_UNKNOWN=1
"$bin_dir/slang-test" \
-use-test-server \
- -server-count 8 \
+ -server-count ${{ matrix.server-count }} \
-category ${{ matrix.test-category }} \
-emit-spirv-via-glsl \
-api vk \
diff --git a/examples/example-base/example-base.cpp b/examples/example-base/example-base.cpp
index 9d5f1bcae..9de47b77b 100644
--- a/examples/example-base/example-base.cpp
+++ b/examples/example-base/example-base.cpp
@@ -21,7 +21,7 @@ Slang::Result WindowedAppBase::initializeBase(
// Initialize the rendering layer.
#ifdef _DEBUG
// Enable debug layer in debug config.
- gfxEnableDebugLayer();
+ gfxEnableDebugLayer(true);
#endif
IDevice::Desc deviceDesc = {};
deviceDesc.deviceType = deviceType;
diff --git a/examples/reflection-parameter-blocks/main.cpp b/examples/reflection-parameter-blocks/main.cpp
index cc20de281..873e785d0 100644
--- a/examples/reflection-parameter-blocks/main.cpp
+++ b/examples/reflection-parameter-blocks/main.cpp
@@ -580,7 +580,7 @@ struct ReflectionParameterBlocksExampleApp : public TestBase
// Vulkan device up and running.
#ifdef _DEBUG
- gfx::gfxEnableDebugLayer();
+ gfx::gfxEnableDebugLayer(true);
#endif
gfx::IDevice::Desc deviceDesc = {};
deviceDesc.deviceType = gfx::DeviceType::Vulkan;
diff --git a/include/slang-gfx.h b/include/slang-gfx.h
index a4e616f7b..ec405bac7 100644
--- a/include/slang-gfx.h
+++ b/include/slang-gfx.h
@@ -2933,7 +2933,7 @@ extern "C"
/// Enables debug layer. The debug layer will check all `gfx` calls and verify that uses are
/// valid.
- SLANG_GFX_API void SLANG_MCALL gfxEnableDebugLayer();
+ SLANG_GFX_API void SLANG_MCALL gfxEnableDebugLayer(bool enable);
SLANG_GFX_API const char* SLANG_MCALL gfxGetDeviceTypeName(DeviceType type);
}
diff --git a/tests/language-feature/defer/deferred-loop.slang b/tests/language-feature/defer/deferred-loop.slang
index 0108dbbc1..ebc05bbfb 100644
--- a/tests/language-feature/defer/deferred-loop.slang
+++ b/tests/language-feature/defer/deferred-loop.slang
@@ -1,5 +1,5 @@
//TEST(compute):COMPARE_COMPUTE: -shaderobj
-//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj
+//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj -xslang -O0
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
diff --git a/tests/language-feature/defer/scoped.slang b/tests/language-feature/defer/scoped.slang
index 447c02357..907ce2988 100644
--- a/tests/language-feature/defer/scoped.slang
+++ b/tests/language-feature/defer/scoped.slang
@@ -1,5 +1,5 @@
//TEST(compute):COMPARE_COMPUTE: -shaderobj
-//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj
+//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj -xslang -O0
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
diff --git a/tools/gfx-unit-test/buffer-barrier-test.cpp b/tools/gfx-unit-test/buffer-barrier-test.cpp
index 2d53ac13f..b128448d2 100644
--- a/tools/gfx-unit-test/buffer-barrier-test.cpp
+++ b/tools/gfx-unit-test/buffer-barrier-test.cpp
@@ -146,6 +146,7 @@ void barrierTestImpl(IDevice* device, UnitTestContext* context)
void barrierTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api)
{
+ gfxEnableDebugLayer(context->enableDebugLayers);
if ((api & context->enabledApis) == 0)
{
SLANG_IGNORE_TEST
diff --git a/tools/gfx-unit-test/existing-device-handle-test.cpp b/tools/gfx-unit-test/existing-device-handle-test.cpp
index 8b7a84ec2..5605bf8a5 100644
--- a/tools/gfx-unit-test/existing-device-handle-test.cpp
+++ b/tools/gfx-unit-test/existing-device-handle-test.cpp
@@ -83,6 +83,7 @@ void existingDeviceHandleTestImpl(IDevice* device, UnitTestContext* context)
void existingDeviceHandleTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api)
{
+ gfxEnableDebugLayer(context->enableDebugLayers);
if ((api & context->enabledApis) == 0)
{
SLANG_IGNORE_TEST;
diff --git a/tools/gfx-unit-test/get-buffer-resource-handle-test.cpp b/tools/gfx-unit-test/get-buffer-resource-handle-test.cpp
index 97bb413fd..102986616 100644
--- a/tools/gfx-unit-test/get-buffer-resource-handle-test.cpp
+++ b/tools/gfx-unit-test/get-buffer-resource-handle-test.cpp
@@ -53,6 +53,7 @@ void getBufferResourceHandleTestImpl(IDevice* device, UnitTestContext* context)
void getBufferResourceHandleTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api)
{
+ gfxEnableDebugLayer(context->enableDebugLayers);
if ((api & context->enabledApis) == 0)
{
SLANG_IGNORE_TEST;
diff --git a/tools/gfx-unit-test/get-cmd-buffer-handle-test.cpp b/tools/gfx-unit-test/get-cmd-buffer-handle-test.cpp
index b1e7ebc04..5c734f966 100644
--- a/tools/gfx-unit-test/get-cmd-buffer-handle-test.cpp
+++ b/tools/gfx-unit-test/get-cmd-buffer-handle-test.cpp
@@ -49,6 +49,7 @@ void getBufferHandleTestImpl(IDevice* device, UnitTestContext* context)
void getBufferHandleTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api)
{
+ gfxEnableDebugLayer(context->enableDebugLayers);
if ((api & context->enabledApis) == 0)
{
SLANG_IGNORE_TEST;
diff --git a/tools/gfx-unit-test/get-cmd-queue-handle-test.cpp b/tools/gfx-unit-test/get-cmd-queue-handle-test.cpp
index 5e72c41d9..82561f4a2 100644
--- a/tools/gfx-unit-test/get-cmd-queue-handle-test.cpp
+++ b/tools/gfx-unit-test/get-cmd-queue-handle-test.cpp
@@ -38,6 +38,7 @@ void getQueueHandleTestImpl(IDevice* device, UnitTestContext* context)
void getQueueHandleTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api)
{
+ gfxEnableDebugLayer(context->enableDebugLayers);
if ((api & context->enabledApis) == 0)
{
SLANG_IGNORE_TEST;
diff --git a/tools/gfx-unit-test/get-texture-resource-handle-test.cpp b/tools/gfx-unit-test/get-texture-resource-handle-test.cpp
index 4a7412ddc..1900b482e 100644
--- a/tools/gfx-unit-test/get-texture-resource-handle-test.cpp
+++ b/tools/gfx-unit-test/get-texture-resource-handle-test.cpp
@@ -50,6 +50,7 @@ void getTextureResourceHandleTestImpl(IDevice* device, UnitTestContext* context)
void getTextureResourceHandleTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api)
{
+ gfxEnableDebugLayer(context->enableDebugLayers);
if ((api & context->enabledApis) == 0)
{
SLANG_IGNORE_TEST;
diff --git a/tools/gfx-unit-test/gfx-test-util.cpp b/tools/gfx-unit-test/gfx-test-util.cpp
index d7cfa0f65..bd1b2a891 100644
--- a/tools/gfx-unit-test/gfx-test-util.cpp
+++ b/tools/gfx-unit-test/gfx-test-util.cpp
@@ -323,13 +323,7 @@ Slang::ComPtr<gfx::IDevice> createTestingDevice(
void* extDescPtrs[2] = {&extDesc, &slangExtDesc};
deviceDesc.extendedDescs = extDescPtrs;
- // TODO: We should also set the debug callback
- // (And in general reduce the differences (and duplication) between
- // here and render-test-main.cpp)
-#ifdef _DEBUG
- gfx::gfxEnableDebugLayer();
-#endif
-
+ gfx::gfxEnableDebugLayer(context->enableDebugLayers);
auto createDeviceResult = gfxCreateDevice(&deviceDesc, device.writeRef());
if (SLANG_FAILED(createDeviceResult))
{
diff --git a/tools/gfx/d3d12/d3d12-device.cpp b/tools/gfx/d3d12/d3d12-device.cpp
index 88051d837..cfb384787 100644
--- a/tools/gfx/d3d12/d3d12-device.cpp
+++ b/tools/gfx/d3d12/d3d12-device.cpp
@@ -17,12 +17,6 @@
#include "d3d12-swap-chain.h"
#include "d3d12-vertex-layout.h"
-#ifdef _DEBUG
-#define ENABLE_DEBUG_LAYER 1
-#else
-#define ENABLE_DEBUG_LAYER 0
-#endif
-
#ifdef GFX_NVAPI
#include "../nvapi/nvapi-include.h"
#endif
@@ -534,7 +528,7 @@ Result DeviceImpl::initialize(const Desc& desc)
// If Aftermath is enabled, we can't enable the D3D12 debug layer as well
- if (ENABLE_DEBUG_LAYER || isGfxDebugLayerEnabled() && !g_isAftermathEnabled)
+ if (isGfxDebugLayerEnabled() && !g_isAftermathEnabled)
{
m_D3D12GetDebugInterface =
(PFN_D3D12_GET_DEBUG_INTERFACE)loadProc(d3dModule, "D3D12GetDebugInterface");
@@ -569,10 +563,7 @@ Result DeviceImpl::initialize(const Desc& desc)
if (desc.existingDeviceHandles.handles[0].handleValue == 0)
{
FlagCombiner combiner;
- // TODO: we should probably provide a command-line option
- // to override UseDebug of default rather than leave it
- // up to each back-end to specify.
- if (ENABLE_DEBUG_LAYER || isGfxDebugLayerEnabled())
+ if (isGfxDebugLayerEnabled())
{
combiner.add(
DeviceCheckFlag::UseDebug,
diff --git a/tools/gfx/d3d12/d3d12-helper-functions.cpp b/tools/gfx/d3d12/d3d12-helper-functions.cpp
index 9d218dae0..7d15a1a2d 100644
--- a/tools/gfx/d3d12/d3d12-helper-functions.cpp
+++ b/tools/gfx/d3d12/d3d12-helper-functions.cpp
@@ -10,15 +10,8 @@
#include "d3d12-query.h"
#include "d3d12-transient-heap.h"
-#ifdef _DEBUG
-#define ENABLE_DEBUG_LAYER 1
-#else
-#define ENABLE_DEBUG_LAYER 0
-#endif
-
namespace gfx
{
-
using namespace Slang;
namespace d3d12
diff --git a/tools/gfx/render.cpp b/tools/gfx/render.cpp
index 1ae7e370c..516369c0e 100644
--- a/tools/gfx/render.cpp
+++ b/tools/gfx/render.cpp
@@ -26,7 +26,13 @@ Result SLANG_MCALL getCUDAAdapters(List<AdapterInfo>& outAdapters);
Result SLANG_MCALL reportD3DLiveObjects();
+// Enable debug layer (validation layer) by default for DEBUG build
+#if _DEBUG
+static bool debugLayerEnabled = true;
+#else
static bool debugLayerEnabled = false;
+#endif
+
bool isGfxDebugLayerEnabled()
{
return debugLayerEnabled;
@@ -276,7 +282,7 @@ extern "C"
return SLANG_E_NOT_IMPLEMENTED;
#endif
#if SLANG_WINDOWS_FAMILY || SLANG_LINUX_FAMILY
- // Assume no Vulkan or CUDA on MacOS or Cygwin
+ // Assume no Vulkan or CUDA on MacOS or Cygwin
case DeviceType::Vulkan:
SLANG_RETURN_ON_FAIL(getVKAdapters(adapters));
break;
@@ -428,9 +434,9 @@ extern "C"
return SLANG_OK;
}
- SLANG_GFX_API void SLANG_MCALL gfxEnableDebugLayer()
+ SLANG_GFX_API void SLANG_MCALL gfxEnableDebugLayer(bool enable)
{
- debugLayerEnabled = true;
+ debugLayerEnabled = enable;
}
const char* SLANG_MCALL gfxGetDeviceTypeName(DeviceType type)
diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp
index b9ca76493..d056e3984 100644
--- a/tools/gfx/vulkan/vk-device.cpp
+++ b/tools/gfx/vulkan/vk-device.cpp
@@ -214,7 +214,8 @@ Result DeviceImpl::initVulkanInstanceAndDevice(
#endif
}
- if (ENABLE_VALIDATION_LAYER || isGfxDebugLayerEnabled())
+ gfxEnableDebugLayer(useValidationLayer);
+ if (isGfxDebugLayerEnabled())
instanceExtensions.add(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
VkInstanceCreateInfo instanceCreateInfo = {VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO};
@@ -1027,7 +1028,7 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
descriptorSetAllocator.m_api = &m_api;
initDeviceResult = initVulkanInstanceAndDevice(
desc.existingDeviceHandles.handles,
- ENABLE_VALIDATION_LAYER != 0 || isGfxDebugLayerEnabled());
+ isGfxDebugLayerEnabled());
if (initDeviceResult == SLANG_OK)
break;
}
diff --git a/tools/gfx/vulkan/vk-helper-functions.cpp b/tools/gfx/vulkan/vk-helper-functions.cpp
index f1f517567..4a1fe85d0 100644
--- a/tools/gfx/vulkan/vk-helper-functions.cpp
+++ b/tools/gfx/vulkan/vk-helper-functions.cpp
@@ -214,8 +214,7 @@ VkAccessFlags translateAccelerationStructureAccessFlag(AccessFlag access)
{
VkAccessFlags result = 0;
if ((uint32_t)access & (uint32_t)AccessFlag::Read)
- result |= VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR | VK_ACCESS_SHADER_READ_BIT |
- VK_ACCESS_TRANSFER_READ_BIT;
+ result |= VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR | VK_ACCESS_SHADER_READ_BIT;
if ((uint32_t)access & (uint32_t)AccessFlag::Write)
result |= VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR;
return result;
diff --git a/tools/gfx/vulkan/vk-helper-functions.h b/tools/gfx/vulkan/vk-helper-functions.h
index 59dc61230..14fd18f5d 100644
--- a/tools/gfx/vulkan/vk-helper-functions.h
+++ b/tools/gfx/vulkan/vk-helper-functions.h
@@ -7,13 +7,6 @@
// Vulkan has a different coordinate system to ogl
// http://anki3d.org/vulkan-coordinate-system/
-#ifndef ENABLE_VALIDATION_LAYER
-#if _DEBUG
-#define ENABLE_VALIDATION_LAYER 1
-#else
-#define ENABLE_VALIDATION_LAYER 0
-#endif
-#endif
#ifdef _MSC_VER
#include <stddef.h>
diff --git a/tools/slang-test/options.cpp b/tools/slang-test/options.cpp
index 6be590ef2..da4f9cffe 100644
--- a/tools/slang-test/options.cpp
+++ b/tools/slang-test/options.cpp
@@ -1,4 +1,4 @@
-// test-context.cpp
+// options.cpp
#include "options.h"
#include "../../source/core/slang-io.h"
@@ -88,6 +88,10 @@ static bool _isSubCommand(const char* arg)
" -use-test-server Run tests using test server\n"
" -use-fully-isolated-test-server Run each test in isolated server\n"
" -capability <name> Compile with the given capability\n"
+#if _DEBUG
+ " -disable-debug-layers Disable the debug layers (default enabled in debug "
+ "build)\n"
+#endif
"\n"
"Output modes:\n"
" -appveyor Use AppVeyor output format\n"
@@ -406,6 +410,12 @@ static bool _isSubCommand(const char* arg)
{
optionsOut->skipReferenceImageGeneration = true;
}
+#if _DEBUG
+ else if (strcmp(arg, "-disable-debug-layers") == 0)
+ {
+ optionsOut->debugLayerEnabled = false;
+ }
+#endif
else
{
stdError.print("unknown option '%s'\n", arg);
diff --git a/tools/slang-test/options.h b/tools/slang-test/options.h
index 7fda33198..6e408374e 100644
--- a/tools/slang-test/options.h
+++ b/tools/slang-test/options.h
@@ -83,6 +83,15 @@ struct Options
// integration builds.
bool dumpOutputOnFailure = false;
+ // When true it will run with debug layer (e.g. vulkan validation layer)
+#if _DEBUG
+ // Default is true for debug build
+ bool debugLayerEnabled = true;
+#else
+ // Default is false for release build
+ bool debugLayerEnabled = false;
+#endif
+
// Set the default spawn type to use
// Having tests isolated, slows down testing considerably, so using UseSharedLibrary is the most
// desirable default usually.
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 92e50737e..02d305a46 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -3607,8 +3607,10 @@ TestResult runComputeComparisonImpl(
// gets misinterpreted as the result from the test.
// This is due to the limitation that Slang RPC implementation expects only
// one time communication.
- if (input.spawnType != SpawnType::UseTestServer)
+ if (context->options.debugLayerEnabled && input.spawnType != SpawnType::UseTestServer)
+ {
cmdLine.addArg("-enable-debug-layers");
+ }
#endif
if (context->isExecuting())
@@ -4344,7 +4346,7 @@ static SlangResult _runTestsOnFile(TestContext* context, String filePath)
context->setTestRequirements(&requirements);
runTest(context, filePath, filePath, filePath, testDetails.options);
- //
+
apiUsedFlags |= requirements.usedRenderApiFlags;
explictUsedApiFlags |= (requirements.explicitRenderApi != RenderApiType::Unknown)
? (RenderApiFlags(1) << int(requirements.explicitRenderApi))
@@ -4703,6 +4705,7 @@ static SlangResult runUnitTestModule(
unitTestContext.slangGlobalSession = context->getSession();
unitTestContext.workDirectory = "";
unitTestContext.enabledApis = context->options.enabledApis;
+ unitTestContext.enableDebugLayers = context->options.debugLayerEnabled;
unitTestContext.executableDirectory = context->exeDirectoryPath.getBuffer();
auto testCount = testModule->getTestCount();
@@ -5054,21 +5057,20 @@ SlangResult innerMain(int argc, char** argv)
TestReporter::SuiteScope suiteScope(&reporter, "unit tests");
TestReporter::set(&reporter);
- for (bool isRetry : {false, true})
+ // Try the unit tests up to 3 times
+ for (bool isRetry : {false, true, true})
{
- auto spawnType = context.getFinalSpawnType();
-
- context.isRetry = false;
+ // Use default spawn type for unit tests as the test server one is unstable
+ auto spawnType = SpawnType::Default;
+ context.isRetry = isRetry;
if (isRetry)
{
if (context.failedUnitTests.getCount() == 0)
break;
- printf("Retrying unit tests...\n");
- context.isRetry = true;
+ printf("Retrying unit tests with default spawn type...\n");
context.options.testPrefixes = context.failedUnitTests;
context.failedUnitTests.clear();
- spawnType = SpawnType::Default;
}
// Run the unit tests
@@ -5090,14 +5092,20 @@ SlangResult innerMain(int argc, char** argv)
}
// If we have a couple failed tests, they maybe intermittent failures due to parallel
- // excution or driver instability. We can try running them again.
+ // excution or driver instability. We can try running them again. Debug build has more
+ // instability at this moment, so we allow more retries.
+#if _DEBUG
+ static constexpr int kFailedTestLimitForRetry = 32;
+#else
static constexpr int kFailedTestLimitForRetry = 16;
+#endif
if (context.failedFileTests.getCount() <= kFailedTestLimitForRetry)
{
if (context.failedFileTests.getCount() > 0)
printf("Retrying %d failed tests...\n", (int)context.failedFileTests.getCount());
for (auto& test : context.failedFileTests)
{
+ context.isRetry = true;
FileTestInfoImpl* fileTestInfo = static_cast<FileTestInfoImpl*>(test.Ptr());
TestReporter::SuiteScope suiteScope(&reporter, "tests");
TestReporter::TestScope scope(&reporter, fileTestInfo->testName);
diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h
index 97562da99..6720cd648 100644
--- a/tools/slang-test/test-context.h
+++ b/tools/slang-test/test-context.h
@@ -181,6 +181,8 @@ public:
Slang::RefPtr<Slang::JSONRPCConnection> m_languageServerConnection;
bool isRetry;
+ bool enableDebugLayers;
+
std::mutex mutexFailedTests;
Slang::List<Slang::RefPtr<FileTestInfo>> failedFileTests;
Slang::List<Slang::String> failedUnitTests;
diff --git a/tools/slang-test/test-reporter.cpp b/tools/slang-test/test-reporter.cpp
index 1f6c00637..352245028 100644
--- a/tools/slang-test/test-reporter.cpp
+++ b/tools/slang-test/test-reporter.cpp
@@ -693,7 +693,7 @@ void TestReporter::outputSummary()
printf("\n===\n\n");
if (m_failedTestCount)
{
- printf("failing tests:\n");
+ printf("%d failing tests:\n", m_failedTestCount);
printf("---\n");
for (const auto& testInfo : m_testInfos)
{
diff --git a/tools/unit-test/slang-unit-test.h b/tools/unit-test/slang-unit-test.h
index 8f0f0a445..49cb5d8d7 100644
--- a/tools/unit-test/slang-unit-test.h
+++ b/tools/unit-test/slang-unit-test.h
@@ -43,6 +43,7 @@ struct UnitTestContext
const char* workDirectory;
const char* executableDirectory;
Slang::RenderApiFlags enabledApis;
+ bool enableDebugLayers;
};
typedef void (*UnitTestFunc)(UnitTestContext*);