* [PATCH 1/2] multipath/tests: fix hwtable tests after "hidden" support
2018-10-02 18:46 [PATCH 0/2] multipath-tools: unit test fixes Martin Wilck
@ 2018-10-02 18:47 ` Martin Wilck
2018-10-02 18:47 ` [PATCH 2/2] multipath-tools: tests/hwtable: test hidden devices Martin Wilck
1 sibling, 0 replies; 3+ messages in thread
From: Martin Wilck @ 2018-10-02 18:47 UTC (permalink / raw)
To: Christophe Varoqui; +Cc: Martin Wilck, dm-devel
The previous patch "libmultipath: pathinfo: skip hidden devices"
requires a change in the pathinfo mocking code. Otherwise the hwtable
tests will fail.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
tests/test-lib.c | 6 ++++++
tests/test-lib.h | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/tests/test-lib.c b/tests/test-lib.c
index cff7a5d1..59275163 100644
--- a/tests/test-lib.c
+++ b/tests/test-lib.c
@@ -248,6 +248,12 @@ static void mock_sysfs_pathinfo(const struct mocked_path *mp)
*/
void mock_pathinfo(int mask, const struct mocked_path *mp)
{
+ if (mp->flags & DEV_HIDDEN) {
+ will_return(__wrap_udev_device_get_sysattr_value, "1");
+ return;
+ } else
+ will_return(__wrap_udev_device_get_sysattr_value, "0");
+
/* filter_property */
will_return(__wrap_udev_device_get_sysname, mp->devnode);
if (mp->flags & BL_BY_PROPERTY) {
diff --git a/tests/test-lib.h b/tests/test-lib.h
index d2745979..7643ab67 100644
--- a/tests/test-lib.h
+++ b/tests/test-lib.h
@@ -14,7 +14,8 @@ enum {
BL_MASK = BL_BY_DEVNODE|BL_BY_DEVICE|BL_BY_WWID|BL_BY_PROPERTY,
NEED_SELECT_PRIO = (1 << 8),
NEED_FD = (1 << 9),
- USE_GETUID = (1 << 10)
+ USE_GETUID = (1 << 10),
+ DEV_HIDDEN = (1 << 11),
};
struct mocked_path {
--
2.19.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] multipath-tools: tests/hwtable: test hidden devices
2018-10-02 18:46 [PATCH 0/2] multipath-tools: unit test fixes Martin Wilck
2018-10-02 18:47 ` [PATCH 1/2] multipath/tests: fix hwtable tests after "hidden" support Martin Wilck
@ 2018-10-02 18:47 ` Martin Wilck
1 sibling, 0 replies; 3+ messages in thread
From: Martin Wilck @ 2018-10-02 18:47 UTC (permalink / raw)
To: Christophe Varoqui; +Cc: Martin Wilck, dm-devel
Add a test for skipping "hidden" devices.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
tests/hwtable.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tests/hwtable.c b/tests/hwtable.c
index 42127adf..9146ecc3 100644
--- a/tests/hwtable.c
+++ b/tests/hwtable.c
@@ -1661,6 +1661,24 @@ static int setup_multipath_config_3(void **state)
return 0;
}
+/*
+ * Test for device with "hidden" attribute
+ */
+static void test_hidden(const struct hwt_state *hwt)
+{
+ mock_path_flags("NVME", "NoName", DEV_HIDDEN|BL_MASK);
+}
+
+static int setup_hidden(void **state)
+{
+ struct hwt_state *hwt = CHECK_STATE(state);
+
+ WRITE_EMPTY_CONF(hwt);
+ SET_TEST_FUNC(hwt, test_hidden);
+
+ return 0;
+}
+
/*
* Create wrapper functions around test_driver() to avoid that cmocka
* always uses the same test name. That makes it easier to read test results.
@@ -1703,6 +1721,7 @@ define_test(product_blacklist_matching)
define_test(multipath_config)
define_test(multipath_config_2)
define_test(multipath_config_3)
+define_test(hidden)
#define test_entry(x) \
cmocka_unit_test_setup(run_##x, setup_##x)
@@ -1742,6 +1761,7 @@ static int test_hwtable(void)
test_entry(multipath_config),
test_entry(multipath_config_2),
test_entry(multipath_config_3),
+ test_entry(hidden),
};
return cmocka_run_group_tests(tests, setup, teardown);
--
2.19.0
^ permalink raw reply related [flat|nested] 3+ messages in thread