From d60fa6c96f0074f179322bbb79d008ffbd0c2ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 15 Jan 2007 10:11:03 +0000 Subject: [PATCH] Now checks the return value of wait_for_thread() and print out an error message if it fails. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19804 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/system/kernel/fibo_exec.cpp | 24 +++++++++++++++------ src/tests/system/kernel/fibo_fork.cpp | 24 +++++++++++++++------ src/tests/system/kernel/fibo_load_image.cpp | 23 ++++++++++++++------ 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/tests/system/kernel/fibo_exec.cpp b/src/tests/system/kernel/fibo_exec.cpp index c39de62c61..d2d55123a8 100644 --- a/src/tests/system/kernel/fibo_exec.cpp +++ b/src/tests/system/kernel/fibo_exec.cpp @@ -83,14 +83,24 @@ main(int argc, char *argv[]) return -1; } - status_t status; - while (wait_for_thread(childA, &status) == B_INTERRUPTED) - ; - result = status; + status_t status, returnValue = 0; + do { + status = wait_for_thread(childA, &returnValue); + } while (status == B_INTERRUPTED); - while (wait_for_thread(childB, &status) == B_INTERRUPTED) - ; - result += status; + if (status == B_OK) + result = returnValue; + else + fprintf(stderr, "wait_for_thread(%ld) A failed: %s\n", childA, strerror(status)); + + do { + status = wait_for_thread(childB, &returnValue); + } while (status == B_INTERRUPTED); + + if (status == B_OK) + result += returnValue; + else + fprintf(stderr, "wait_for_thread(%ld) B failed: %s\n", childB, strerror(status)); } if (silent) { diff --git a/src/tests/system/kernel/fibo_fork.cpp b/src/tests/system/kernel/fibo_fork.cpp index 29c1a3957a..baafd8e5cf 100644 --- a/src/tests/system/kernel/fibo_fork.cpp +++ b/src/tests/system/kernel/fibo_fork.cpp @@ -70,14 +70,24 @@ main(int argc, char *argv[]) return -1; } - status_t status; - while (wait_for_thread(childA, &status) == B_INTERRUPTED) - ; - result = status; + status_t status, returnValue = 0; + do { + status = wait_for_thread(childA, &returnValue); + } while (status == B_INTERRUPTED); - while (wait_for_thread(childB, &status) == B_INTERRUPTED) - ; - result += status; + if (status == B_OK) + result = returnValue; + else + fprintf(stderr, "wait_for_thread(%ld) A failed: %s\n", childA, strerror(status)); + + do { + status = wait_for_thread(childB, &returnValue); + } while (status == B_INTERRUPTED); + + if (status == B_OK) + result += returnValue; + else + fprintf(stderr, "wait_for_thread(%ld) B failed: %s\n", childB, strerror(status)); } if (gForked) { diff --git a/src/tests/system/kernel/fibo_load_image.cpp b/src/tests/system/kernel/fibo_load_image.cpp index ef302ef30c..e7d0a09e17 100644 --- a/src/tests/system/kernel/fibo_load_image.cpp +++ b/src/tests/system/kernel/fibo_load_image.cpp @@ -71,13 +71,24 @@ main(int argc, char *argv[]) resume_thread(threadA); resume_thread(threadB); - while (wait_for_thread(threadA, &status) == B_INTERRUPTED) - ; - result = status; + status_t returnValue = 0; + do { + status = wait_for_thread(threadA, &returnValue); + } while (status == B_INTERRUPTED); - while (wait_for_thread(threadB, &status) == B_INTERRUPTED) - ; - result += status; + if (status == B_OK) + result = returnValue; + else + fprintf(stderr, "wait_for_thread(%ld) A failed: %s\n", threadA, strerror(status)); + + do { + status = wait_for_thread(threadB, &returnValue); + } while (status == B_INTERRUPTED); + + if (status == B_OK) + result += returnValue; + else + fprintf(stderr, "wait_for_thread(%ld) B failed: %s\n", threadB, strerror(status)); } if (silent) {