[libvirt] [PATCH 0/3] storagepoolxml2argvtest: delete some lines

Also fix the build on FreeBSD Ján Tomko (3): storagepoolxml2argvtest: pass the platform suffix as a string storagepoolxml2argvtest: introduce DO_TEST_PLATFORM storagepoolxml2argvtest: run mountopts test conditionally tests/storagepoolxml2argvtest.c | 76 +++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 48 deletions(-) -- 2.16.4

Instead of a pair of bools. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/storagepoolxml2argvtest.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c index 786fb26402..2c5e385d2b 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -96,8 +96,7 @@ testCompareXMLToArgvFiles(bool shouldFail, struct testInfo { bool shouldFail; const char *pool; - bool linuxOut; - bool freebsdOut; + const char *platformSuffix; }; static int @@ -112,19 +111,10 @@ testCompareXMLToArgvHelper(const void *data) abs_srcdir, info->pool) < 0) goto cleanup; - if (info->linuxOut) { - if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s-linux.argv", - abs_srcdir, info->pool) < 0 && !info->shouldFail) - goto cleanup; - } else if (info->freebsdOut) { - if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s-freebsd.argv", - abs_srcdir, info->pool) < 0 && !info->shouldFail) - goto cleanup; - } else { - if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s.argv", - abs_srcdir, info->pool) < 0 && !info->shouldFail) - goto cleanup; - } + if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s%s.argv", + abs_srcdir, info->pool, info->platformSuffix) < 0 && + !info->shouldFail) + goto cleanup; result = testCompareXMLToArgvFiles(info->shouldFail, poolxml, cmdline); @@ -141,9 +131,9 @@ mymain(void) { int ret = 0; -#define DO_TEST_FULL(shouldFail, pool, linuxOut, freebsdOut) \ +#define DO_TEST_FULL(shouldFail, pool, platformSuffix) \ do { \ - struct testInfo info = { shouldFail, pool, linuxOut, freebsdOut }; \ + struct testInfo info = { shouldFail, pool, platformSuffix }; \ if (virTestRun("Storage Pool XML-2-argv " pool, \ testCompareXMLToArgvHelper, &info) < 0) \ ret = -1; \ @@ -151,16 +141,16 @@ mymain(void) while (0); #define DO_TEST(pool, ...) \ - DO_TEST_FULL(false, pool, false, false) + DO_TEST_FULL(false, pool, "") #define DO_TEST_FAIL(pool, ...) \ - DO_TEST_FULL(true, pool, false, false) + DO_TEST_FULL(true, pool, "") #define DO_TEST_LINUX(pool, ...) \ - DO_TEST_FULL(false, pool, true, false) + DO_TEST_FULL(false, pool, "-linux") #define DO_TEST_FREEBSD(pool, ...) \ - DO_TEST_FULL(false, pool, false, true) + DO_TEST_FULL(false, pool, "-freebsd") if (storageRegisterAll() < 0) return EXIT_FAILURE; -- 2.16.4

Instead of repeating the same platform for every test, set it once, since we do the same tests with the same input for all platforms, it's just the output that differs. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/storagepoolxml2argvtest.c | 48 ++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c index 2c5e385d2b..0b2c2e4f98 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -130,6 +130,13 @@ static int mymain(void) { int ret = 0; +#ifdef __linux__ + const char *platform = "-linux"; +#elif defined(__FreeBSD__) + const char *platform = "-freebsd"; +#else + const char *platform = ""; +#endif #define DO_TEST_FULL(shouldFail, pool, platformSuffix) \ do { \ @@ -146,11 +153,8 @@ mymain(void) #define DO_TEST_FAIL(pool, ...) \ DO_TEST_FULL(true, pool, "") -#define DO_TEST_LINUX(pool, ...) \ - DO_TEST_FULL(false, pool, "-linux") - -#define DO_TEST_FREEBSD(pool, ...) \ - DO_TEST_FULL(false, pool, "-freebsd") +#define DO_TEST_PLATFORM(pool, ...) \ + DO_TEST_FULL(false, pool, platform) if (storageRegisterAll() < 0) return EXIT_FAILURE; @@ -165,31 +169,15 @@ mymain(void) DO_TEST_FAIL("pool-disk-device-nopartsep"); DO_TEST_FAIL("pool-iscsi"); DO_TEST_FAIL("pool-iscsi-auth"); -#ifdef __linux__ - DO_TEST_LINUX("pool-fs"); - DO_TEST_LINUX("pool-netfs"); - DO_TEST_LINUX("pool-netfs-auto"); - DO_TEST_LINUX("pool-netfs-protocol-ver"); - DO_TEST_LINUX("pool-netfs-ns-mountopts"); - DO_TEST_LINUX("pool-netfs-gluster"); - DO_TEST_LINUX("pool-netfs-cifs"); -#elif defined(__FreeBSD__) - DO_TEST_FREEBSD("pool-fs"); - DO_TEST_FREEBSD("pool-netfs"); - DO_TEST_FREEBSD("pool-netfs-auto"); - DO_TEST_FREEBSD("pool-netfs-protocol-ver"); - DO_TEST_FREEBSD("pool-netfs-ns-mountopts"); - DO_TEST_FREEBSD("pool-netfs-gluster"); - DO_TEST_FREEBSD("pool-netfs-cifs"); -#else - DO_TEST("pool-fs"); - DO_TEST("pool-netfs"); - DO_TEST("pool-netfs-auto"); - DO_TEST("pool-netfs-protocol-ver"); - DO_TEST("pool-netfs-ns-mountopts"); - DO_TEST("pool-netfs-gluster"); - DO_TEST("pool-netfs-cifs"); -#endif + + DO_TEST_PLATFORM("pool-fs"); + DO_TEST_PLATFORM("pool-netfs"); + DO_TEST_PLATFORM("pool-netfs-auto"); + DO_TEST_PLATFORM("pool-netfs-protocol-ver"); + DO_TEST_PLATFORM("pool-netfs-ns-mountopts"); + DO_TEST_PLATFORM("pool-netfs-gluster"); + DO_TEST_PLATFORM("pool-netfs-cifs"); + DO_TEST_FAIL("pool-scsi"); DO_TEST_FAIL("pool-scsi-type-scsi-host"); DO_TEST_FAIL("pool-scsi-type-fc-host"); -- 2.16.4

This test relies on namespace support, which is only compiled in if we have the 'fs' and 'netfs' backends. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/storagepoolxml2argvtest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c index 0b2c2e4f98..e7f42dc0f8 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -174,7 +174,9 @@ mymain(void) DO_TEST_PLATFORM("pool-netfs"); DO_TEST_PLATFORM("pool-netfs-auto"); DO_TEST_PLATFORM("pool-netfs-protocol-ver"); +#if WITH_STORAGE_FS DO_TEST_PLATFORM("pool-netfs-ns-mountopts"); +#endif DO_TEST_PLATFORM("pool-netfs-gluster"); DO_TEST_PLATFORM("pool-netfs-cifs"); -- 2.16.4

On Thu, 2019-01-31 at 15:54 +0100, Ján Tomko wrote:
Also fix the build on FreeBSD
Ján Tomko (3): storagepoolxml2argvtest: pass the platform suffix as a string storagepoolxml2argvtest: introduce DO_TEST_PLATFORM storagepoolxml2argvtest: run mountopts test conditionally
tests/storagepoolxml2argvtest.c | 76 +++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 48 deletions(-)
I love it. Assuming you have compile-tested the series on the relevant platforms, which I can't really be bothered doing right now, you can sprinkle it with some Reviewed-by: Andrea Bolognani <abologna@redhat.com> and push away. -- Andrea Bolognani / Red Hat / Virtualization

Andrea Bolognani wrote:
On Thu, 2019-01-31 at 15:54 +0100, Ján Tomko wrote:
Also fix the build on FreeBSD
Ján Tomko (3): storagepoolxml2argvtest: pass the platform suffix as a string storagepoolxml2argvtest: introduce DO_TEST_PLATFORM storagepoolxml2argvtest: run mountopts test conditionally
tests/storagepoolxml2argvtest.c | 76 +++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 48 deletions(-)
I love it.
Assuming you have compile-tested the series on the relevant platforms, which I can't really be bothered doing right now, you can sprinkle it with some
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
and push away.
-- Andrea Bolognani / Red Hat / Virtualization
FWIW, make check passes on FreeBSD with this series applied. Roman Bogorodskiy
participants (3)
-
Andrea Bolognani
-
Ján Tomko
-
Roman Bogorodskiy