Skip to content

Commit 14641e5

Browse files
committed
t/kvs: do not immediately exit on fence error
Problem: In the fence_api testing tool, if an error occurs during a fence, the tool immediately exits. This makes it difficult to test for fence error conditions. Solution: Do not exit immediately on error, capture the error and call pthread_exit(). Determine if an error has occurred after all threads have ended.
1 parent 02d70c3 commit 14641e5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

t/kvs/fence_api.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ typedef struct {
3636
char *treeobj;
3737
char *rootref;
3838
int sequence;
39+
int errnum;
3940
} thd_t;
4041

4142
static int fencecount = -1;
@@ -105,8 +106,15 @@ void *thread (void *arg)
105106

106107
if (!(f = flux_kvs_fence (t->h, namespace, flags, fence_name,
107108
fencecount, txn))
108-
|| flux_future_get (f, NULL) < 0)
109-
log_err_exit ("flux_kvs_fence");
109+
|| flux_future_get (f, NULL) < 0) {
110+
/* Do not call log_err_exit(), for tests that want to see the
111+
* error that occurred. Code in main() will check for errnum
112+
* and exit after all threads are done.
113+
*/
114+
log_err ("flux_kvs_fence");
115+
t->errnum = errno;
116+
return NULL;
117+
}
110118

111119
/* save off fence root information */
112120

@@ -182,6 +190,11 @@ int main (int argc, char *argv[])
182190
log_errn (rc, "pthread_join");
183191
}
184192

193+
for (i = 0; i < fencecount; i++) {
194+
if (thd[i].errnum)
195+
exit (1);
196+
}
197+
185198
/* compare results from all of the fences, the root ref info
186199
* should all be the same
187200
*/

0 commit comments

Comments
 (0)