Skip to content

Commit ef8bd18

Browse files
mmhalkuba-moo
authored andcommitted
vsock/test: Introduce option to select tests
Allow for selecting specific test IDs to be executed. Reviewed-by: Stefano Garzarella <[email protected]> Signed-off-by: Michal Luczaj <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f3af3ba commit ef8bd18

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

tools/testing/vsock/util.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,7 @@ void list_tests(const struct test_case *test_cases)
486486
exit(EXIT_FAILURE);
487487
}
488488

489-
void skip_test(struct test_case *test_cases, size_t test_cases_len,
490-
const char *test_id_str)
489+
static unsigned long parse_test_id(const char *test_id_str, size_t test_cases_len)
491490
{
492491
unsigned long test_id;
493492
char *endptr = NULL;
@@ -505,9 +504,35 @@ void skip_test(struct test_case *test_cases, size_t test_cases_len,
505504
exit(EXIT_FAILURE);
506505
}
507506

507+
return test_id;
508+
}
509+
510+
void skip_test(struct test_case *test_cases, size_t test_cases_len,
511+
const char *test_id_str)
512+
{
513+
unsigned long test_id = parse_test_id(test_id_str, test_cases_len);
508514
test_cases[test_id].skip = true;
509515
}
510516

517+
void pick_test(struct test_case *test_cases, size_t test_cases_len,
518+
const char *test_id_str)
519+
{
520+
static bool skip_all = true;
521+
unsigned long test_id;
522+
523+
if (skip_all) {
524+
unsigned long i;
525+
526+
for (i = 0; i < test_cases_len; ++i)
527+
test_cases[i].skip = true;
528+
529+
skip_all = false;
530+
}
531+
532+
test_id = parse_test_id(test_id_str, test_cases_len);
533+
test_cases[test_id].skip = false;
534+
}
535+
511536
unsigned long hash_djb2(const void *data, size_t len)
512537
{
513538
unsigned long hash = 5381;

tools/testing/vsock/util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ void run_tests(const struct test_case *test_cases,
6262
void list_tests(const struct test_case *test_cases);
6363
void skip_test(struct test_case *test_cases, size_t test_cases_len,
6464
const char *test_id_str);
65+
void pick_test(struct test_case *test_cases, size_t test_cases_len,
66+
const char *test_id_str);
6567
unsigned long hash_djb2(const void *data, size_t len);
6668
size_t iovec_bytes(const struct iovec *iov, size_t iovnum);
6769
unsigned long iovec_hash_djb2(const struct iovec *iov, size_t iovnum);

tools/testing/vsock/vsock_test.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,11 @@ static const struct option longopts[] = {
16441644
.has_arg = required_argument,
16451645
.val = 's',
16461646
},
1647+
{
1648+
.name = "pick",
1649+
.has_arg = required_argument,
1650+
.val = 't',
1651+
},
16471652
{
16481653
.name = "help",
16491654
.has_arg = no_argument,
@@ -1681,6 +1686,8 @@ static void usage(void)
16811686
" --peer-cid <cid> CID of the other side\n"
16821687
" --peer-port <port> AF_VSOCK port used for the test [default: %d]\n"
16831688
" --list List of tests that will be executed\n"
1689+
" --pick <test_id> Test ID to execute selectively;\n"
1690+
" use multiple --pick options to select more tests\n"
16841691
" --skip <test_id> Test ID to skip;\n"
16851692
" use multiple --skip options to skip more tests\n",
16861693
DEFAULT_PEER_PORT
@@ -1737,6 +1744,10 @@ int main(int argc, char **argv)
17371744
skip_test(test_cases, ARRAY_SIZE(test_cases) - 1,
17381745
optarg);
17391746
break;
1747+
case 't':
1748+
pick_test(test_cases, ARRAY_SIZE(test_cases) - 1,
1749+
optarg);
1750+
break;
17401751
case '?':
17411752
default:
17421753
usage();

0 commit comments

Comments
 (0)