static void test_qga_sync(gconstpointer fix) { const TestFixture *fixture = fix; guint32 v, r = g_random_int(); QDict *ret; /* * TODO guest-sync is inherently limited: we cannot distinguish * failure caused by reacting to garbage on the wire prior to this * command, from failure of this actual command. Clients are * supposed to be able to send a raw '\xff' byte to at least * re-synchronize the server's parser prior to this command, but * we are not in a position to test that here because (at least * for now) it causes the server to issue an error message about * invalid JSON. Testing of '\xff' handling is done in * guest-sync-delimited instead. */ ret = qmp_fd(fixture->fd, "{'execute': 'guest-sync', 'arguments': {'id': %u } }", r); g_assert_nonnull(ret); qmp_assert_no_error(ret); v = qdict_get_int(ret, "return"); g_assert_cmpint(r, ==, v); qobject_unref(ret); }
static void test_qga_invalid_oob(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret; ret = qmp_fd(fixture->fd, "{'exec-oob': 'guest-ping'}"); g_assert_nonnull(ret); qmp_assert_error_class(ret, "GenericError"); }
static void test_qga_ping(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret; ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping'}"); g_assert_nonnull(ret); qmp_assert_no_error(ret); QDECREF(ret); }
static void test_qga_invalid_id(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret, *error; const char *class; ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping', 'id': 1}"); g_assert_nonnull(ret); error = qdict_get_qdict(ret, "error"); class = qdict_get_try_str(error, "class"); g_assert_cmpstr(class, ==, "GenericError"); qobject_unref(ret); }
static void test_qga_get_memory_block_info(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret, *val; int64_t size; ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-memory-block-info'}"); g_assert_nonnull(ret); /* some systems might not expose memory block info in sysfs */ if (!qdict_haskey(ret, "error")) { /* check there is at least some memory */ val = qdict_get_qdict(ret, "return"); size = qdict_get_int(val, "size"); g_assert_cmpint(size, >, 0); }
static void test_qga_info(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret, *val; const gchar *version; ret = qmp_fd(fixture->fd, "{'execute': 'guest-info'}"); g_assert_nonnull(ret); qmp_assert_no_error(ret); val = qdict_get_qdict(ret, "return"); version = qdict_get_try_str(val, "version"); g_assert_cmpstr(version, ==, QEMU_VERSION); QDECREF(ret); }
static void test_qga_invalid_cmd(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret, *error; const gchar *class, *desc; ret = qmp_fd(fixture->fd, "{'execute': 'guest-invalid-cmd'}"); g_assert_nonnull(ret); error = qdict_get_qdict(ret, "error"); class = qdict_get_try_str(error, "class"); desc = qdict_get_try_str(error, "desc"); g_assert_cmpstr(class, ==, "CommandNotFound"); g_assert_cmpint(strlen(desc), >, 0); QDECREF(ret); }
static void test_qga_get_vcpus(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret; QList *list; const QListEntry *entry; ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-vcpus'}"); g_assert_nonnull(ret); qmp_assert_no_error(ret); /* check there is at least a cpu */ list = qdict_get_qlist(ret, "return"); entry = qlist_first(list); g_assert(qdict_haskey(qobject_to_qdict(entry->value), "online")); g_assert(qdict_haskey(qobject_to_qdict(entry->value), "logical-id")); QDECREF(ret); }
static void test_qga_invalid_args(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret, *error; const gchar *class, *desc; ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping', " "'arguments': {'foo': 42 }}"); g_assert_nonnull(ret); error = qdict_get_qdict(ret, "error"); class = qdict_get_try_str(error, "class"); desc = qdict_get_try_str(error, "desc"); g_assert_cmpstr(class, ==, "GenericError"); g_assert_cmpstr(desc, ==, "Parameter 'foo' is unexpected"); qobject_unref(ret); }
static void test_qga_sync(gconstpointer fix) { const TestFixture *fixture = fix; guint32 v, r = g_random_int(); QDict *ret; gchar *cmd; cmd = g_strdup_printf("%c{'execute': 'guest-sync'," " 'arguments': {'id': %u } }", 0xff, r); ret = qmp_fd(fixture->fd, cmd); g_free(cmd); g_assert_nonnull(ret); qmp_assert_no_error(ret); v = qdict_get_int(ret, "return"); g_assert_cmpint(r, ==, v); QDECREF(ret); }
static void test_qga_get_fsinfo(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret; QList *list; const QListEntry *entry; ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-fsinfo'}"); g_assert_nonnull(ret); qmp_assert_no_error(ret); /* check there is at least a fs */ list = qdict_get_qlist(ret, "return"); entry = qlist_first(list); g_assert(qdict_haskey(qobject_to_qdict(entry->value), "name")); g_assert(qdict_haskey(qobject_to_qdict(entry->value), "mountpoint")); g_assert(qdict_haskey(qobject_to_qdict(entry->value), "type")); g_assert(qdict_haskey(qobject_to_qdict(entry->value), "disk")); QDECREF(ret); }
static void test_qga_get_fsinfo(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret; QList *list; const QListEntry *entry; ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-fsinfo'}"); g_assert_nonnull(ret); qmp_assert_no_error(ret); /* sanity-check the response if there are any filesystems */ list = qdict_get_qlist(ret, "return"); entry = qlist_first(list); if (entry) { g_assert(qdict_haskey(qobject_to(QDict, entry->value), "name")); g_assert(qdict_haskey(qobject_to(QDict, entry->value), "mountpoint")); g_assert(qdict_haskey(qobject_to(QDict, entry->value), "type")); g_assert(qdict_haskey(qobject_to(QDict, entry->value), "disk")); } qobject_unref(ret); }