提交 9c2ccd64 编写于 作者: M Michal Privoznik

viriscsitest: Introduce testIscsiadmCbData struct

Some tests will want to pass their own callback data into the
testIscsiadmCbData callback. Introduce testIscsiadmCbData struct
to give this some form and order.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 e97cd364
......@@ -60,6 +60,10 @@ const char *iscsiadmSendtargetsOutput =
"10.20.30.40:3260,1 iqn.2008-04.example:example1:iscsi.bar\n"
"10.20.30.40:3260,1 iqn.2009-04.example:example1:iscsi.seven\n";
struct testIscsiadmCbData {
bool output_version;
};
static void testIscsiadmCb(const char *const*args,
const char *const*env ATTRIBUTE_UNUSED,
const char *input ATTRIBUTE_UNUSED,
......@@ -68,12 +72,13 @@ static void testIscsiadmCb(const char *const*args,
int *status,
void *opaque)
{
int *output_version = opaque;
struct testIscsiadmCbData *data = opaque;
if (args[0] && STREQ(args[0], ISCSIADM) &&
args[1] && STREQ(args[1], "--mode") &&
args[2] && STREQ(args[2], "session") &&
args[3] == NULL) {
if (*output_version == 1)
if (data->output_version)
ignore_value(VIR_STRDUP(*output, iscsiadmSessionOutputNonFlash));
else
ignore_value(VIR_STRDUP(*output, iscsiadmSessionOutput));
......@@ -114,7 +119,7 @@ static void testIscsiadmCb(const char *const*args,
struct testSessionInfo {
const char *device_path;
int output_version;
bool output_version;
const char *expected_session;
};
......@@ -122,11 +127,13 @@ static int
testISCSIGetSession(const void *data)
{
const struct testSessionInfo *info = data;
int ver = info->output_version;
struct testIscsiadmCbData cbData = { 0 };
char *actual_session = NULL;
int ret = -1;
virCommandSetDryRun(NULL, testIscsiadmCb, &ver);
cbData.output_version = info->output_version;
virCommandSetDryRun(NULL, testIscsiadmCb, &cbData);
actual_session = virISCSIGetSession(info->device_path, true);
......@@ -227,11 +234,11 @@ mymain(void)
# define DO_SESSION_TEST(name, session) \
do { \
struct testSessionInfo info = {name, 0, session}; \
struct testSessionInfo info = {name, false, session}; \
if (virTestRun("ISCSI get session test" name, \
testISCSIGetSession, &info) < 0) \
rv = -1; \
info.output_version = 1; \
info.output_version = true; \
if (virTestRun("ISCSI get (non-flash) session test" name, \
testISCSIGetSession, &info) < 0) \
rv = -1; \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册