From: Martin Wilck Date: Thu, 21 Nov 2024 22:45:02 +0000 (+0100) Subject: testsuite: test-hash: add a test for deleting a non-existing element X-Git-Tag: v34~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d534de7d7f1f8202c11c1a475df1f01225c176a;p=thirdparty%2Fkmod.git testsuite: test-hash: add a test for deleting a non-existing element This test fails and will be fixed by the next commit. Signed-off-by: Martin Wilck Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/257 Signed-off-by: Lucas De Marchi --- diff --git a/testsuite/test-hash.c b/testsuite/test-hash.c index b115a623..e9041117 100644 --- a/testsuite/test-hash.c +++ b/testsuite/test-hash.c @@ -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);