summaryrefslogtreecommitdiff
path: root/internal.h
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2012-06-01 23:08:21 +0100
committerBen Hutchings <bhutchings@solarflare.com>2012-06-01 23:20:35 +0100
commit70943b52befd3dfd0de276aebd5f771bbf4e6fbc (patch)
treedcb73ac8179521226626258d8f229ffa4a474619 /internal.h
parent2038e9ecde330cb82eb368725034b21d30de91fc (diff)
downloadethtool-70943b52befd3dfd0de276aebd5f771bbf4e6fbc.tar.gz
test: Add test_ioctl() function to support a mock send_ioctl()
test_ioctl() verifies an ethtool ioctl structure and either returns a canned response (if it was as expected) or aborts the test. Adjust the file redirection in test_cmdline() so that test_ioctl() can always print error messages. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'internal.h')
-rw-r--r--internal.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/internal.h b/internal.h
index b013783..0fff2a5 100644
--- a/internal.h
+++ b/internal.h
@@ -103,6 +103,16 @@ struct cmd_context {
#ifdef TEST_ETHTOOL
int test_cmdline(const char *args);
+struct cmd_expect {
+ const void *cmd; /* expected command; NULL at end of list */
+ size_t cmd_len; /* length to match (might be < sizeof struct) */
+ int rc; /* kernel return code */
+ const void *resp; /* response to write back; may be NULL */
+ size_t resp_len; /* length to write back */
+};
+int test_ioctl(const struct cmd_expect *expect, void *cmd);
+#define TEST_IOCTL_MISMATCH (-2)
+
#ifndef TEST_NO_WRAPPERS
int test_main(int argc, char **argp);
#define main(...) test_main(__VA_ARGS__)