From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Emilio G. Cota" <cota@braap.org>
Cc: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [Qemu-devel] [PATCH 3/6] test-qht: test qht_iter_remove
Date: Fri, 07 Sep 2018 16:15:08 +0100 [thread overview]
Message-ID: <87h8j1z6df.fsf@linaro.org> (raw)
In-Reply-To: <20180817232923.28899-4-cota@braap.org>
Emilio G. Cota <cota@braap.org> writes:
> Signed-off-by: Emilio G. Cota <cota@braap.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> tests/test-qht.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 48 insertions(+), 2 deletions(-)
>
> diff --git a/tests/test-qht.c b/tests/test-qht.c
> index dda6a067be..283fb3db39 100644
> --- a/tests/test-qht.c
> +++ b/tests/test-qht.c
> @@ -108,6 +108,49 @@ static void iter_check(unsigned int count)
> g_assert_cmpuint(curr, ==, count);
> }
>
> +static void sum_func(struct qht *ht, void *p, uint32_t hash, void *userp)
> +{
> + uint32_t *sum = userp;
> + uint32_t a = *(uint32_t *)p;
> +
> + *sum += a;
> +}
> +
> +static void iter_sum_check(unsigned int expected)
> +{
> + unsigned int sum = 0;
> +
> + qht_iter(&ht, sum_func, &sum);
> + g_assert_cmpuint(sum, ==, expected);
> +}
> +
> +static bool rm_mod_func(struct qht *ht, void *p, uint32_t hash, void *userp)
> +{
> + uint32_t a = *(uint32_t *)p;
> + unsigned int mod = *(unsigned int *)userp;
> +
> + return a % mod == 0;
> +}
> +
> +static void iter_rm_mod(unsigned int mod)
> +{
> + qht_iter_remove(&ht, rm_mod_func, &mod);
> +}
> +
> +static void iter_rm_mod_check(unsigned int mod)
> +{
> + unsigned int expected = 0;
> + unsigned int i;
> +
> + for (i = 0; i < N; i++) {
> + if (i % mod == 0) {
> + continue;
> + }
> + expected += i;
> + }
> + iter_sum_check(expected);
> +}
> +
> static void qht_do_test(unsigned int mode, size_t init_entries)
> {
> /* under KVM we might fetch stats from an uninitialized qht */
> @@ -138,8 +181,11 @@ static void qht_do_test(unsigned int mode, size_t init_entries)
> insert(10, 150);
> check_n(N);
>
> - rm(1, 2);
> - check_n(N - 1);
> + qht_reset(&ht);
> + insert(0, N);
> + iter_rm_mod(10);
> + iter_rm_mod_check(10);
> + check_n(N * 9 / 10);
> qht_reset_size(&ht, 0);
> check_n(0);
> check(0, N, false);
--
Alex Bennée
next prev parent reply other threads:[~2018-09-07 15:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-17 23:29 [Qemu-devel] [PATCH 0/6] qht improvements for 3.1 Emilio G. Cota
2018-08-17 23:29 ` [Qemu-devel] [PATCH 1/6] qht: remove unused map param from qht_remove__locked Emilio G. Cota
2018-09-07 14:43 ` Alex Bennée
2018-08-17 23:29 ` [Qemu-devel] [PATCH 2/6] qht: add qht_iter_remove Emilio G. Cota
2018-09-07 14:51 ` Alex Bennée
2018-09-07 15:45 ` Emilio G. Cota
2018-08-17 23:29 ` [Qemu-devel] [PATCH 3/6] test-qht: test qht_iter_remove Emilio G. Cota
2018-09-07 15:15 ` Alex Bennée [this message]
2018-08-17 23:29 ` [Qemu-devel] [PATCH 4/6] test-qht: test removal of non-existent entries Emilio G. Cota
2018-09-07 15:16 ` Alex Bennée
2018-08-17 23:29 ` [Qemu-devel] [PATCH 5/6] test-qht: test deletion of the last entry in a bucket Emilio G. Cota
2018-09-07 15:17 ` Alex Bennée
2018-08-17 23:29 ` [Qemu-devel] [PATCH 6/6] test-qht: speed up + test qht_resize Emilio G. Cota
2018-09-07 15:34 ` Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h8j1z6df.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=cota@braap.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.