aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-09-17 10:29:13 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-09-18 23:08:03 -0400
commit3ef3a2758c572dcdeed7d693f52c5049394f11f5 (patch)
tree7e0df913c83a421fbb7203bb707c5b7018bafa37
parent60c0a3c8607b835f73e77d89b5f67a8e6bd5c8b3 (diff)
downloadstasis-3ef3a2758c572dcdeed7d693f52c5049394f11f5.tar.gz
Fix test status expectation
* Fix child not returning result of execvp(). task->status is for program status, not fork() status.
-rw-r--r--src/multiprocessing.c3
-rw-r--r--tests/test_multiprocessing.c4
2 files changed, 3 insertions, 4 deletions
diff --git a/src/multiprocessing.c b/src/multiprocessing.c
index 5eb9f81..8709911 100644
--- a/src/multiprocessing.c
+++ b/src/multiprocessing.c
@@ -65,8 +65,7 @@ int child(struct MultiProcessingPool *pool, struct MultiProcessingTask *task, co
fflush(stdout);
fflush(stderr);
char *args[] = {"bash", "--norc", task->parent_script, (char *) NULL};
- task->status = execvp("/bin/bash", args);
- return 0; // NOP return to satisfy the compiler
+ return execvp("/bin/bash", args);
}
int parent(struct MultiProcessingPool *pool, struct MultiProcessingTask *task, pid_t pid, int *child_status) {
diff --git a/tests/test_multiprocessing.c b/tests/test_multiprocessing.c
index 3d1d972..67574e3 100644
--- a/tests/test_multiprocessing.c
+++ b/tests/test_multiprocessing.c
@@ -38,7 +38,7 @@ void test_mp_task() {
STASIS_ASSERT_FATAL((task = mp_task(pool, task_name, commands[i])) != NULL, "Task should not be NULL");
STASIS_ASSERT(task->pid != 0, "PID should be non-zero at this point");
STASIS_ASSERT(task->parent_pid != MP_POOL_PID_UNUSED, "Parent PID should be non-zero");
- STASIS_ASSERT(task->status == 0, "Status should be zero");
+ STASIS_ASSERT(task->status == -1, "Status should be -1 (not started yet)");
STASIS_ASSERT(strcmp(task->ident, task_name) == 0, "Wrong task identity");
STASIS_ASSERT(strstr(task->log_file, pool->log_root) != NULL, "Log file path must be in log_root");
STASIS_ASSERT(task->gate != NULL, "Semaphore should be initialized");
@@ -51,7 +51,7 @@ void test_mp_pool_join() {
for (size_t i = 0; i < pool->num_used; i++) {
struct MultiProcessingTask *task = &pool->task[i];
STASIS_ASSERT(task->pid == MP_POOL_PID_UNUSED, "Task should be marked as unused");
- STASIS_ASSERT(task->status == 0, "Task should have succeeded");
+ STASIS_ASSERT(task->status == 0, "Task status should be zero (success)");
}
}