[PATCH net-next v1 8/9] net: devmem: ksft: upgrade rx test to send 1K data

Mina Almasry posted 9 patches 7 months ago
There is a newer version of this series
[PATCH net-next v1 8/9] net: devmem: ksft: upgrade rx test to send 1K data
Posted by Mina Almasry 7 months ago
The current test just sends "hello\nworld" and verifies that is the
string received on the RX side. That is fine, but improve the test a bit
by sending 1K data. The test should be improved further to send more
data, but for now this should be a welcome improvement.

The test will send a repeating pattern of 0x01, 0x02, ... 0x06. The
ncdevmem `-v 7` flag will verify this pattern. ncdevmem will provide
useful debugging info when the test fails, such as the frags received
and verified fine, and which frag exactly failed, what was the expected
byte pattern, and what is the actual byte pattern received. All this
debug information will be useful when the test fails.

Signed-off-by: Mina Almasry <almasrymina@google.com>

---
 tools/testing/selftests/drivers/net/hw/devmem.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/drivers/net/hw/devmem.py b/tools/testing/selftests/drivers/net/hw/devmem.py
index 40fe5b525d51..10ffd8a8f72b 100755
--- a/tools/testing/selftests/drivers/net/hw/devmem.py
+++ b/tools/testing/selftests/drivers/net/hw/devmem.py
@@ -38,16 +38,17 @@ def check_rx(cfg, ipver) -> None:
     if fs_5_tuple:
         socat += f",bind={remote_addr}:{port}"
 
-    listen_cmd = f"{cfg.bin_local} -l -f {cfg.ifname} -s {addr} -p {port}"
+    listen_cmd = f"{cfg.bin_local} -l -f {cfg.ifname} -s {addr} -p {port} -v 7"
 
     if fs_5_tuple:
         listen_cmd += f" -c {remote_addr}"
 
     with bkg(listen_cmd, exit_wait=True) as ncdevmem:
         wait_port_listen(port)
-        cmd(f"echo -e \"hello\\nworld\"| {socat}", host=cfg.remote, shell=True)
+        cmd(f"yes $(echo -e \x01\x02\x03\x04\x05\x06) | \
+            head -c 1K | {socat}", host=cfg.remote, shell=True)
 
-    ksft_eq(ncdevmem.stdout.strip(), "hello\nworld")
+    ksft_eq(ncdevmem.ret, 0)
 
 
 def check_tx(cfg, ipver) -> None:
-- 
2.49.0.1101.gccaa498523-goog
Re: [PATCH net-next v1 8/9] net: devmem: ksft: upgrade rx test to send 1K data
Posted by Stanislav Fomichev 7 months ago
On 05/19, Mina Almasry wrote:
> The current test just sends "hello\nworld" and verifies that is the
> string received on the RX side. That is fine, but improve the test a bit
> by sending 1K data. The test should be improved further to send more
> data, but for now this should be a welcome improvement.
> 
> The test will send a repeating pattern of 0x01, 0x02, ... 0x06. The
> ncdevmem `-v 7` flag will verify this pattern. ncdevmem will provide
> useful debugging info when the test fails, such as the frags received
> and verified fine, and which frag exactly failed, what was the expected
> byte pattern, and what is the actual byte pattern received. All this
> debug information will be useful when the test fails.
> 
> Signed-off-by: Mina Almasry <almasrymina@google.com>

Acked-by: Stanislav Fomichev <sdf@fomichev.me>