blob: 33bb5c3136ef524ac3ad326605a08b28955d3d3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/*
* Copyright (c) 2021, Spencer Dixon <spencercdixon@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibTest/TestCase.h>
#include <LibThreading/Thread.h>
#include <unistd.h>
// FIXME: Enable these tests once they work reliably.
#if 0
TEST_CASE(threads_can_detach)
{
int should_be_42 = 0;
auto thread = Threading::Thread::construct([&should_be_42]() {
usleep(10 * 1000);
should_be_42 = 42;
return 0;
});
thread->start();
thread->detach();
usleep(20 * 1000);
EXPECT(should_be_42 == 42);
}
TEST_CASE(joining_detached_thread_errors)
{
auto thread = Threading::Thread::construct([]() { return 0; });
thread->start();
thread->detach();
EXPECT(thread->join().is_error());
}
#endif
|