* [PATCH net-next] selftests/net: plug rxtimestamp test into kselftest framework
@ 2020-06-22 17:43 Tanner Love
2020-06-24 3:36 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Tanner Love @ 2020-06-22 17:43 UTC (permalink / raw)
To: netdev; +Cc: davem, tannerlove, Willem de Bruijn
From: tannerlove <tannerlove@google.com>
Run rxtimestamp as part of TEST_PROGS. Analogous to other tests, add
new rxtimestamp.sh wrapper script, so that the test runs isolated
from background traffic in a private network namespace.
Also ignore failures of test case #6 by default. This case verifies
that a receive timestamp is not reported if timestamp reporting is
enabled for a socket, but generation is disabled. Receive timestamp
generation has to be enabled globally, as no associated socket is
known yet. A background process that enables rx timestamp generation
therefore causes a false positive. Ntpd is one example that does.
Add a "--strict" option to cause failure in the event that any test
case fails, including test #6. This is useful for environments that
are known to not have such background processes.
Tested:
make -C tools/testing/selftests TARGETS="net" run_tests
Signed-off-by: Tanner Love <tannerlove@google.com>
Acked-by: Willem de Bruijn <willemb@google.com>
---
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/rxtimestamp.c | 11 +++++++++--
tools/testing/selftests/net/rxtimestamp.sh | 4 ++++
3 files changed, 14 insertions(+), 2 deletions(-)
create mode 100755 tools/testing/selftests/net/rxtimestamp.sh
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 895ec992b2f1..bfacb960450f 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -17,6 +17,7 @@ TEST_PROGS += route_localnet.sh
TEST_PROGS += reuseaddr_ports_exhausted.sh
TEST_PROGS += txtimestamp.sh
TEST_PROGS += vrf-xfrm-tests.sh
+TEST_PROGS += rxtimestamp.sh
TEST_PROGS_EXTENDED := in_netns.sh
TEST_GEN_FILES = socket nettest
TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any
diff --git a/tools/testing/selftests/net/rxtimestamp.c b/tools/testing/selftests/net/rxtimestamp.c
index 422e7761254d..d4ea86a13e52 100644
--- a/tools/testing/selftests/net/rxtimestamp.c
+++ b/tools/testing/selftests/net/rxtimestamp.c
@@ -44,6 +44,7 @@ struct test_case {
struct options sockopt;
struct tstamps expected;
bool enabled;
+ bool warn_on_fail;
};
struct sof_flag {
@@ -89,7 +90,7 @@ static struct test_case test_cases[] = {
},
{
{ so_timestamping: SOF_TIMESTAMPING_SOFTWARE },
- {}
+ warn_on_fail : true
},
{
{ so_timestamping: SOF_TIMESTAMPING_RX_SOFTWARE
@@ -115,6 +116,7 @@ static struct option long_options[] = {
{ "tcp", no_argument, 0, 't' },
{ "udp", no_argument, 0, 'u' },
{ "ip", no_argument, 0, 'i' },
+ { "strict", no_argument, 0, 'S' },
{ NULL, 0, NULL, 0 },
};
@@ -327,6 +329,7 @@ int main(int argc, char **argv)
{
bool all_protocols = true;
bool all_tests = true;
+ bool strict = false;
int arg_index = 0;
int failures = 0;
int s, t;
@@ -363,6 +366,9 @@ int main(int argc, char **argv)
all_protocols = false;
socket_types[0].enabled = true;
break;
+ case 'S':
+ strict = true;
+ break;
default:
error(1, 0, "Failed to parse parameters.");
}
@@ -379,7 +385,8 @@ int main(int argc, char **argv)
printf("Starting testcase %d...\n", t);
if (run_test_case(socket_types[s], test_cases[t])) {
- failures++;
+ if (strict || !test_cases[t].warn_on_fail)
+ failures++;
printf("FAILURE in test case ");
print_test_case(&test_cases[t]);
}
diff --git a/tools/testing/selftests/net/rxtimestamp.sh b/tools/testing/selftests/net/rxtimestamp.sh
new file mode 100755
index 000000000000..91631e88bf46
--- /dev/null
+++ b/tools/testing/selftests/net/rxtimestamp.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+./in_netns.sh ./rxtimestamp $@
--
2.27.0.111.gc72c7da667-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] selftests/net: plug rxtimestamp test into kselftest framework
2020-06-22 17:43 [PATCH net-next] selftests/net: plug rxtimestamp test into kselftest framework Tanner Love
@ 2020-06-24 3:36 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-06-24 3:36 UTC (permalink / raw)
To: tannerlove.kernel; +Cc: netdev, tannerlove, willemb
From: Tanner Love <tannerlove.kernel@gmail.com>
Date: Mon, 22 Jun 2020 13:43:24 -0400
> From: tannerlove <tannerlove@google.com>
>
> Run rxtimestamp as part of TEST_PROGS. Analogous to other tests, add
> new rxtimestamp.sh wrapper script, so that the test runs isolated
> from background traffic in a private network namespace.
>
> Also ignore failures of test case #6 by default. This case verifies
> that a receive timestamp is not reported if timestamp reporting is
> enabled for a socket, but generation is disabled. Receive timestamp
> generation has to be enabled globally, as no associated socket is
> known yet. A background process that enables rx timestamp generation
> therefore causes a false positive. Ntpd is one example that does.
>
> Add a "--strict" option to cause failure in the event that any test
> case fails, including test #6. This is useful for environments that
> are known to not have such background processes.
>
> Tested:
> make -C tools/testing/selftests TARGETS="net" run_tests
>
> Signed-off-by: Tanner Love <tannerlove@google.com>
> Acked-by: Willem de Bruijn <willemb@google.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-24 3:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-22 17:43 [PATCH net-next] selftests/net: plug rxtimestamp test into kselftest framework Tanner Love
2020-06-24 3:36 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).