[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/7] throttle: Add throttle group infrastructure tes
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH 3/7] throttle: Add throttle group infrastructure tests |
Date: |
Thu, 26 Mar 2015 19:24:57 +0200 |
Signed-off-by: Alberto Garcia <address@hidden>
---
tests/test-throttle.c | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/tests/test-throttle.c b/tests/test-throttle.c
index 458f577..4f151ec 100644
--- a/tests/test-throttle.c
+++ b/tests/test-throttle.c
@@ -1,10 +1,12 @@
/*
* Throttle infrastructure tests
*
- * Copyright Nodalink, SARL. 2013
+ * Copyright Nodalink, EURL. 2013-2014
+ * Copyright Igalia, S.L. 2015
*
* Authors:
- * Benoît Canet <address@hidden>
+ * Benoît Canet <address@hidden>
+ * Alberto Garcia <address@hidden>
*
* This work is licensed under the terms of the GNU LGPL, version 2 or later.
* See the COPYING.LIB file in the top-level directory.
@@ -15,6 +17,7 @@
#include "block/aio.h"
#include "qemu/throttle.h"
#include "qemu/error-report.h"
+#include "block/throttle-groups.h"
static AioContext *ctx;
static LeakyBucket bkt;
@@ -500,6 +503,35 @@ static void test_accounting(void)
(64.0 / 13)));
}
+static void test_groups(void)
+{
+ BlockDriverState *bdrv1, *bdrv2, *bdrv3;
+
+ bdrv1 = bdrv_new();
+ bdrv2 = bdrv_new();
+ bdrv3 = bdrv_new();
+
+ g_assert(bdrv1->throttle_state == NULL);
+ g_assert(bdrv2->throttle_state == NULL);
+ g_assert(bdrv3->throttle_state == NULL);
+
+ throttle_group_register_bs(bdrv1, "bar");
+ throttle_group_register_bs(bdrv2, "foo");
+ throttle_group_register_bs(bdrv3, "bar");
+
+ g_assert(!strcmp(throttle_group_get_name(bdrv1), "bar"));
+ g_assert(!strcmp(throttle_group_get_name(bdrv2), "foo"));
+ g_assert(bdrv1->throttle_state == bdrv3->throttle_state);
+
+ throttle_group_unregister_bs(bdrv1);
+ throttle_group_unregister_bs(bdrv2);
+ throttle_group_unregister_bs(bdrv3);
+
+ g_assert(bdrv1->throttle_state == NULL);
+ g_assert(bdrv2->throttle_state == NULL);
+ g_assert(bdrv3->throttle_state == NULL);
+}
+
int main(int argc, char **argv)
{
GSource *src;
@@ -533,6 +565,7 @@ int main(int argc, char **argv)
g_test_add_func("/throttle/config/is_valid", test_is_valid);
g_test_add_func("/throttle/config_functions", test_config_functions);
g_test_add_func("/throttle/accounting", test_accounting);
+ g_test_add_func("/throttle/groups", test_groups);
return g_test_run();
}
--
2.1.4
- [Qemu-devel] [PATCH v4 0/7] Block Throttle Group Support, Alberto Garcia, 2015/03/26
- [Qemu-devel] [PATCH 2/7] throttle: Add throttle group infrastructure, Alberto Garcia, 2015/03/26
- [Qemu-devel] [PATCH 1/7] throttle: Extract timers from ThrottleState into a separate structure, Alberto Garcia, 2015/03/26
- [Qemu-devel] [PATCH 6/7] throttle: add the name of the ThrottleGroup to BlockDeviceInfo, Alberto Garcia, 2015/03/26
- [Qemu-devel] [PATCH 4/7] throttle: Add throttle group support, Alberto Garcia, 2015/03/26
- [Qemu-devel] [PATCH 5/7] throttle: acquire the ThrottleGroup lock in bdrv_swap(), Alberto Garcia, 2015/03/26
- [Qemu-devel] [PATCH 7/7] throttle: Update throttle infrastructure copyright, Alberto Garcia, 2015/03/26
- [Qemu-devel] [PATCH 3/7] throttle: Add throttle group infrastructure tests,
Alberto Garcia <=
- Re: [Qemu-devel] [PATCH v4 0/7] Block Throttle Group Support, Alberto Garcia, 2015/03/26
- Re: [Qemu-devel] [PATCH v4 0/7] Block Throttle Group Support, Stefan Hajnoczi, 2015/03/30