From 70943b52befd3dfd0de276aebd5f771bbf4e6fbc Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 1 Jun 2012 23:08:21 +0100 Subject: 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 --- internal.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'internal.h') 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__) -- cgit v1.2.1