summaryrefslogtreecommitdiff
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
parent11b2dbd9bc8f094213a29ada2cfdf03e1adf936c (diff)
downloadkit-187945d0d458615f82a425c561d3918e29a50b45.zip
[build] debug
-rwxr-xr-xbuild.c38
-rw-r--r--source/tests/test_interprocess.c11
2 files changed, 30 insertions, 19 deletions
diff --git a/build.c b/build.c
index 8b3b51a..837a2b0 100755
--- a/build.c
+++ b/build.c
@@ -35,13 +35,13 @@ enum {
};
#if defined(_WIN32) && !defined(__CYGWIN__)
-#define DELIM "\\"
+#define DLM "\\"
enum { OS = WINDOWS, };
#elif defined(__APPLE__)
-#define DELIM "/"
+#define DLM "/"
enum { OS = MACOS, };
#else
-#define DELIM "/"
+#define DLM "/"
enum { OS = LINUX, };
#endif
@@ -429,7 +429,7 @@ i32 main(i32 argc, c8 **argv) {
if (system(fmt(
"%s %s "
- "%s%s" DELIM PROJECT "%s "
+ "%s%s" DLM PROJECT "%s "
SOURCE_LIB,
compiler_c, flags,
flag_obj, destination, postfix_obj)
@@ -442,8 +442,8 @@ i32 main(i32 argc, c8 **argv) {
if (system(fmt(
"%s %s "
- "%s%s" DELIM "test_suite%s "
- "%s" DELIM PROJECT "%s "
+ "%s%s" DLM "test_suite%s "
+ "%s" DLM PROJECT "%s "
FOLDER_TESTS "_exe.c "
"%s",
compiler_c, flags,
@@ -463,8 +463,8 @@ i32 main(i32 argc, c8 **argv) {
for (i32 i = 0; i < sizeof c_tests / sizeof *c_tests; ++i)
if (system(fmt(
"%s %s "
- "%s%s" DELIM "%s%s "
- "%s" DELIM PROJECT "%s "
+ "%s%s" DLM "%s%s "
+ "%s" DLM PROJECT "%s "
FOLDER_TESTS "%s.c"
" %s",
compiler_c, flags,
@@ -484,8 +484,8 @@ i32 main(i32 argc, c8 **argv) {
for (i32 i = 0; i < sizeof cpp_tests / sizeof *cpp_tests; ++i)
if (system(fmt(
"%s %s "
- "%s%s" DELIM "%s%s "
- "%s" DELIM PROJECT "%s "
+ "%s%s" DLM "%s%s "
+ "%s" DLM PROJECT "%s "
FOLDER_TESTS "%s.cpp"
" %s",
compiler_cpp, flags,
@@ -508,13 +508,13 @@ i32 main(i32 argc, c8 **argv) {
printf("Run tests\n\n");
fflush(stdout);
- if (system(fmt("\"." DELIM "%s" DELIM "test_suite\"", destination)) != 0)
+ if (system(fmt("\"." DLM "%s" DLM "test_suite\"", destination)) != 0)
status = 1;
fflush(stdout);
i32 code;
- code = system(fmt("\"." DELIM "%s" DELIM "test_too_many_assertions\" --quiet", destination)) & 0xff;
+ code = system(fmt("\"." DLM "%s" DLM "test_too_many_assertions\" --quiet", destination)) & 0xff;
if (code == 0)
printf("too many assertions - OK\n");
else {
@@ -523,7 +523,7 @@ i32 main(i32 argc, c8 **argv) {
}
fflush(stdout);
- code = system(fmt("\"." DELIM "%s" DELIM "test_too_many_tests\" --quiet", destination)) & 0xff;
+ code = system(fmt("\"." DLM "%s" DLM "test_too_many_tests\" --quiet", destination)) & 0xff;
if (code == 0)
printf("too many tests - OK\n");
else {
@@ -532,7 +532,7 @@ i32 main(i32 argc, c8 **argv) {
}
fflush(stdout);
- code = system(fmt("\"." DELIM "%s" DELIM "test_cpp\" --quiet", destination)) & 0xff;
+ code = system(fmt("\"." DLM "%s" DLM "test_cpp\" --quiet", destination)) & 0xff;
if (code == 0)
printf("cpp - OK\n");
else {
@@ -541,7 +541,7 @@ i32 main(i32 argc, c8 **argv) {
}
fflush(stdout);
- code = system(fmt("\"." DELIM "%s" DELIM "test_signals\" --quiet", destination)) & 0xff;
+ code = system(fmt("\"." DLM "%s" DLM "test_signals\" --quiet", destination)) & 0xff;
if (code == 0)
printf("signals - OK\n");
else {
@@ -550,12 +550,12 @@ i32 main(i32 argc, c8 **argv) {
}
fflush(stdout);
- system(fmt("\"." DELIM "%s" DELIM "test_interprocess\" clean", destination));
+ system(fmt("\"." DLM "%s" DLM "test_interprocess\" clean", destination));
if (OS == WINDOWS)
- system(fmt("cmd /c start \"\" /b %s/test_interprocess\" reader", destination));
+ system(fmt("cmd /c start "" /b \"." DLM "%s" DLM "test_interprocess\" reader", destination));
else
- system(fmt("\"." DELIM "%s" DELIM "test_interprocess\" reader &", destination));
- code = system(fmt("\"." DELIM "%s" DELIM "test_interprocess\" writer", destination));
+ system(fmt("\"." DLM "%s" DLM "test_interprocess\" reader &", destination));
+ code = system(fmt("\"." DLM "%s" DLM "test_interprocess\" writer", destination));
if (code == 0)
printf("interprocess - OK\n");
else {
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);
}