dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity
@ 2021-02-11 23:46 mwilck
  2021-02-11 23:46 ` [dm-devel] [PATCH 2/4] multipath-tools: devt test: avoid failure when run in containers mwilck
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: mwilck @ 2021-02-11 23:46 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski
  Cc: dm-devel, Xose Vazquez Perez, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

Use common code to control verbosity during unit tests runs.
The environment variable MPATHTEST_VERBOSITY is honored by most
tests, except those that need to parse the log messages or have
other special needs.

Also, get rid of the now obsolete global variables logsink and
udev, as these are now defined in libmultipath.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 tests/README.md   |  5 +++++
 tests/alias.c     |  2 +-
 tests/blacklist.c |  2 +-
 tests/devt.c      |  1 +
 tests/directio.c  |  2 +-
 tests/dmevents.c  |  1 +
 tests/globals.c   | 27 +++++++++++++++++++++------
 tests/hwtable.c   |  2 ++
 tests/parser.c    |  1 +
 tests/pgpolicy.c  |  1 +
 tests/uevent.c    |  1 +
 tests/unaligned.c |  1 +
 tests/util.c      |  1 +
 tests/valid.c     |  2 ++
 tests/vpd.c       |  1 +
 15 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/tests/README.md b/tests/README.md
index 6e7ad40..47c0f0b 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -13,6 +13,11 @@ If valgrind detects a bad memory access or leak, the test will fail. The
 output of the test run, including valgrind output, is stored as
 `<testname>.vgr`.
 
+## Controlling verbosity for unit tests
+
+Some test programs use the environment variable `MPATHTEST_VERBOSITY` to
+control the log level during test execution.
+
 ## Notes on individual tests
 
 ### Tests that require root permissions
diff --git a/tests/alias.c b/tests/alias.c
index 5e0bfea..b363718 100644
--- a/tests/alias.c
+++ b/tests/alias.c
@@ -736,7 +736,7 @@ static int test_allocate_binding(void)
 int main(void)
 {
 	int ret = 0;
-	libmp_verbosity = conf.verbosity;
+	init_test_verbosity(3);
 
 	ret += test_format_devname();
 	ret += test_scan_devname();
diff --git a/tests/blacklist.c b/tests/blacklist.c
index 0b42e25..882aa3a 100644
--- a/tests/blacklist.c
+++ b/tests/blacklist.c
@@ -153,7 +153,7 @@ static int setup(void **state)
 	    store_ble(blist_property_wwn_inv, "!ID_WWN", ORIGIN_CONFIG))
 		return -1;
 
-	libmp_verbosity = conf.verbosity = 4;
+	init_test_verbosity(4);
 	return 0;
 }
 
diff --git a/tests/devt.c b/tests/devt.c
index fd4d74a..2b72851 100644
--- a/tests/devt.c
+++ b/tests/devt.c
@@ -187,6 +187,7 @@ int main(void)
 {
 	int ret = 0;
 
+	init_test_verbosity(-1);
 	ret += devt2devname_tests();
 	return ret;
 }
diff --git a/tests/directio.c b/tests/directio.c
index 9895409..9f7d388 100644
--- a/tests/directio.c
+++ b/tests/directio.c
@@ -770,7 +770,7 @@ int main(void)
 {
 	int ret = 0;
 
-	conf.verbosity = 2;
+	init_test_verbosity(2);
 	ret += test_directio();
 	return ret;
 }
diff --git a/tests/dmevents.c b/tests/dmevents.c
index 29eaa6d..204cf1d 100644
--- a/tests/dmevents.c
+++ b/tests/dmevents.c
@@ -925,6 +925,7 @@ int main(void)
 {
 	int ret = 0;
 
+	init_test_verbosity(-1);
 	ret += test_dmevents();
 	return ret;
 }
diff --git a/tests/globals.c b/tests/globals.c
index fc0c07a..36319ed 100644
--- a/tests/globals.c
+++ b/tests/globals.c
@@ -1,13 +1,12 @@
+#include <stdlib.h>
+#include <string.h>
+
+#include "defaults.h"
 #include "structs.h"
 #include "config.h"
 #include "debug.h"
 
-/* Required globals */
-struct udev *udev;
-int logsink = LOGSINK_STDERR_WITHOUT_TIME;
-struct config conf = {
-	.verbosity = 4,
-};
+struct config conf;
 
 struct config *get_multipath_config(void)
 {
@@ -16,3 +15,19 @@ struct config *get_multipath_config(void)
 
 void put_multipath_config(void *arg)
 {}
+
+static __attribute__((unused)) void init_test_verbosity(int test_verbosity)
+{
+	char *verb = getenv("MPATHTEST_VERBOSITY");
+
+	libmp_verbosity = test_verbosity >= 0 ? test_verbosity :
+		DEFAULT_VERBOSITY;
+	if (verb && *verb) {
+		char *c;
+		int vb;
+
+		vb = strtoul(verb, &c, 10);
+		if (!*c && vb >= 0 && vb <= 5)
+			libmp_verbosity = vb;
+	}
+}
diff --git a/tests/hwtable.c b/tests/hwtable.c
index 4dd0873..6f5766f 100644
--- a/tests/hwtable.c
+++ b/tests/hwtable.c
@@ -1778,6 +1778,8 @@ int main(void)
 {
 	int ret = 0;
 
+	/* We can't use init_test_verbosity in this test */
+	libmp_verbosity = VERBOSITY;
 	ret += test_hwtable();
 	return ret;
 }
diff --git a/tests/parser.c b/tests/parser.c
index 5772391..cf96d81 100644
--- a/tests/parser.c
+++ b/tests/parser.c
@@ -511,6 +511,7 @@ int main(void)
 {
 	int ret = 0;
 
+	init_test_verbosity(-1);
 	ret += test_config_parser();
 	return ret;
 }
diff --git a/tests/pgpolicy.c b/tests/pgpolicy.c
index 3f61b12..57ad338 100644
--- a/tests/pgpolicy.c
+++ b/tests/pgpolicy.c
@@ -1031,6 +1031,7 @@ int main(void)
 {
 	int ret = 0;
 
+	init_test_verbosity(-1);
 	ret += test_pgpolicies();
 	return ret;
 }
diff --git a/tests/uevent.c b/tests/uevent.c
index 9ffcd2d..648ff26 100644
--- a/tests/uevent.c
+++ b/tests/uevent.c
@@ -322,6 +322,7 @@ int main(void)
 {
 	int ret = 0;
 
+	init_test_verbosity(-1);
 	ret += test_uevent_get_XXX();
 	return ret;
 }
diff --git a/tests/unaligned.c b/tests/unaligned.c
index 7ece1de..e43b64d 100644
--- a/tests/unaligned.c
+++ b/tests/unaligned.c
@@ -91,6 +91,7 @@ int main(void)
 {
 	int ret = 0;
 
+	init_test_verbosity(-1);
 	ret += test_unaligned();
 	return ret;
 }
diff --git a/tests/util.c b/tests/util.c
index c3c49b6..9affb0e 100644
--- a/tests/util.c
+++ b/tests/util.c
@@ -946,6 +946,7 @@ int main(void)
 {
 	int ret = 0;
 
+	init_test_verbosity(-1);
 	ret += test_basenamecpy();
 	ret += test_bitmasks();
 	ret += test_strlcpy();
diff --git a/tests/valid.c b/tests/valid.c
index 8ec803e..e7393a1 100644
--- a/tests/valid.c
+++ b/tests/valid.c
@@ -554,6 +554,8 @@ int test_valid(void)
 int main(void)
 {
 	int ret = 0;
+
+	init_test_verbosity(-1);
 	ret += test_valid();
 	return ret;
 }
diff --git a/tests/vpd.c b/tests/vpd.c
index e2ec65e..8e730d3 100644
--- a/tests/vpd.c
+++ b/tests/vpd.c
@@ -799,6 +799,7 @@ int main(void)
 {
 	int ret = 0;
 
+	init_test_verbosity(-1);
 	ret += test_vpd();
 	return ret;
 }
-- 
2.29.2


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [dm-devel] [PATCH 2/4] multipath-tools: devt test: avoid failure when run in containers
  2021-02-11 23:46 [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity mwilck
@ 2021-02-11 23:46 ` mwilck
  2021-02-11 23:46 ` [dm-devel] [PATCH 3/4] multipath-tools: fix compilation errors on 32-bit musl mwilck
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: mwilck @ 2021-02-11 23:46 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski
  Cc: dm-devel, Xose Vazquez Perez, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

/sys/dev/block is usually unavailable containers, causing libudev
calls to fail. Skip the respective tests.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 tests/devt.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tests/devt.c b/tests/devt.c
index 2b72851..02f2e8f 100644
--- a/tests/devt.c
+++ b/tests/devt.c
@@ -11,11 +11,25 @@
 #include <cmocka.h>
 #include <libudev.h>
 #include <sys/sysmacros.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
 #include "util.h"
 #include "debug.h"
 
 #include "globals.c"
 
+static bool sys_dev_block_exists(void)
+{
+	int fd;
+	bool rc;
+
+	fd = open("/sys/dev/block", O_RDONLY|O_DIRECTORY);
+	rc = (fd != -1);
+	close(fd);
+	return rc;
+}
+
 static int get_one_devt(char *devt, size_t len)
 {
 	struct udev_enumerate *enm;
@@ -71,6 +85,8 @@ static void test_devt2devname_devt_good(void **state)
 {
 	char dummy[BLK_DEV_SIZE];
 
+	if (!sys_dev_block_exists())
+		skip();
 	assert_int_equal(devt2devname(dummy, sizeof(dummy), *state), 0);
 }
 
@@ -137,6 +153,8 @@ static void test_devt2devname_real(void **state)
 	struct udev_list_entry *first, *item;
 	unsigned int i = 0;
 
+	if (!sys_dev_block_exists())
+		skip();
 	enm = udev_enumerate_new(udev);
 	assert_non_null(enm);
 	r = udev_enumerate_add_match_subsystem(enm, "block");
-- 
2.29.2


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [dm-devel] [PATCH 3/4] multipath-tools: fix compilation errors on 32-bit musl
  2021-02-11 23:46 [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity mwilck
  2021-02-11 23:46 ` [dm-devel] [PATCH 2/4] multipath-tools: devt test: avoid failure when run in containers mwilck
@ 2021-02-11 23:46 ` mwilck
  2021-02-11 23:46 ` [dm-devel] [PATCH 4/4] libmultipath: fix compilation error with gcc 10 on i386 mwilck
  2021-02-15 21:39 ` [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity Benjamin Marzinski
  3 siblings, 0 replies; 5+ messages in thread
From: mwilck @ 2021-02-11 23:46 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski
  Cc: dm-devel, Xose Vazquez Perez, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

gcc on alpine Linux/i386 throws errors because the "tv_sec" element
of struct timespec is a time_t, which is a "long long" in that
environment. In general, time_t is signed. As we only use CLOCK_MONOTONIC,
which starts at boot time, a cast to long should be no problem, even
in 32bit environments.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 multipath/main.c    |  2 +-
 multipathd/main.c   | 16 ++++++++--------
 multipathd/uxlsnr.c |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/multipath/main.c b/multipath/main.c
index 9ac4286..3f97582 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -417,7 +417,7 @@ static int print_cmd_valid(int k, const vector pathvec,
 		wait = find_multipaths_check_timeout(pp, 0, &until);
 	if (wait == FIND_MULTIPATHS_WAITING)
 		printf("FIND_MULTIPATHS_WAIT_UNTIL=\"%ld.%06ld\"\n",
-			       until.tv_sec, until.tv_nsec/1000);
+		       (long)until.tv_sec, until.tv_nsec/1000);
 	else if (wait == FIND_MULTIPATHS_WAIT_DONE)
 		printf("FIND_MULTIPATHS_WAIT_UNTIL=\"0\"\n");
 	printf("DM_MULTIPATH_DEVICE_PATH=\"%d\"\n",
diff --git a/multipathd/main.c b/multipathd/main.c
index 1967984..5316643 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -2408,8 +2408,8 @@ checkerloop (void *ap)
 		get_monotonic_time(&start_time);
 		if (start_time.tv_sec && last_time.tv_sec) {
 			timespecsub(&start_time, &last_time, &diff_time);
-			condlog(4, "tick (%lu.%06lu secs)",
-				diff_time.tv_sec, diff_time.tv_nsec / 1000);
+			condlog(4, "tick (%ld.%06lu secs)",
+				(long)diff_time.tv_sec, diff_time.tv_nsec / 1000);
 			last_time = start_time;
 			ticks = diff_time.tv_sec;
 		} else {
@@ -2470,18 +2470,18 @@ checkerloop (void *ap)
 			if (num_paths) {
 				unsigned int max_checkint;
 
-				condlog(4, "checked %d path%s in %lu.%06lu secs",
+				condlog(4, "checked %d path%s in %ld.%06lu secs",
 					num_paths, num_paths > 1 ? "s" : "",
-					diff_time.tv_sec,
+					(long)diff_time.tv_sec,
 					diff_time.tv_nsec / 1000);
 				conf = get_multipath_config();
 				max_checkint = conf->max_checkint;
 				put_multipath_config(conf);
 				if (diff_time.tv_sec > (time_t)max_checkint)
 					condlog(1, "path checkers took longer "
-						"than %lu seconds, consider "
+						"than %ld seconds, consider "
 						"increasing max_polling_interval",
-						diff_time.tv_sec);
+						(long)diff_time.tv_sec);
 			}
 		}
 
@@ -2507,8 +2507,8 @@ checkerloop (void *ap)
 			} else
 				diff_time.tv_sec = 1;
 
-			condlog(3, "waiting for %lu.%06lu secs",
-				diff_time.tv_sec,
+			condlog(3, "waiting for %ld.%06lu secs",
+				(long)diff_time.tv_sec,
 				diff_time.tv_nsec / 1000);
 			if (nanosleep(&diff_time, NULL) != 0) {
 				condlog(3, "nanosleep failed with error %d",
diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c
index cd462b6..dbee0d6 100644
--- a/multipathd/uxlsnr.c
+++ b/multipathd/uxlsnr.c
@@ -154,8 +154,8 @@ static void check_timeout(struct timespec start_time, char *inbuf,
 			diff_time.tv_nsec / (1000 * 1000);
 		if (msecs > timeout)
 			condlog(2, "cli cmd '%s' timeout reached "
-				"after %lu.%06lu secs", inbuf,
-				diff_time.tv_sec, diff_time.tv_nsec / 1000);
+				"after %ld.%06lu secs", inbuf,
+				(long)diff_time.tv_sec, diff_time.tv_nsec / 1000);
 	}
 }
 
-- 
2.29.2


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [dm-devel] [PATCH 4/4] libmultipath: fix compilation error with gcc 10 on i386
  2021-02-11 23:46 [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity mwilck
  2021-02-11 23:46 ` [dm-devel] [PATCH 2/4] multipath-tools: devt test: avoid failure when run in containers mwilck
  2021-02-11 23:46 ` [dm-devel] [PATCH 3/4] multipath-tools: fix compilation errors on 32-bit musl mwilck
@ 2021-02-11 23:46 ` mwilck
  2021-02-15 21:39 ` [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity Benjamin Marzinski
  3 siblings, 0 replies; 5+ messages in thread
From: mwilck @ 2021-02-11 23:46 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski
  Cc: dm-devel, Xose Vazquez Perez, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

gcc complained about a possible negative value of "nr" in the
memcpy() call. I consider that a false positive, but it's easily
fixed.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/sysfs.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c
index 5390de6..7a2af1e 100644
--- a/libmultipath/sysfs.c
+++ b/libmultipath/sysfs.c
@@ -344,24 +344,23 @@ bool sysfs_is_multipathed(struct path *pp, bool set_wwid)
 		pthread_cleanup_push(close_fd, (void *)fd);
 		nr = read(fd, uuid, sizeof(uuid));
 		if (nr > (int)UUID_PREFIX_LEN &&
-		    !memcmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN))
+		    !memcmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN)) {
 			found = true;
-		else if (nr < 0) {
+			if (set_wwid) {
+				nr -= UUID_PREFIX_LEN;
+				memcpy(pp->wwid, uuid + UUID_PREFIX_LEN, nr);
+				if (nr == WWID_SIZE) {
+					condlog(4, "%s: overflow while reading from %s",
+						__func__, pathbuf);
+					pp->wwid[0] = '\0';
+				} else {
+					pp->wwid[nr] = '\0';
+					strchop(pp->wwid);
+				}
+			}
+                } else if (nr < 0)
 			condlog(1, "%s: error reading from %s: %m",
 				__func__, pathbuf);
-		}
-		if (found && set_wwid) {
-			nr -= UUID_PREFIX_LEN;
-			memcpy(pp->wwid, uuid + UUID_PREFIX_LEN, nr);
-			if (nr == WWID_SIZE) {
-				condlog(4, "%s: overflow while reading from %s",
-					__func__, pathbuf);
-				pp->wwid[0] = '\0';
-			} else {
-				pp->wwid[nr] = '\0';
-				strchop(pp->wwid);
-			}
-                }
 
 		pthread_cleanup_pop(1);
 	}
-- 
2.29.2


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity
  2021-02-11 23:46 [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity mwilck
                   ` (2 preceding siblings ...)
  2021-02-11 23:46 ` [dm-devel] [PATCH 4/4] libmultipath: fix compilation error with gcc 10 on i386 mwilck
@ 2021-02-15 21:39 ` Benjamin Marzinski
  3 siblings, 0 replies; 5+ messages in thread
From: Benjamin Marzinski @ 2021-02-15 21:39 UTC (permalink / raw)
  To: mwilck; +Cc: dm-devel, Xose Vazquez Perez

On Fri, Feb 12, 2021 at 12:46:47AM +0100, mwilck@suse.com wrote:
> From: Martin Wilck <mwilck@suse.com>
> 
> Use common code to control verbosity during unit tests runs.
> The environment variable MPATHTEST_VERBOSITY is honored by most
> tests, except those that need to parse the log messages or have
> other special needs.
> 
> Also, get rid of the now obsolete global variables logsink and
> udev, as these are now defined in libmultipath.
> 

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>

For the set.

> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  tests/README.md   |  5 +++++
>  tests/alias.c     |  2 +-
>  tests/blacklist.c |  2 +-
>  tests/devt.c      |  1 +
>  tests/directio.c  |  2 +-
>  tests/dmevents.c  |  1 +
>  tests/globals.c   | 27 +++++++++++++++++++++------
>  tests/hwtable.c   |  2 ++
>  tests/parser.c    |  1 +
>  tests/pgpolicy.c  |  1 +
>  tests/uevent.c    |  1 +
>  tests/unaligned.c |  1 +
>  tests/util.c      |  1 +
>  tests/valid.c     |  2 ++
>  tests/vpd.c       |  1 +
>  15 files changed, 41 insertions(+), 9 deletions(-)
> 
> diff --git a/tests/README.md b/tests/README.md
> index 6e7ad40..47c0f0b 100644
> --- a/tests/README.md
> +++ b/tests/README.md
> @@ -13,6 +13,11 @@ If valgrind detects a bad memory access or leak, the test will fail. The
>  output of the test run, including valgrind output, is stored as
>  `<testname>.vgr`.
>  
> +## Controlling verbosity for unit tests
> +
> +Some test programs use the environment variable `MPATHTEST_VERBOSITY` to
> +control the log level during test execution.
> +
>  ## Notes on individual tests
>  
>  ### Tests that require root permissions
> diff --git a/tests/alias.c b/tests/alias.c
> index 5e0bfea..b363718 100644
> --- a/tests/alias.c
> +++ b/tests/alias.c
> @@ -736,7 +736,7 @@ static int test_allocate_binding(void)
>  int main(void)
>  {
>  	int ret = 0;
> -	libmp_verbosity = conf.verbosity;
> +	init_test_verbosity(3);
>  
>  	ret += test_format_devname();
>  	ret += test_scan_devname();
> diff --git a/tests/blacklist.c b/tests/blacklist.c
> index 0b42e25..882aa3a 100644
> --- a/tests/blacklist.c
> +++ b/tests/blacklist.c
> @@ -153,7 +153,7 @@ static int setup(void **state)
>  	    store_ble(blist_property_wwn_inv, "!ID_WWN", ORIGIN_CONFIG))
>  		return -1;
>  
> -	libmp_verbosity = conf.verbosity = 4;
> +	init_test_verbosity(4);
>  	return 0;
>  }
>  
> diff --git a/tests/devt.c b/tests/devt.c
> index fd4d74a..2b72851 100644
> --- a/tests/devt.c
> +++ b/tests/devt.c
> @@ -187,6 +187,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> +	init_test_verbosity(-1);
>  	ret += devt2devname_tests();
>  	return ret;
>  }
> diff --git a/tests/directio.c b/tests/directio.c
> index 9895409..9f7d388 100644
> --- a/tests/directio.c
> +++ b/tests/directio.c
> @@ -770,7 +770,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> -	conf.verbosity = 2;
> +	init_test_verbosity(2);
>  	ret += test_directio();
>  	return ret;
>  }
> diff --git a/tests/dmevents.c b/tests/dmevents.c
> index 29eaa6d..204cf1d 100644
> --- a/tests/dmevents.c
> +++ b/tests/dmevents.c
> @@ -925,6 +925,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> +	init_test_verbosity(-1);
>  	ret += test_dmevents();
>  	return ret;
>  }
> diff --git a/tests/globals.c b/tests/globals.c
> index fc0c07a..36319ed 100644
> --- a/tests/globals.c
> +++ b/tests/globals.c
> @@ -1,13 +1,12 @@
> +#include <stdlib.h>
> +#include <string.h>
> +
> +#include "defaults.h"
>  #include "structs.h"
>  #include "config.h"
>  #include "debug.h"
>  
> -/* Required globals */
> -struct udev *udev;
> -int logsink = LOGSINK_STDERR_WITHOUT_TIME;
> -struct config conf = {
> -	.verbosity = 4,
> -};
> +struct config conf;
>  
>  struct config *get_multipath_config(void)
>  {
> @@ -16,3 +15,19 @@ struct config *get_multipath_config(void)
>  
>  void put_multipath_config(void *arg)
>  {}
> +
> +static __attribute__((unused)) void init_test_verbosity(int test_verbosity)
> +{
> +	char *verb = getenv("MPATHTEST_VERBOSITY");
> +
> +	libmp_verbosity = test_verbosity >= 0 ? test_verbosity :
> +		DEFAULT_VERBOSITY;
> +	if (verb && *verb) {
> +		char *c;
> +		int vb;
> +
> +		vb = strtoul(verb, &c, 10);
> +		if (!*c && vb >= 0 && vb <= 5)
> +			libmp_verbosity = vb;
> +	}
> +}
> diff --git a/tests/hwtable.c b/tests/hwtable.c
> index 4dd0873..6f5766f 100644
> --- a/tests/hwtable.c
> +++ b/tests/hwtable.c
> @@ -1778,6 +1778,8 @@ int main(void)
>  {
>  	int ret = 0;
>  
> +	/* We can't use init_test_verbosity in this test */
> +	libmp_verbosity = VERBOSITY;
>  	ret += test_hwtable();
>  	return ret;
>  }
> diff --git a/tests/parser.c b/tests/parser.c
> index 5772391..cf96d81 100644
> --- a/tests/parser.c
> +++ b/tests/parser.c
> @@ -511,6 +511,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> +	init_test_verbosity(-1);
>  	ret += test_config_parser();
>  	return ret;
>  }
> diff --git a/tests/pgpolicy.c b/tests/pgpolicy.c
> index 3f61b12..57ad338 100644
> --- a/tests/pgpolicy.c
> +++ b/tests/pgpolicy.c
> @@ -1031,6 +1031,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> +	init_test_verbosity(-1);
>  	ret += test_pgpolicies();
>  	return ret;
>  }
> diff --git a/tests/uevent.c b/tests/uevent.c
> index 9ffcd2d..648ff26 100644
> --- a/tests/uevent.c
> +++ b/tests/uevent.c
> @@ -322,6 +322,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> +	init_test_verbosity(-1);
>  	ret += test_uevent_get_XXX();
>  	return ret;
>  }
> diff --git a/tests/unaligned.c b/tests/unaligned.c
> index 7ece1de..e43b64d 100644
> --- a/tests/unaligned.c
> +++ b/tests/unaligned.c
> @@ -91,6 +91,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> +	init_test_verbosity(-1);
>  	ret += test_unaligned();
>  	return ret;
>  }
> diff --git a/tests/util.c b/tests/util.c
> index c3c49b6..9affb0e 100644
> --- a/tests/util.c
> +++ b/tests/util.c
> @@ -946,6 +946,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> +	init_test_verbosity(-1);
>  	ret += test_basenamecpy();
>  	ret += test_bitmasks();
>  	ret += test_strlcpy();
> diff --git a/tests/valid.c b/tests/valid.c
> index 8ec803e..e7393a1 100644
> --- a/tests/valid.c
> +++ b/tests/valid.c
> @@ -554,6 +554,8 @@ int test_valid(void)
>  int main(void)
>  {
>  	int ret = 0;
> +
> +	init_test_verbosity(-1);
>  	ret += test_valid();
>  	return ret;
>  }
> diff --git a/tests/vpd.c b/tests/vpd.c
> index e2ec65e..8e730d3 100644
> --- a/tests/vpd.c
> +++ b/tests/vpd.c
> @@ -799,6 +799,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> +	init_test_verbosity(-1);
>  	ret += test_vpd();
>  	return ret;
>  }
> -- 
> 2.29.2

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-15 21:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-11 23:46 [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity mwilck
2021-02-11 23:46 ` [dm-devel] [PATCH 2/4] multipath-tools: devt test: avoid failure when run in containers mwilck
2021-02-11 23:46 ` [dm-devel] [PATCH 3/4] multipath-tools: fix compilation errors on 32-bit musl mwilck
2021-02-11 23:46 ` [dm-devel] [PATCH 4/4] libmultipath: fix compilation error with gcc 10 on i386 mwilck
2021-02-15 21:39 ` [dm-devel] [PATCH 1/4] multipath-tools tests: allow control of test verbosity Benjamin Marzinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).