summaryrefslogtreecommitdiff
path: root/source/tests
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-06-06 13:22:35 +0200
committerMitya Selivanov <automainint@guattari.tech>2024-06-06 13:22:35 +0200
commit187945d0d458615f82a425c561d3918e29a50b45 (patch)
treec16d4e08744f84794f6bb87f9aedba2ce1d9eb72 /source/tests
parent11b2dbd9bc8f094213a29ada2cfdf03e1adf936c (diff)
downloadkit-187945d0d458615f82a425c561d3918e29a50b45.zip
[build] debug
Diffstat (limited to 'source/tests')
-rw-r--r--source/tests/test_interprocess.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/tests/test_interprocess.c b/source/tests/test_interprocess.c
index ee25324..7655192 100644
--- a/source/tests/test_interprocess.c
+++ b/source/tests/test_interprocess.c
@@ -34,6 +34,8 @@ int run_writer() {
p->state = STATE_INIT;
unique_unlock(&p->m);
+ thrd_yield();
+
unique_lock(&p->m);
for (int i = 0; i < DATA_SIZE; i++) p->bytes[i] = i;
p->state = STATE_READY;
@@ -97,6 +99,15 @@ int run_reader() {
shared_lock(&p->m);
while (p->state != STATE_READY) {
shared_unlock(&p->m);
+
+ struct timespec t1;
+ timespec_get(&t1, TIME_UTC);
+
+ if (t1.tv_sec - t0.tv_sec > TIMEOUT) {
+ printf("%s: timeout.\n", __FUNCTION__);
+ return 1;
+ }
+
thrd_yield();
shared_lock(&p->m);
}