2 * blockdev.c test cases
4 * Copyright (C) 2013 Red Hat Inc.
7 * Stefan Hajnoczi <stefanha@redhat.com>
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.
17 static void test_drive_add_empty(void)
20 const char *response_return
;
22 /* Start with an empty drive */
23 qtest_start("-drive if=none,id=drive0");
25 /* Delete the drive */
26 response
= qmp("{\"execute\": \"human-monitor-command\","
28 " \"command-line\": \"drive_del drive0\""
31 response_return
= qdict_get_try_str(response
, "return");
32 g_assert(response_return
);
33 g_assert(strcmp(response_return
, "") == 0);
36 /* Ensure re-adding the drive works - there should be no duplicate ID error
37 * because the old drive must be gone.
39 response
= qmp("{\"execute\": \"human-monitor-command\","
41 " \"command-line\": \"drive_add 0 if=none,id=drive0\""
44 response_return
= qdict_get_try_str(response
, "return");
45 g_assert(response_return
);
46 g_assert(strcmp(response_return
, "OK\r\n") == 0);
52 int main(int argc
, char **argv
)
54 g_test_init(&argc
, &argv
, NULL
);
56 qtest_add_func("/qmp/drive_add_empty", test_drive_add_empty
);