aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorJerry Hoemann <jerry.hoemann@hpe.com>2018-09-26 17:23:09 -0400
committerShuah Khan (Samsung OSG) <shuah@kernel.org>2018-10-24 16:49:36 -0400
commit7514c39cf1d9433203c9b7c6674dbfa429db804b (patch)
tree9971549c08f6226f8c2c7c82dfd4de8e81fda26e /tools/testing
parent04d5e4bd37516ad60854eb74592c7dbddd75d277 (diff)
selftests: watchdog: Add gettimeout and get|set pretimeout
Add command line arguments to call ioctl WDIOC_GETTIMEOUT, WDIOC_GETPRETIMEOUT and WDIOC_SETPRETIMEOUT. Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/watchdog/watchdog-test.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index f1c6e025cbe5..e0f1600dc1b3 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -19,7 +19,7 @@
19 19
20int fd; 20int fd;
21const char v = 'V'; 21const char v = 'V';
22static const char sopts[] = "bdehp:t:"; 22static const char sopts[] = "bdehp:t:Tn:N";
23static const struct option lopts[] = { 23static const struct option lopts[] = {
24 {"bootstatus", no_argument, NULL, 'b'}, 24 {"bootstatus", no_argument, NULL, 'b'},
25 {"disable", no_argument, NULL, 'd'}, 25 {"disable", no_argument, NULL, 'd'},
@@ -27,6 +27,9 @@ static const struct option lopts[] = {
27 {"help", no_argument, NULL, 'h'}, 27 {"help", no_argument, NULL, 'h'},
28 {"pingrate", required_argument, NULL, 'p'}, 28 {"pingrate", required_argument, NULL, 'p'},
29 {"timeout", required_argument, NULL, 't'}, 29 {"timeout", required_argument, NULL, 't'},
30 {"gettimeout", no_argument, NULL, 'T'},
31 {"pretimeout", required_argument, NULL, 'n'},
32 {"getpretimeout", no_argument, NULL, 'N'},
30 {NULL, no_argument, NULL, 0x0} 33 {NULL, no_argument, NULL, 0x0}
31}; 34};
32 35
@@ -71,9 +74,13 @@ static void usage(char *progname)
71 printf(" -h, --help Print the help message\n"); 74 printf(" -h, --help Print the help message\n");
72 printf(" -p, --pingrate=P Set ping rate to P seconds (default %d)\n", DEFAULT_PING_RATE); 75 printf(" -p, --pingrate=P Set ping rate to P seconds (default %d)\n", DEFAULT_PING_RATE);
73 printf(" -t, --timeout=T Set timeout to T seconds\n"); 76 printf(" -t, --timeout=T Set timeout to T seconds\n");
77 printf(" -T, --gettimeout Get the timeout\n");
78 printf(" -n, --pretimeout=T Set the pretimeout to T seconds\n");
79 printf(" -N, --getpretimeout Get the pretimeout\n");
74 printf("\n"); 80 printf("\n");
75 printf("Parameters are parsed left-to-right in real-time.\n"); 81 printf("Parameters are parsed left-to-right in real-time.\n");
76 printf("Example: %s -d -t 10 -p 5 -e\n", progname); 82 printf("Example: %s -d -t 10 -p 5 -e\n", progname);
83 printf("Example: %s -t 12 -T -n 7 -N\n", progname);
77} 84}
78 85
79int main(int argc, char *argv[]) 86int main(int argc, char *argv[])
@@ -141,6 +148,30 @@ int main(int argc, char *argv[])
141 else 148 else
142 printf("WDIOC_SETTIMEOUT error '%s'\n", strerror(errno)); 149 printf("WDIOC_SETTIMEOUT error '%s'\n", strerror(errno));
143 break; 150 break;
151 case 'T':
152 oneshot = 1;
153 ret = ioctl(fd, WDIOC_GETTIMEOUT, &flags);
154 if (!ret)
155 printf("WDIOC_GETTIMEOUT returns %u seconds.\n", flags);
156 else
157 printf("WDIOC_GETTIMEOUT error '%s'\n", strerror(errno));
158 break;
159 case 'n':
160 flags = strtoul(optarg, NULL, 0);
161 ret = ioctl(fd, WDIOC_SETPRETIMEOUT, &flags);
162 if (!ret)
163 printf("Watchdog pretimeout set to %u seconds.\n", flags);
164 else
165 printf("WDIOC_SETPRETIMEOUT error '%s'\n", strerror(errno));
166 break;
167 case 'N':
168 oneshot = 1;
169 ret = ioctl(fd, WDIOC_GETPRETIMEOUT, &flags);
170 if (!ret)
171 printf("WDIOC_GETPRETIMEOUT returns %u seconds.\n", flags);
172 else
173 printf("WDIOC_GETPRETIMEOUT error '%s'\n", strerror(errno));
174 break;
144 default: 175 default:
145 usage(argv[0]); 176 usage(argv[0]);
146 goto end; 177 goto end;