]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: test-hash: add a test for deleting a single element
authorMartin Wilck <mwilck@suse.com>
Thu, 21 Nov 2024 21:52:34 +0000 (22:52 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 29 Nov 2024 15:15:21 +0000 (09:15 -0600)
...using n_buckets = 32, which will cause a step size of 1.
This test fails, and will be fixed by the next commit.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/257
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
testsuite/test-hash.c

index cfe5a8e4bc3e8c4f334d83346790bc03f3fe100d..1ec820d1c47a6270770d1286b72b2614b241e68f 100644 (file)
@@ -171,6 +171,22 @@ static int test_hash_iter_after_del(const struct test *t)
 DEFINE_TEST(test_hash_iter_after_del,
            .description = "test hash_iter, after deleting element");
 
+static int test_hash_del(const struct test *t)
+{
+       struct hash *h = hash_new(32, NULL);
+       const char *k1 = "k1";
+       const char *v1 = "v1";
+
+       hash_add(h, k1, v1);
+       hash_del(h, k1);
+
+       hash_free(h);
+
+       return 0;
+}
+DEFINE_TEST(test_hash_del, .description = "test add / delete a single element",
+           .expected_fail = true);
+
 static int test_hash_free(const struct test *t)
 {
        struct hash *h = hash_new(8, countfreecalls);