]> git.proxmox.com Git - qemu.git/blob - tests/blockdev-test.c
block: vhdx - update _make_test_img() to filter out vhdx options
[qemu.git] / tests / blockdev-test.c
1 /*
2 * blockdev.c test cases
3 *
4 * Copyright (C) 2013 Red Hat Inc.
5 *
6 * Authors:
7 * Stefan Hajnoczi <stefanha@redhat.com>
8 *
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
11 */
12
13 #include <glib.h>
14 #include <string.h>
15 #include "libqtest.h"
16
17 static void test_drive_add_empty(void)
18 {
19 QDict *response;
20 const char *response_return;
21
22 /* Start with an empty drive */
23 qtest_start("-drive if=none,id=drive0");
24
25 /* Delete the drive */
26 response = qmp("{\"execute\": \"human-monitor-command\","
27 " \"arguments\": {"
28 " \"command-line\": \"drive_del drive0\""
29 "}}");
30 g_assert(response);
31 response_return = qdict_get_try_str(response, "return");
32 g_assert(response_return);
33 g_assert(strcmp(response_return, "") == 0);
34 QDECREF(response);
35
36 /* Ensure re-adding the drive works - there should be no duplicate ID error
37 * because the old drive must be gone.
38 */
39 response = qmp("{\"execute\": \"human-monitor-command\","
40 " \"arguments\": {"
41 " \"command-line\": \"drive_add 0 if=none,id=drive0\""
42 "}}");
43 g_assert(response);
44 response_return = qdict_get_try_str(response, "return");
45 g_assert(response_return);
46 g_assert(strcmp(response_return, "OK\r\n") == 0);
47 QDECREF(response);
48
49 qtest_end();
50 }
51
52 int main(int argc, char **argv)
53 {
54 g_test_init(&argc, &argv, NULL);
55
56 qtest_add_func("/qmp/drive_add_empty", test_drive_add_empty);
57
58 return g_test_run();
59 }