17 std::condition_variable _cv0, _cv1;
22 locker_test(
const std::string& device_path,
bool actual_test):
25 _actual_test(actual_test),
26 _device_path(device_path)
33 std::unique_lock<std::mutex> lk(_m0);
34 _cv0.wait(lk, [
this]{
return _go_0;});
42 std::unique_lock<std::mutex> lk(_m0);
49 std::unique_lock<std::mutex> lk(_m1);
50 _cv1.wait(lk, [
this]{
return _go_1;});
55 std::lock_guard<std::mutex> lk_gm(_m1);
60 std::unique_lock<std::mutex> lk(_m1);
61 _cv1.wait(lk, [
this]{
return _go_1;});
69 std::thread
t0 = std::thread([
this](){func_0();});
70 std::thread
t1 = std::thread([
this](){func_1();});
73 std::lock_guard<std::mutex> lk_gm(_m1);
79 std::unique_lock<std::mutex> lk(_m1);
80 _cv1.wait(lk, [
this]{
return !_go_1;});
84 std::lock_guard<std::mutex> lk_gm(_m0);
89 std::this_thread::sleep_for(std::chrono::milliseconds(2000));
91 std::lock_guard<std::mutex> lk_gm(_m0);
93 test_ok = (_go_0 == _actual_test);
97 std::lock_guard<std::mutex> lk_gm(_m1);
108 if(
access( device_path.c_str(), F_OK ) == -1 )
110 fid = open(device_path.c_str(), O_CREAT | O_RDWR, 0666);
123 locker_test _test(device_path, actual_test);
131 if(
access( device_path.c_str(), F_OK ) == -1 )
133 fid = open(device_path.c_str(), O_CREAT | O_RDWR, 0666);
137 sem_unlink(
"test_semaphore1");
138 sem_t *sem1 = sem_open(
"test_semaphore1", O_CREAT|O_EXCL, S_IRWXU, 0);
140 sem_unlink(
"test_semaphore2");
141 sem_t *sem2 = sem_open(
"test_semaphore2", O_CREAT|O_EXCL, S_IRWXU, 0);
143 pid_t pid_0 = getpid();
156 signal(SIGTERM, [](
int signum) {
exit(1); });
171 std::this_thread::sleep_for(std::chrono::milliseconds(2000));
173 pid_t
w = waitpid(pid, &status, WNOHANG);
175 bool child_alive(w == 0);
177 int res = kill(pid,SIGTERM);
178 pid_t w = waitpid(pid, &status, 0);
182 remove(device_path.c_str());
184 sem_unlink(
"test_semaphore1");
186 sem_unlink(
"test_semaphore2");
188 REQUIRE(child_alive == actual_test);
def run_test(self, configuration=None, log_path=None)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
GLdouble GLdouble GLdouble w
GLsizei const GLchar *const * string
status
Defines return codes that SDK interfaces use. Negative values indicate errors, a zero value indicates...
static const textual_icon exit
GLuint GLint GLboolean GLint GLenum access
TEST_CASE("named_mutex_threads","[code]")
CHECK_FALSE(inverse(inverse(p))==p)