kernel: destroy untouched static rwlocks without allocation

This commit is contained in:
Chai T authored and nmzik committed 2026-10-29 18:32:14 +01:00
1 parent 97bef2992f
commit 4592e4c178
2 files changed
+16 -1

No files matched your search

+12
View File
@@ -101,6 +101,17 @@ void WaitForMutexTest(Predicate ready) {
}
}
void TestStaticRwlockDestroy() {
using namespace Libs::LibKernel;
PthreadRwlock rwlock = nullptr;
Check(PthreadRwlockDestroy(nullptr) == KERNEL_ERROR_EINVAL &&
PthreadRwlockDestroy(&rwlock) == OK && rwlock == nullptr,
"destroy an untouched static rwlock without allocating it");
Check(PthreadRwlockRdlock(&rwlock) == OK && PthreadRwlockUnlock(&rwlock) == OK &&
PthreadRwlockDestroy(&rwlock) == OK,
"static rwlock remains usable after destroying its untouched initializer");
}
struct MutexWaiter {
Libs::LibKernel::PthreadMutex *mutex;
Libs::LibKernel::KernelUseconds timeout = 0;
@@ -2723,6 +2734,7 @@ int main(int argc, char** argv) {
}
TestMutexHandoff();
TestStaticRwlockDestroy();
if (argc == 2 && std::string_view(argv[1]) == "--mutex-only") {
subsystems.Destroy();
std::printf("KernelFileSystemTests: mutex cases passed\n");