]> git.proxmox.com Git - mirror_qemu.git/commitdiff
test-qht: test deletion of the last entry in a bucket
authorEmilio G. Cota <cota@braap.org>
Fri, 17 Aug 2018 22:15:33 +0000 (18:15 -0400)
committerRichard Henderson <richard.henderson@linaro.org>
Wed, 26 Sep 2018 15:55:54 +0000 (08:55 -0700)
This improves coverage by one (!) LoC in qht.c, bringing the
coverage rate up from 90.00% to 90.28%.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
tests/test-qht.c

index 05b1d6807a0092991216b10ef2c96bc02cf569ab..77666e8c5f4aa5d45112bdac7fce74a1544d026d 100644 (file)
@@ -172,9 +172,20 @@ static void qht_do_test(unsigned int mode, size_t init_entries)
 
     qht_init(&ht, is_equal, 0, mode);
     rm_nonexist(0, 4);
+    /*
+     * Test that we successfully delete the last element in a bucket.
+     * This is a hard-to-reach code path when resizing is on, but without
+     * resizing we can easily hit it if init_entries <= 1.
+     * Given that the number of elements per bucket can be 4 or 6 depending on
+     * the host's pointer size, test the removal of the 4th and 6th elements.
+     */
     insert(0, 4);
     rm_nonexist(5, 6);
-    insert(4, 6);
+    rm(3, 4);
+    check_n(3);
+    insert(3, 6);
+    rm(5, 6);
+    check_n(5);
     rm_nonexist(7, 8);
     iter_rm_mod(1);