]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: test-hash: add a test for deleting a non-existing element
authorMartin Wilck <mwilck@suse.com>
Thu, 21 Nov 2024 22:45:02 +0000 (23:45 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 29 Nov 2024 15:15:21 +0000 (09:15 -0600)
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 b115a623f55e3716480156965ea703945deb693f..e904111772fc185b12fa7039a635751ad3237c72 100644 (file)
@@ -186,6 +186,23 @@ static int test_hash_del(const struct test *t)
 }
 DEFINE_TEST(test_hash_del, .description = "test add / delete a single element");
 
+static int test_hash_del_nonexistent(const struct test *t)
+{
+       struct hash *h = hash_new(32, NULL);
+       const char *k1 = "k1";
+       int rc;
+
+       rc = hash_del(h, k1);
+       assert_return(rc == -ENOENT, EXIT_FAILURE);
+
+       hash_free(h);
+
+       return 0;
+}
+DEFINE_TEST(test_hash_del_nonexistent,
+           .description = "test deleting an element that doesn't exist",
+           .expected_fail = true);
+
 static int test_hash_free(const struct test *t)
 {
        struct hash *h = hash_new(8, countfreecalls);