summaryrefslogtreecommitdiff
path: root/ethtool.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2011-10-31 18:29:35 +0000
committerBen Hutchings <bhutchings@solarflare.com>2012-05-23 01:02:29 +0100
commitdfacc4a0fa3be71539be94da11f5cd3f47ffcbe5 (patch)
treeae4f589f30d8e84a87540a45fea091450919541d /ethtool.c
parent2edf56749abe006f6a68c9c21a2a249d29345a01 (diff)
downloadethtool-dfacc4a0fa3be71539be94da11f5cd3f47ffcbe5.tar.gz
Run tests in-process
Wrap main(), exit(), and resource management so that ethtool commands can be tested without starting a new process and without leaking. This will allow deeper teesting that covers ioctl requests and responses. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'ethtool.c')
-rw-r--r--ethtool.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/ethtool.c b/ethtool.c
index f18f611..65bdd38 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -3261,16 +3261,13 @@ static int do_getmodule(struct cmd_context *ctx)
return 0;
}
+#ifndef TEST_ETHTOOL
int send_ioctl(struct cmd_context *ctx, void *cmd)
{
-#ifndef TEST_ETHTOOL
ctx->ifr.ifr_data = cmd;
return ioctl(ctx->fd, SIOCETHTOOL, &ctx->ifr);
-#else
- /* If we get this far then parsing succeeded */
- exit(0);
-#endif
}
+#endif
static int show_usage(struct cmd_context *ctx);
@@ -3451,7 +3448,7 @@ static int show_usage(struct cmd_context *ctx)
return 0;
}
-int main(int argc, char **argp, char **envp)
+int main(int argc, char **argp)
{
int (*func)(struct cmd_context *);
int want_device;