diff options
author | Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> | 2018-05-31 00:42:36 -0400 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-06-02 00:13:56 -0400 |
commit | 16edddfe3c5d192f097c27ff60cae05daa29f782 (patch) | |
tree | 40d6b5bacec67b7236b606645c1fe7d7abb90c9f | |
parent | bcece5dc40b9e00d0a9a91fc0acc9a825c23362b (diff) |
selftests/bpf: test_sockmap, check test failure
Test failures are not identified because exit code of RX/TX threads
is not checked. Also threads are not returning correct exit code.
- Return exit code from threads depending on test execution status
- In main thread, check the exit code of RX/TX threads
- Skip error checking for corked tests as they are expected to timeout
Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r-- | tools/testing/selftests/bpf/test_sockmap.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index eb17fae458e6..7b2008a144cb 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c | |||
@@ -429,8 +429,8 @@ static int sendmsg_test(struct sockmap_options *opt) | |||
429 | struct msg_stats s = {0}; | 429 | struct msg_stats s = {0}; |
430 | int iov_count = opt->iov_count; | 430 | int iov_count = opt->iov_count; |
431 | int iov_buf = opt->iov_length; | 431 | int iov_buf = opt->iov_length; |
432 | int rx_status, tx_status; | ||
432 | int cnt = opt->rate; | 433 | int cnt = opt->rate; |
433 | int status; | ||
434 | 434 | ||
435 | errno = 0; | 435 | errno = 0; |
436 | 436 | ||
@@ -442,7 +442,7 @@ static int sendmsg_test(struct sockmap_options *opt) | |||
442 | rxpid = fork(); | 442 | rxpid = fork(); |
443 | if (rxpid == 0) { | 443 | if (rxpid == 0) { |
444 | if (opt->drop_expected) | 444 | if (opt->drop_expected) |
445 | exit(1); | 445 | exit(0); |
446 | 446 | ||
447 | if (opt->sendpage) | 447 | if (opt->sendpage) |
448 | iov_count = 1; | 448 | iov_count = 1; |
@@ -463,7 +463,9 @@ static int sendmsg_test(struct sockmap_options *opt) | |||
463 | "rx_sendmsg: TX: %zuB %fB/s %fGB/s RX: %zuB %fB/s %fGB/s\n", | 463 | "rx_sendmsg: TX: %zuB %fB/s %fGB/s RX: %zuB %fB/s %fGB/s\n", |
464 | s.bytes_sent, sent_Bps, sent_Bps/giga, | 464 | s.bytes_sent, sent_Bps, sent_Bps/giga, |
465 | s.bytes_recvd, recvd_Bps, recvd_Bps/giga); | 465 | s.bytes_recvd, recvd_Bps, recvd_Bps/giga); |
466 | exit(1); | 466 | if (err && txmsg_cork) |
467 | err = 0; | ||
468 | exit(err ? 1 : 0); | ||
467 | } else if (rxpid == -1) { | 469 | } else if (rxpid == -1) { |
468 | perror("msg_loop_rx: "); | 470 | perror("msg_loop_rx: "); |
469 | return errno; | 471 | return errno; |
@@ -491,14 +493,27 @@ static int sendmsg_test(struct sockmap_options *opt) | |||
491 | "tx_sendmsg: TX: %zuB %fB/s %f GB/s RX: %zuB %fB/s %fGB/s\n", | 493 | "tx_sendmsg: TX: %zuB %fB/s %f GB/s RX: %zuB %fB/s %fGB/s\n", |
492 | s.bytes_sent, sent_Bps, sent_Bps/giga, | 494 | s.bytes_sent, sent_Bps, sent_Bps/giga, |
493 | s.bytes_recvd, recvd_Bps, recvd_Bps/giga); | 495 | s.bytes_recvd, recvd_Bps, recvd_Bps/giga); |
494 | exit(1); | 496 | exit(err ? 1 : 0); |
495 | } else if (txpid == -1) { | 497 | } else if (txpid == -1) { |
496 | perror("msg_loop_tx: "); | 498 | perror("msg_loop_tx: "); |
497 | return errno; | 499 | return errno; |
498 | } | 500 | } |
499 | 501 | ||
500 | assert(waitpid(rxpid, &status, 0) == rxpid); | 502 | assert(waitpid(rxpid, &rx_status, 0) == rxpid); |
501 | assert(waitpid(txpid, &status, 0) == txpid); | 503 | assert(waitpid(txpid, &tx_status, 0) == txpid); |
504 | if (WIFEXITED(rx_status)) { | ||
505 | err = WEXITSTATUS(rx_status); | ||
506 | if (err) { | ||
507 | fprintf(stderr, "rx thread exited with err %d. ", err); | ||
508 | goto out; | ||
509 | } | ||
510 | } | ||
511 | if (WIFEXITED(tx_status)) { | ||
512 | err = WEXITSTATUS(tx_status); | ||
513 | if (err) | ||
514 | fprintf(stderr, "tx thread exited with err %d. ", err); | ||
515 | } | ||
516 | out: | ||
502 | return err; | 517 | return err; |
503 | } | 518 | } |
504 | 519 | ||