]> git.proxmox.com Git - mirror_qemu.git/blame - tests/unit/test-write-threshold.c
tests/qtest/libqos/e1000e: Remove "other" interrupts
[mirror_qemu.git] / tests / unit / test-write-threshold.c
CommitLineData
e2462113
FR
1/*
2 * Test block device write threshold
3 *
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.
6 *
7 */
8
681c28a3 9#include "qemu/osdep.h"
e2462113
FR
10#include "block/block_int.h"
11#include "block/write-threshold.h"
12
13
e2462113
FR
14static void test_threshold_not_trigger(void)
15{
e2462113
FR
16 uint64_t threshold = 4 * 1024 * 1024;
17 BlockDriverState bs;
e2462113
FR
18
19 memset(&bs, 0, sizeof(bs));
8b117001 20
e2462113 21 bdrv_write_threshold_set(&bs, threshold);
e46354a8
VSO
22 bdrv_write_threshold_check_write(&bs, 1024, 1024);
23 g_assert_cmpuint(bdrv_write_threshold_get(&bs), ==, threshold);
e2462113
FR
24}
25
26
27static void test_threshold_trigger(void)
28{
e2462113
FR
29 uint64_t threshold = 4 * 1024 * 1024;
30 BlockDriverState bs;
e2462113
FR
31
32 memset(&bs, 0, sizeof(bs));
8b117001 33
e2462113 34 bdrv_write_threshold_set(&bs, threshold);
e46354a8
VSO
35 bdrv_write_threshold_check_write(&bs, threshold - 1024, 2 * 1024);
36 g_assert_cmpuint(bdrv_write_threshold_get(&bs), ==, 0);
e2462113
FR
37}
38
e2462113
FR
39
40int main(int argc, char **argv)
41{
e2462113 42 g_test_init(&argc, &argv, NULL);
23357b93
VSO
43 g_test_add_func("/write-threshold/not-trigger", test_threshold_not_trigger);
44 g_test_add_func("/write-threshold/trigger", test_threshold_trigger);
45
e2462113
FR
46 return g_test_run();
47}