[libvirt] [PATCHv2 8/8] Add test for virISCSIScanTargets

Daniel P. Berrange berrange at redhat.com
Thu Mar 20 15:01:16 UTC 2014


On Wed, Mar 19, 2014 at 04:52:33PM +0100, Ján Tomko wrote:
> ---
>  tests/viriscsitest.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 82 insertions(+)
> 
> diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c
> index 0b09834..16a40c7 100644
> --- a/tests/viriscsitest.c
> +++ b/tests/viriscsitest.c
> @@ -51,6 +51,14 @@ static const char *iscsiadmSessionOutputNonFlash =
>  "tcp: [6] 10.20.30.44:3260,1 iqn.2008-04.example:example1:iscsi.bar (non-flash)\n"
>  "tcp: [7] 10.20.30.45:3260,1 iqn.2009-04.example:example1:iscsi.seven (non-flash)\n";
>  
> +const char *iscsiadmSendtargetsOutput =
> +"10.20.30.40:3260,1 iqn.2004-06.example:example1:iscsi.test\n"
> +"10.20.30.40:3260,1 iqn.2005-05.example:example1:iscsi.hello\n"
> +"10.20.30.40:3260,1 iqn.2006-04.example:example1:iscsi.world\n"
> +"10.20.30.40:3260,1 iqn.2007-04.example:example1:iscsi.foo\n"
> +"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";

Same note about indenting the strings relative to the variable dcl.

> +
>  struct testSessionInfo {
>      const char *device_path;
>      int output_version;
> @@ -74,6 +82,15 @@ static void testIscsiadmCb(const char *const*args,
>              ignore_value(VIR_STRDUP(*output, iscsiadmSessionOutputNonFlash));
>          else
>              ignore_value(VIR_STRDUP(*output, iscsiadmSessionOutput));
> +    } else if (args[0] && STREQ(args[0], ISCSIADM) &&
> +               args[1] && STREQ(args[1], "--mode") &&
> +               args[2] && STREQ(args[2], "discovery") &&
> +               args[3] && STREQ(args[3], "--type") &&
> +               args[4] && STREQ(args[4], "sendtargets") &&
> +               args[5] && STREQ(args[5], "--portal") &&
> +               args[6] && STREQ(args[6], "10.20.30.40:3260,1") &&
> +               args[7] == NULL) {

I find myself doing a similar with to compare args. I wonder if we
should create a virStringListIsEqual() helper function for comparing
a char ** against a statically declared args list.

ACK because such a refactoring can be separately done any time.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list