aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-10-22 01:47:34 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-10-22 01:47:34 -0400
commitebb75d08d5f680f13867f71528b83df62a9d27b0 (patch)
tree6216e47b242cd3593c65043b7b9b5f7d0fb5fb34
parentb46552ef9e37e60f7913c9776f73637e17a1d9e6 (diff)
downloadstasis-ebb75d08d5f680f13867f71528b83df62a9d27b0.tar.gz
Update test_mp_fail_fast
* Brute force the conditions required to make this work. Issue 128 jobs.
-rw-r--r--tests/test_multiprocessing.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/test_multiprocessing.c b/tests/test_multiprocessing.c
index 13a343d..7cc8bc7 100644
--- a/tests/test_multiprocessing.c
+++ b/tests/test_multiprocessing.c
@@ -120,20 +120,26 @@ void test_mp_pool_workflow() {
}
void test_mp_fail_fast() {
- char *commands_ff[] = {
+ char *commands_ff[128] = {
"sleep 1; true",
"sleep 3; true",
"sleep 5; false",
- "sleep 30; true", // these...
- "sleep 30; true", // shouldn't...
- "sleep 30; true", // execute... but need to be here to satisfy the signaled_by test below
};
+ // Pad the array with tasks. None of these should execute when
+ // the "fail fast" conditions are met
+ char *nopcmd = "sleep 30; true";
+ for (size_t i = 3; i < sizeof(commands_ff) / sizeof(*commands_ff); i++) {
+ commands_ff[i] = nopcmd;
+ }
+
struct MultiProcessingPool *p;
STASIS_ASSERT((p = mp_pool_init("failfast", "failfastlogs")) != NULL, "Failed to initialize pool");
for (size_t i = 0; i < sizeof(commands_ff) / sizeof(*commands_ff); i++) {
char *command = commands_ff[i];
- STASIS_ASSERT(mp_pool_task(p, "task", NULL, (char *) command) != NULL, "Failed to queue task");
+ char taskname[100] = {0};
+ snprintf(taskname, sizeof(taskname) - 1, "task_%03zu", i);
+ STASIS_ASSERT(mp_pool_task(p, taskname, NULL, (char *) command) != NULL, "Failed to queue task");
}
STASIS_ASSERT(mp_pool_join(p, get_cpu_count(), MP_POOL_FAIL_FAST) < 0, "Unexpected result");