return line;
}
-static gchar **qtest_rsp(QTestState *s, int expected_args)
+static gchar **qtest_rsp_args(QTestState *s, int expected_args)
{
GString *line;
gchar **words;
g_assert(words[0] != NULL);
g_assert_cmpstr(words[0], ==, "OK");
- if (expected_args) {
- for (i = 0; i < expected_args; i++) {
- g_assert(words[i] != NULL);
- }
- } else {
- g_strfreev(words);
- words = NULL;
+ for (i = 0; i < expected_args; i++) {
+ g_assert(words[i] != NULL);
}
return words;
}
+static void qtest_rsp(QTestState *s)
+{
+ gchar **words = qtest_rsp_args(s, 0);
+
+ g_strfreev(words);
+}
+
static int qtest_query_target_endianness(QTestState *s)
{
gchar **args;
int big_endian;
qtest_sendf(s, "endianness\n");
- args = qtest_rsp(s, 1);
+ args = qtest_rsp_args(s, 1);
g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
big_endian = strcmp(args[1], "big") == 0;
g_strfreev(args);
void qtest_module_load(QTestState *s, const char *prefix, const char *libname)
{
qtest_sendf(s, "module_load %s %s\n", prefix, libname);
- qtest_rsp(s, 0);
+ qtest_rsp(s);
}
static int64_t qtest_clock_rsp(QTestState *s)
{
gchar **words;
int64_t clock;
- words = qtest_rsp(s, 2);
+ words = qtest_rsp_args(s, 2);
clock = g_ascii_strtoll(words[1], NULL, 0);
g_strfreev(words);
return clock;
void qtest_irq_intercept_out(QTestState *s, const char *qom_path)
{
qtest_sendf(s, "irq_intercept_out %s\n", qom_path);
- qtest_rsp(s, 0);
+ qtest_rsp(s);
}
void qtest_irq_intercept_in(QTestState *s, const char *qom_path)
{
qtest_sendf(s, "irq_intercept_in %s\n", qom_path);
- qtest_rsp(s, 0);
+ qtest_rsp(s);
}
void qtest_set_irq_in(QTestState *s, const char *qom_path, const char *name,
name = "unnamed-gpio-in";
}
qtest_sendf(s, "set_irq_in %s %s %d %d\n", qom_path, name, num, level);
- qtest_rsp(s, 0);
+ qtest_rsp(s);
}
static void qtest_out(QTestState *s, const char *cmd, uint16_t addr, uint32_t value)
{
qtest_sendf(s, "%s 0x%x 0x%x\n", cmd, addr, value);
- qtest_rsp(s, 0);
+ qtest_rsp(s);
}
void qtest_outb(QTestState *s, uint16_t addr, uint8_t value)
unsigned long value;
qtest_sendf(s, "%s 0x%x\n", cmd, addr);
- args = qtest_rsp(s, 2);
+ args = qtest_rsp_args(s, 2);
ret = qemu_strtoul(args[1], NULL, 0, &value);
g_assert(!ret && value <= UINT32_MAX);
g_strfreev(args);
uint64_t value)
{
qtest_sendf(s, "%s 0x%" PRIx64 " 0x%" PRIx64 "\n", cmd, addr, value);
- qtest_rsp(s, 0);
+ qtest_rsp(s);
}
void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value)
uint64_t value;
qtest_sendf(s, "%s 0x%" PRIx64 "\n", cmd, addr);
- args = qtest_rsp(s, 2);
+ args = qtest_rsp_args(s, 2);
ret = qemu_strtou64(args[1], NULL, 0, &value);
g_assert(!ret);
g_strfreev(args);
}
qtest_sendf(s, "read 0x%" PRIx64 " 0x%zx\n", addr, size);
- args = qtest_rsp(s, 2);
+ args = qtest_rsp_args(s, 2);
for (i = 0; i < size; i++) {
ptr[i] = hex2nib(args[1][2 + (i * 2)]) << 4;
{
qtest_sendf(s, "rtas %s %u 0x%"PRIx64" %u 0x%"PRIx64"\n",
name, nargs, args, nret, ret);
- qtest_rsp(s, 0);
+ qtest_rsp(s);
return 0;
}
qtest_sendf(s, "b64write 0x%" PRIx64 " 0x%zx ", addr, size);
s->ops.send(s, bdata);
s->ops.send(s, "\n");
- qtest_rsp(s, 0);
+ qtest_rsp(s);
g_free(bdata);
}
size_t len;
qtest_sendf(s, "b64read 0x%" PRIx64 " 0x%zx\n", addr, size);
- args = qtest_rsp(s, 2);
+ args = qtest_rsp_args(s, 2);
g_base64_decode_inplace(args[1], &len);
if (size != len) {
}
qtest_sendf(s, "write 0x%" PRIx64 " 0x%zx 0x%s\n", addr, size, enc);
- qtest_rsp(s, 0);
+ qtest_rsp(s);
g_free(enc);
}
void qtest_memset(QTestState *s, uint64_t addr, uint8_t pattern, size_t size)
{
qtest_sendf(s, "memset 0x%" PRIx64 " 0x%zx 0x%02x\n", addr, size, pattern);
- qtest_rsp(s, 0);
+ qtest_rsp(s);
}
void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)