From 2f3d141c04d460f7c28efed5718dd9135395fc13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=B8=E0=A4=AE=E0=A5=80=E0=A4=B0=20=E0=A4=B8=E0=A4=BF?= =?UTF-8?q?=E0=A4=82=E0=A4=B9=20Sameer=20Singh?= Date: Thu, 9 Jan 2025 08:43:54 +0530 Subject: [PATCH] test: add extra debugging information to the icmp tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: समीर सिंह Sameer Singh --- test/zdtm/lib/sysctl.c | 26 ++++++++++++++++++++++++++ test/zdtm/lib/sysctl.h | 1 + test/zdtm/static/socket6_icmp.c | 9 +++++++++ test/zdtm/static/socket_icmp.c | 9 +++++++++ 4 files changed, 45 insertions(+) diff --git a/test/zdtm/lib/sysctl.c b/test/zdtm/lib/sysctl.c index 6f0d3ac56c..cccc9f74b9 100644 --- a/test/zdtm/lib/sysctl.c +++ b/test/zdtm/lib/sysctl.c @@ -58,6 +58,32 @@ int sysctl_write_int(const char *name, int val) return ret; } +int sysctl_read_str(const char *name, char *data, int data_len) +{ + int fd; + int ret; + + fd = open(name, O_RDONLY); + if (fd < 0) { + pr_perror("Can't open %s", name); + return fd; + } + + ret = read(fd, data, data_len - 1); + if (ret < 0) { + pr_perror("Can't read %s", name); + ret = -errno; + goto err; + } + + data[ret] = '\0'; + + ret = 0; +err: + close(fd); + return ret; +} + int sysctl_write_str(const char *name, const char *val) { int fd; diff --git a/test/zdtm/lib/sysctl.h b/test/zdtm/lib/sysctl.h index b47829fc9f..e39ac43d36 100644 --- a/test/zdtm/lib/sysctl.h +++ b/test/zdtm/lib/sysctl.h @@ -3,6 +3,7 @@ extern int sysctl_read_int(const char *name, int *data); extern int sysctl_write_int(const char *name, int val); +extern int sysctl_read_str(const char *name, char *data, int data_len); extern int sysctl_write_str(const char *name, const char *val); #endif diff --git a/test/zdtm/static/socket6_icmp.c b/test/zdtm/static/socket6_icmp.c index 5e0ec7bfe4..fc2acbebae 100644 --- a/test/zdtm/static/socket6_icmp.c +++ b/test/zdtm/static/socket6_icmp.c @@ -1,4 +1,5 @@ #include "zdtmtst.h" +#include "sysctl.h" const char *test_doc = "static test for IP6/ICMP socket\n"; const char *test_author = "समीर सिंह Sameer Singh \n"; @@ -20,6 +21,8 @@ const char *test_author = "समीर सिंह Sameer Singh