summaryrefslogtreecommitdiff
path: root/tools/slang-test
diff options
context:
space:
mode:
authorskallweitNV <64953474+skallweitNV@users.noreply.github.com>2022-12-14 18:11:01 +0100
committerGitHub <noreply@github.com>2022-12-14 09:11:01 -0800
commit5ce8d4c146fef7c8890cd40e112858db69702bd2 (patch)
treed37e4faaaaa3631563b9993077787f44f234eb21 /tools/slang-test
parent9d048351d283f8df2a68aca52b3573dcbb8cdb9b (diff)
Shader cache improvements (#2564)
* Make shader cache tests check the output buffer * Add shader cache eviction test * Cleanup comments * Improve TestReporter thread safety * Split lockFile test into two tests * Cleanup PersistentCache tests * Disable multi-threaded tests on aarch64
Diffstat (limited to 'tools/slang-test')
-rw-r--r--tools/slang-test/test-reporter.cpp11
-rw-r--r--tools/slang-test/test-reporter.h4
2 files changed, 13 insertions, 2 deletions
diff --git a/tools/slang-test/test-reporter.cpp b/tools/slang-test/test-reporter.cpp
index ee8421e81..b2d0d1a54 100644
--- a/tools/slang-test/test-reporter.cpp
+++ b/tools/slang-test/test-reporter.cpp
@@ -140,18 +140,25 @@ void TestReporter::addResult(TestResult result)
{
assert(m_inTest);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
m_currentInfo.testResult = combine(m_currentInfo.testResult, result);
m_numCurrentResults++;
}
void TestReporter::addExecutionTime(double time)
{
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
m_currentInfo.executionTime = time;
}
void TestReporter::addResultWithLocation(TestResult result, const char* testText, const char* file, int line)
{
assert(m_inTest);
+
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
m_numCurrentResults++;
m_currentInfo.testResult = combine(m_currentInfo.testResult, result);
@@ -505,8 +512,8 @@ void TestReporter::addTest(const String& testName, TestResult testResult)
void TestReporter::message(TestMessageType type, const String& message)
{
- static std::mutex mutex;
- std::lock_guard<std::mutex> lock(mutex);
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+
if (type == TestMessageType::Info)
{
if (m_isVerbose && canWriteStdError())
diff --git a/tools/slang-test/test-reporter.h b/tools/slang-test/test-reporter.h
index b87c5368f..a90cd6653 100644
--- a/tools/slang-test/test-reporter.h
+++ b/tools/slang-test/test-reporter.h
@@ -9,6 +9,8 @@
#include "../../source/core/slang-dictionary.h"
#include "tools/unit-test/slang-unit-test.h"
+#include <mutex>
+
enum class TestOutputMode
{
Default = 0, ///< Default mode is to write test results to the console
@@ -138,6 +140,8 @@ protected:
bool m_inTest;
+ std::recursive_mutex m_mutex;
+
static TestReporter* s_reporter;
};