[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/13] throttle: Check that burst_level leaks correc
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH 12/13] throttle: Check that burst_level leaks correctly |
Date: |
Fri, 5 Feb 2016 12:59:22 +0200 |
This patch expands test_leak_bucket() to check that burst_level leaks
correctly.
Signed-off-by: Alberto Garcia <address@hidden>
---
tests/test-throttle.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/tests/test-throttle.c b/tests/test-throttle.c
index cf81033..11ede23 100644
--- a/tests/test-throttle.c
+++ b/tests/test-throttle.c
@@ -59,6 +59,22 @@ static void test_leak_bucket(void)
g_assert(bkt.avg == 150);
g_assert(bkt.max == 15);
g_assert(double_cmp(bkt.level, 0));
+
+ /* check that burst_level leaks correctly */
+ bkt.burst_level = 6;
+ bkt.max = 250;
+ bkt.burst_length = 2; /* otherwise burst_level will not leak */
+ throttle_leak_bucket(&bkt, NANOSECONDS_PER_SECOND / 100);
+ g_assert(double_cmp(bkt.burst_level, 3.5));
+
+ throttle_leak_bucket(&bkt, NANOSECONDS_PER_SECOND / 100);
+ g_assert(double_cmp(bkt.burst_level, 1));
+
+ throttle_leak_bucket(&bkt, NANOSECONDS_PER_SECOND / 100);
+ g_assert(double_cmp(bkt.burst_level, 0));
+
+ throttle_leak_bucket(&bkt, NANOSECONDS_PER_SECOND / 100);
+ g_assert(double_cmp(bkt.burst_level, 0));
}
static void test_compute_wait(void)
--
2.7.0
- [Qemu-devel] [PATCH 00/13] throttle: Allow I/O bursts for a user-defined period of time, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 05/13] throttle: Set always an average value when setting a maximum value, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 09/13] throttle: Add command-line settings to define the burst periods, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 06/13] throttle: Merge all functions that check the configuration into one, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 01/13] throttle: Make throttle_compute_timer() static, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 04/13] throttle: Make throttle_is_valid() set errp, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 02/13] throttle: Make throttle_conflicting() set errp, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 12/13] throttle: Check that burst_level leaks correctly,
Alberto Garcia <=
- [Qemu-devel] [PATCH 07/13] throttle: Use throttle_config_init() to initialize ThrottleConfig, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 08/13] throttle: Add support for burst periods, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 11/13] qapi: Add burst length fields to BlockDeviceInfo, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 13/13] throttle: Test throttle_compute_wait() during bursts, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 03/13] throttle: Make throttle_max_is_missing_limit() set errp, Alberto Garcia, 2016/02/05
- [Qemu-devel] [PATCH 10/13] qapi: Add burst length parameters to block_set_io_throttle, Alberto Garcia, 2016/02/05
- Re: [Qemu-devel] [PATCH 00/13] throttle: Allow I/O bursts for a user-defined period of time, Kevin Wolf, 2016/02/12