MCPcopy Create free account
hub / github.com/corosync/corosync / run_cmap_test

Function run_cmap_test

test/testsam.c:1373–1422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1371}
1372
1373static int run_cmap_test(const char *test_name,
1374 int (test_func)(pid_t pid, pid_t old_pid, int test_n),
1375 int no_tests, int *all_passed, int *no_skipped)
1376{
1377 pid_t pid, old_pid;
1378 int err;
1379 int stat;
1380 const char *res_str;
1381 int n;
1382
1383 old_pid = 0;
1384
1385 fprintf (stderr, "Running %s test\n", test_name);
1386
1387 for (n = 1; n <= no_tests; n++) {
1388 pid = fork ();
1389
1390 if (pid == -1) {
1391 fprintf (stderr, "Can't fork\n");
1392
1393 exit (2);
1394 }
1395
1396 if (pid == 0) {
1397 err = test_func (getpid (), old_pid, n);
1398 sam_finalize ();
1399 exit (err);
1400 }
1401
1402 waitpid (pid, &stat, 0);
1403 old_pid = pid;
1404
1405 err = WEXITSTATUS (stat);
1406 if (err != 0) {
1407 break;
1408 }
1409 }
1410
1411 res_str = (err == 0 ? "passed" : (err == 1 ? "skipped" : "failed"));
1412
1413 if (err == 1) {
1414 (*no_skipped)++;
1415 } else if (err > 1) {
1416 (*all_passed) = 0;
1417 }
1418
1419 fprintf (stderr, "%s test %s\n", test_name, res_str);
1420
1421 return (err);
1422}
1423
1424int main(int argc, char *argv[])
1425{

Callers 1

mainFunction · 0.85

Calls 1

sam_finalizeFunction · 0.85

Tested by

no test coverage detected