Skip to content

Commit 639a8f8

Browse files
committed
[Testbed] Fix crash when Testbed is launched with wrong module name.
1 parent 1209132 commit 639a8f8

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

tests/Testbed/TestbedContext.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ TestbedContext::TestbedContext(const char* moduleName, int version, int argc, ch
142142
rendererDesc.rendererConfigSize = sizeof(cfgGL);
143143
}
144144
}
145-
if ((renderer = RenderSystem::Load(rendererDesc)) != nullptr)
145+
146+
Report report;
147+
if ((renderer = RenderSystem::Load(rendererDesc, &report)) != nullptr)
146148
{
147149
// Create swap chain
148150
SwapChainDescriptor swapChainDesc;
@@ -181,6 +183,11 @@ TestbedContext::TestbedContext(const char* moduleName, int version, int argc, ch
181183
CreateSamplerStates();
182184
LoadDefaultProjectionMatrix();
183185
}
186+
else
187+
{
188+
// Log error report
189+
Log::Errorf(Log::ColorFlags::StdError, "%s", report.GetText());
190+
}
184191
}
185192

186193
TestbedContext::~TestbedContext()

tests/Testbed/TestbedContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ class TestbedContext
4545
// Runs all tests and returns the number of failed ones. If all succeeded, the return value is 0.
4646
unsigned RunAllTests();
4747

48+
// Returns true if this context has a valid renderer.
49+
inline bool IsValid() const
50+
{
51+
return (renderer.get() != nullptr);
52+
}
53+
4854
public:
4955

5056
static unsigned RunRendererIndependentTests(int argc, char* argv[]);

tests/Testbed/TestbedMain.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ static unsigned RunTestbedForRenderer(const char* moduleName, int version, int a
3535
Log::Printf("Run Testbed: %s (%d)\n", moduleName, version);
3636
else
3737
Log::Printf("Run Testbed: %s\n", moduleName);
38+
3839
TestbedContext::PrintSeparator();
3940
TestbedContext context{ moduleName, version, argc, argv };
41+
if (!context.IsValid())
42+
return 1;
43+
4044
unsigned failures = context.RunAllTests();
4145
TestbedContext::PrintSeparator();
4246
Log::Printf("\n");

0 commit comments

Comments
 (0)