kpartx: fix bad dm_devn return
[multipath-tools/.git] / tests / hwtable.c
index 1a6b318..42127ad 100644 (file)
@@ -499,13 +499,8 @@ static void replicate_config(const struct hwt_state *hwt, bool local)
        DUMP_CFG_STR(cfg2);
 #endif
 
-#if BROKEN
-       condlog(1, "%s: WARNING: skipping tests for same configuration after dump/reload on %d",
-               __func__, __LINE__);
-#else
        assert_int_equal(strlen(cfg2), strlen(cfg1));
        assert_string_equal(cfg2, cfg1);
-#endif
        free(cfg1);
        free(cfg2);
 }
@@ -603,18 +598,10 @@ static int setup_internal_nvme(void **state)
 /*
  * Device section with a simple entry qith double quotes ('foo:"bar"')
  */
-#if BROKEN
-static void test_quoted_hwe(void **state)
-#else
 static void test_quoted_hwe(const struct hwt_state *hwt)
-#endif
 {
        struct path *pp;
-#if BROKEN
-       struct hwt_state *hwt = CHECK_STATE(state);
 
-       _conf = LOAD_CONFIG(hwt);
-#endif
        /* foo:"bar" matches */
        pp = mock_path(vnd_foo.value, prd_baq.value);
        TEST_PROP(prio_name(&pp->prio), prio_emc.value);
@@ -630,11 +617,7 @@ static int setup_quoted_hwe(void **state)
        const struct key_value kv[] = { vnd_foo, prd_baqq, prio_emc };
 
        WRITE_ONE_DEVICE(hwt, kv);
-#if BROKEN
-       condlog(0, "%s: WARNING: skipping conf reload test", __func__);
-#else
        SET_TEST_FUNC(hwt, test_quoted_hwe);
-#endif
        return 0;
 }
 
@@ -668,6 +651,51 @@ static int setup_string_hwe(void **state)
        return 0;
 }
 
+/*
+ * Device section with a broken entry (no product)
+ * It should be ignored.
+ */
+static void test_broken_hwe(const struct hwt_state *hwt)
+{
+       struct path *pp;
+
+       /* foo:bar doesn't match, as hwentry is ignored */
+       pp = mock_path(vnd_foo.value, prd_bar.value);
+       TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
+
+       /* boo:bar doesn't match */
+       pp = mock_path(vnd_boo.value, prd_bar.value);
+       TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
+}
+
+static int setup_broken_hwe(void **state)
+{
+       struct hwt_state *hwt = CHECK_STATE(state);
+       const struct key_value kv[] = { vnd_foo, prio_emc };
+
+       WRITE_ONE_DEVICE(hwt, kv);
+       SET_TEST_FUNC(hwt, test_broken_hwe);
+       return 0;
+}
+
+/*
+ * Like test_broken_hwe, but in config_dir file.
+ */
+static int setup_broken_hwe_dir(void **state)
+{
+       struct hwt_state *hwt = CHECK_STATE(state);
+       const struct key_value kv[] = { vnd_foo, prio_emc };
+
+       begin_config(hwt);
+       begin_section_all(hwt, "devices");
+       write_device(hwt->conf_dir_file[0], ARRAY_SIZE(kv), kv);
+       end_section_all(hwt);
+       finish_config(hwt);
+       hwt->test = test_broken_hwe;
+       hwt->test_name = "test_broken_hwe_dir";
+       return 0;
+}
+
 /*
  * Device section with a single regex entry ("^.foo:(bar|baz|ba\.)$")
  */
@@ -1567,8 +1595,6 @@ static int setup_multipath_config(void **state)
  *
  * Expected: properties are taken from both multipath sections, later taking
  * precedence
- *
- * Current: gets properties from first entry only.
  */
 static void test_multipath_config_2(const struct hwt_state *hwt)
 {
@@ -1580,15 +1606,8 @@ static void test_multipath_config_2(const struct hwt_state *hwt)
        assert_ptr_not_equal(mp, NULL);
        assert_ptr_not_equal(mp->mpe, NULL);
        TEST_PROP(prio_name(&pp->prio), prio_rdac.value);
-#if BROKEN
-       condlog(1, "%s: WARNING: broken test on %d", __func__, __LINE__ + 1);
-       assert_int_equal(mp->minio, DEFAULT_MINIO_RQ);
-       condlog(1, "%s: WARNING: broken test on %d", __func__, __LINE__ + 1);
-       assert_int_equal(mp->no_path_retry, NO_PATH_RETRY_QUEUE);
-#else
        assert_int_equal(mp->minio, atoi(minio_99.value));
        assert_int_equal(mp->no_path_retry, atoi(npr_37.value));
-#endif
 }
 
 static int setup_multipath_config_2(void **state)
@@ -1622,15 +1641,8 @@ static void test_multipath_config_3(const struct hwt_state *hwt)
        assert_ptr_not_equal(mp, NULL);
        assert_ptr_not_equal(mp->mpe, NULL);
        TEST_PROP(prio_name(&pp->prio), prio_rdac.value);
-#if BROKEN
-       condlog(1, "%s: WARNING: broken test on %d", __func__, __LINE__ + 1);
-       assert_int_equal(mp->minio, DEFAULT_MINIO_RQ);
-       condlog(1, "%s: WARNING: broken test on %d", __func__, __LINE__ + 1);
-       assert_int_equal(mp->no_path_retry, NO_PATH_RETRY_QUEUE);
-#else
        assert_int_equal(mp->minio, atoi(minio_99.value));
        assert_int_equal(mp->no_path_retry, atoi(npr_37.value));
-#endif
 }
 
 static int setup_multipath_config_3(void **state)
@@ -1661,9 +1673,9 @@ static int setup_multipath_config_3(void **state)
        }
 
 define_test(string_hwe)
-#if !BROKEN
+define_test(broken_hwe)
+define_test(broken_hwe_dir)
 define_test(quoted_hwe)
-#endif
 define_test(internal_nvme)
 define_test(regex_hwe)
 define_test(regex_string_hwe)
@@ -1701,11 +1713,9 @@ static int test_hwtable(void)
                cmocka_unit_test(test_sanity_globals),
                test_entry(internal_nvme),
                test_entry(string_hwe),
-#if BROKEN
-               cmocka_unit_test_setup(test_quoted_hwe, setup_quoted_hwe),
-#else
+               test_entry(broken_hwe),
+               test_entry(broken_hwe_dir),
                test_entry(quoted_hwe),
-#endif
                test_entry(regex_hwe),
                test_entry(regex_string_hwe),
                test_entry(regex_string_hwe_dir),