qemu-options.hx: Fix indentation of some option descriptions
[qemu/ar7.git] / tests / unit / test-write-threshold.c
blob0158e4637a88fe8fcc9285acf768058fc40f3a3f
1 /*
2 * Test block device write threshold
4 * This work is licensed under the terms of the GNU LGPL, version 2 or later.
5 * See the COPYING.LIB file in the top-level directory.
7 */
9 #include "qemu/osdep.h"
10 #include "block/block_int.h"
11 #include "block/write-threshold.h"
14 static void test_threshold_not_trigger(void)
16 uint64_t threshold = 4 * 1024 * 1024;
17 BlockDriverState bs;
19 memset(&bs, 0, sizeof(bs));
21 bdrv_write_threshold_set(&bs, threshold);
22 bdrv_write_threshold_check_write(&bs, 1024, 1024);
23 g_assert_cmpuint(bdrv_write_threshold_get(&bs), ==, threshold);
27 static void test_threshold_trigger(void)
29 uint64_t threshold = 4 * 1024 * 1024;
30 BlockDriverState bs;
32 memset(&bs, 0, sizeof(bs));
34 bdrv_write_threshold_set(&bs, threshold);
35 bdrv_write_threshold_check_write(&bs, threshold - 1024, 2 * 1024);
36 g_assert_cmpuint(bdrv_write_threshold_get(&bs), ==, 0);
40 int main(int argc, char **argv)
42 g_test_init(&argc, &argv, NULL);
43 g_test_add_func("/write-threshold/not-trigger", test_threshold_not_trigger);
44 g_test_add_func("/write-threshold/trigger", test_threshold_trigger);
46 return g_test_run();