[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ybwa5wswrwbfmqyttvqljxelmczko5ds2ln5lvyv2z5rcf75us@22lzbskdiv3d>
Date: Mon, 16 Dec 2024 15:32:19 +0100
From: Stefano Garzarella <sgarzare@...hat.com>
To: Michal Luczaj <mhal@...x.co>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 2/6] vsock/test: Introduce option to run a
single test
On Mon, Dec 16, 2024 at 01:00:58PM +0100, Michal Luczaj wrote:
>Allow for singling out a specific test ID to be executed.
>
>Signed-off-by: Michal Luczaj <mhal@...x.co>
>---
> tools/testing/vsock/util.c | 20 ++++++++++++++++++--
> tools/testing/vsock/util.h | 2 ++
> tools/testing/vsock/vsock_test.c | 10 ++++++++++
> 3 files changed, 30 insertions(+), 2 deletions(-)
>
>diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
>index 34e9dac0a105f8aeb8c9af379b080d5ce8cb2782..5a3b5908ba88e5011906d67fb82342d2a6a6ba74 100644
>--- a/tools/testing/vsock/util.c
>+++ b/tools/testing/vsock/util.c
>@@ -486,8 +486,7 @@ void list_tests(const struct test_case *test_cases)
> exit(EXIT_FAILURE);
> }
>
>-void skip_test(struct test_case *test_cases, size_t test_cases_len,
>- const char *test_id_str)
>+static unsigned long parse_test_id(const char *test_id_str, size_t test_cases_len)
> {
> unsigned long test_id;
> char *endptr = NULL;
>@@ -505,9 +504,26 @@ void skip_test(struct test_case *test_cases, size_t test_cases_len,
> exit(EXIT_FAILURE);
> }
>
>+ return test_id;
>+}
>+
>+void skip_test(struct test_case *test_cases, size_t test_cases_len,
>+ const char *test_id_str)
>+{
>+ unsigned long test_id = parse_test_id(test_id_str, test_cases_len);
> test_cases[test_id].skip = true;
> }
>
>+void pick_test(struct test_case *test_cases, size_t test_cases_len,
>+ const char *test_id_str)
>+{
>+ unsigned long i, test_id;
>+
>+ test_id = parse_test_id(test_id_str, test_cases_len);
>+ for (i = 0; i < test_cases_len; ++i)
>+ test_cases[i].skip = (i != test_id);
>+}
>+
> unsigned long hash_djb2(const void *data, size_t len)
> {
> unsigned long hash = 5381;
>diff --git a/tools/testing/vsock/util.h b/tools/testing/vsock/util.h
>index ba84d296d8b71e1bcba2abdad337e07aac45e75e..e62f46b2b92a7916e83e1e623b43c811b077db3e 100644
>--- a/tools/testing/vsock/util.h
>+++ b/tools/testing/vsock/util.h
>@@ -62,6 +62,8 @@ void run_tests(const struct test_case *test_cases,
> void list_tests(const struct test_case *test_cases);
> void skip_test(struct test_case *test_cases, size_t test_cases_len,
> const char *test_id_str);
>+void pick_test(struct test_case *test_cases, size_t test_cases_len,
>+ const char *test_id_str);
> unsigned long hash_djb2(const void *data, size_t len);
> size_t iovec_bytes(const struct iovec *iov, size_t iovnum);
> unsigned long iovec_hash_djb2(const struct iovec *iov, size_t iovnum);
>diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
>index 38fd8d96eb83ef1bd45728cfaac6adb3c1e07cfe..1ad1fbba10307c515e31816a2529befd547f7fd7 100644
>--- a/tools/testing/vsock/vsock_test.c
>+++ b/tools/testing/vsock/vsock_test.c
>@@ -1644,6 +1644,11 @@ static const struct option longopts[] = {
> .has_arg = required_argument,
> .val = 's',
> },
>+ {
>+ .name = "test",
>+ .has_arg = required_argument,
>+ .val = 't',
>+ },
> {
> .name = "help",
> .has_arg = no_argument,
>@@ -1681,6 +1686,7 @@ static void usage(void)
> " --peer-cid <cid> CID of the other side\n"
> " --peer-port <port> AF_VSOCK port used for the test [default: %d]\n"
> " --list List of tests that will be executed\n"
>+ " --test <test_id> Single test ID to be executed\n"
> " --skip <test_id> Test ID to skip;\n"
> " use multiple --skip options to skip more tests\n",
> DEFAULT_PEER_PORT
>@@ -1737,6 +1743,10 @@ int main(int argc, char **argv)
> skip_test(test_cases, ARRAY_SIZE(test_cases) - 1,
> optarg);
> break;
>+ case 't':
>+ pick_test(test_cases, ARRAY_SIZE(test_cases) - 1,
>+ optarg);
>+ break;
Cool, thanks for adding it!
Currently, if we use multiple times `--test X`, only the last one is
executed.
If we want that behaviour, we should document in the help, or just error
on second time.
But it would be cool to support multiple --test, so maybe we could do
the following:
- the first time we call pick_test, set skip to true in all tests
- from that point on go, set skip to false for each specified test
I mean this patch applied on top of your patch (feel free to change it,
it's just an example to explain better the idea):
diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
index 5a3b5908ba88..81b9a31059d8 100644
--- a/tools/testing/vsock/util.c
+++ b/tools/testing/vsock/util.c
@@ -517,11 +517,20 @@ void skip_test(struct test_case *test_cases, size_t test_cases_len,
void pick_test(struct test_case *test_cases, size_t test_cases_len,
const char *test_id_str)
{
- unsigned long i, test_id;
+ static bool skip_all = true;
+ unsigned long test_id;
+
+ if (skip_all) {
+ unsigned long i;
+
+ for (i = 0; i < test_cases_len; ++i)
+ test_cases[i].skip = true;
+
+ skip_all = false;
+ }
test_id = parse_test_id(test_id_str, test_cases_len);
- for (i = 0; i < test_cases_len; ++i)
- test_cases[i].skip = (i != test_id);
+ test_cases[test_id].skip = false;
}
unsigned long hash_djb2(const void *data, size_t len)
The rest LTGM!
Stefano
Powered by blists - more mailing lists