#include "qemu/osdep.h"
#include <locale.h>
#include <glib/gstdio.h>
#include <sys/socket.h>
#include <sys/un.h>

#include "../qtest/libqtest.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlist.h"

typedef struct {
    char *test_dir;
    GMainLoop *loop;
    int fd;
    GPid pid;
} TestFixture;

static int connect_qga(char *path)
{
    int s, ret, len, i = 0;
    struct sockaddr_un remote;

    s = socket(AF_UNIX, SOCK_STREAM, 0);
    g_assert(s != -1);

    remote.sun_family = AF_UNIX;
    do {
        strcpy(remote.sun_path, path);
        len = strlen(remote.sun_path) + sizeof(remote.sun_family);
        ret = connect(s, (struct sockaddr *)&remote, len);
        if (ret == -1) {
            g_usleep(G_USEC_PER_SEC);
        }
        if (i++ == 10) {
            close(s);
            return -1;
        }
    } while (ret == -1);

    return s;
}

static void qga_watch(GPid pid, gint status, gpointer user_data)
{
    TestFixture *fixture = user_data;

    g_assert_cmpint(status, ==, 0);
    g_main_loop_quit(fixture->loop);
}

static void
fixture_setup(TestFixture *fixture, gconstpointer data, gchar **envp)
{
    const gchar *extra_arg = data;
    GError *error = NULL;
    g_autofree char *cwd = NULL;
    g_autofree char *path = NULL;
    g_autofree char *cmd = NULL;
    g_auto(GStrv) argv = NULL;

    fixture->loop = g_main_loop_new(NULL, FALSE);

    fixture->test_dir = g_strdup_printf("%s/qgatest.XXXXXX", g_get_tmp_dir());
    g_assert_nonnull(g_mkdtemp(fixture->test_dir));

    path = g_build_filename(fixture->test_dir, "sock", NULL);
    cwd = g_get_current_dir();
    cmd = g_strdup_printf("%s%cqga%cqemu-ga -m unix-listen -t %s -p %s %s %s",
                          cwd, G_DIR_SEPARATOR, G_DIR_SEPARATOR,
                          fixture->test_dir, path,
                          getenv("QTEST_LOG") ? "-v" : "",
                          extra_arg ?: "");
    g_shell_parse_argv(cmd, NULL, &argv, &error);
    g_assert_no_error(error);

    g_spawn_async(fixture->test_dir, argv, envp,
                  G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD,
                  NULL, NULL, &fixture->pid, &error);
    g_assert_no_error(error);

    g_child_watch_add(fixture->pid, qga_watch, fixture);

    fixture->fd = connect_qga(path);
    g_assert_cmpint(fixture->fd, !=, -1);
}

static void
fixture_tear_down(TestFixture *fixture, gconstpointer data)
{
    g_autofree char *tmp = NULL;

    kill(fixture->pid, SIGTERM);

    g_main_loop_run(fixture->loop);
    g_main_loop_unref(fixture->loop);

    g_spawn_close_pid(fixture->pid);

    tmp = g_build_filename(fixture->test_dir, "foo", NULL);
    g_unlink(tmp);
    g_free(tmp);

    tmp = g_build_filename(fixture->test_dir, "qga.state", NULL);
    g_unlink(tmp);
    g_free(tmp);

    tmp = g_build_filename(fixture->test_dir, "sock", NULL);
    g_unlink(tmp);

    g_rmdir(fixture->test_dir);
    g_free(fixture->test_dir);
    close(fixture->fd);
}

static void qmp_assertion_message_error(const char     *domain,
                                        const char     *file,
                                        int             line,
                                        const char     *func,
                                        const char     *expr,
                                        QDict          *dict)
{
    const char *class, *desc;
    g_autofree char *s = NULL;
    QDict *error;

    error = qdict_get_qdict(dict, "error");
    class = qdict_get_try_str(error, "class");
    desc = qdict_get_try_str(error, "desc");

    s = g_strdup_printf("assertion failed %s: %s %s", expr, class, desc);
    g_assertion_message(domain, file, line, func, s);
}

#define qmp_assert_no_error(err) do {                                   \
    if (qdict_haskey(err, "error")) {                                   \
        qmp_assertion_message_error(G_LOG_DOMAIN, __FILE__, __LINE__,   \
                                    G_STRFUNC, #err, err);              \
    }                                                                   \
} while (0)

static void test_qga_sync_delimited(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    guint32 v, r = g_test_rand_int();
    unsigned char c;
    g_autoptr(QDict) ret = NULL;

    qmp_fd_send_raw(fixture->fd, "\xff");
    qmp_fd_send(fixture->fd,
                "{'execute': 'guest-sync-delimited',"
                " 'arguments': {'id': %u } }",
                r);

    /*
     * Read and ignore garbage until resynchronized.
     *
     * Note that the full reset sequence would involve checking the
     * response of guest-sync-delimited and repeating the loop if
     * 'id' field of the response does not match the 'id' field of
     * the request. Testing this fully would require inserting
     * garbage in the response stream and is left as a future test
     * to implement.
     *
     * TODO: The server shouldn't emit so much garbage (among other
     * things, it loudly complains about the client's \xff being
     * invalid JSON, even though it is a documented part of the
     * handshake.
     */
    do {
        v = read(fixture->fd, &c, 1);
        g_assert_cmpint(v, ==, 1);
    } while (c != 0xff);

    ret = qmp_fd_receive(fixture->fd);
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);

    v = qdict_get_int(ret, "return");
    g_assert_cmpint(r, ==, v);
}

static void test_qga_sync(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    guint32 v, r = g_test_rand_int();
    g_autoptr(QDict) ret = NULL;

    /*
     * 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);
}

static void test_qga_ping(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;

    ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping'}");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);
}

static void test_qga_id(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;

    ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping', 'id': 1}");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);
    g_assert_cmpint(qdict_get_int(ret, "id"), ==, 1);
}

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_expect_error_and_unref(ret, "GenericError");
}

static void test_qga_invalid_args(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *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");
}

static void test_qga_invalid_cmd(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *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);
}

static void test_qga_info(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *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);
}

static void test_qga_get_vcpus(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    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"));
}

static void test_qga_get_fsinfo(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    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"));
    }
}

static void test_qga_get_memory_block_info(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *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_get_memory_blocks(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QList *list;
    const QListEntry *entry;

    ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-memory-blocks'}");
    g_assert_nonnull(ret);

    /* some systems might not expose memory block info in sysfs */
    if (!qdict_haskey(ret, "error")) {
        list = qdict_get_qlist(ret, "return");
        entry = qlist_first(list);
        /* newer versions of qga may return empty list without error */
        if (entry) {
            g_assert(qdict_haskey(qobject_to(QDict, entry->value),
                                  "phys-index"));
            g_assert(qdict_haskey(qobject_to(QDict, entry->value), "online"));
        }
    }
}

static void test_qga_network_get_interfaces(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QList *list;
    const QListEntry *entry;

    ret = qmp_fd(fixture->fd, "{'execute': 'guest-network-get-interfaces'}");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);

    /* check there is at least an interface */
    list = qdict_get_qlist(ret, "return");
    entry = qlist_first(list);
    g_assert(qdict_haskey(qobject_to(QDict, entry->value), "name"));
}

static void test_qga_file_ops(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    const unsigned char helloworld[] = "Hello World!\n";
    const char *b64;
    gchar *path, *enc;
    unsigned char *dec;
    QDict *ret, *val;
    int64_t id, eof;
    gsize count;
    FILE *f;
    char tmp[100];

    /* open */
    ret = qmp_fd(fixture->fd, "{'execute': 'guest-file-open',"
                 " 'arguments': { 'path': 'foo', 'mode': 'w+' } }");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);
    id = qdict_get_int(ret, "return");
    qobject_unref(ret);

    enc = g_base64_encode(helloworld, sizeof(helloworld));
    /* write */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-write',"
                 " 'arguments': { 'handle': %" PRId64 ", 'buf-b64': %s } }",
                 id, enc);
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);

    val = qdict_get_qdict(ret, "return");
    count = qdict_get_int(val, "count");
    eof = qdict_get_bool(val, "eof");
    g_assert_cmpint(count, ==, sizeof(helloworld));
    g_assert_cmpint(eof, ==, 0);
    qobject_unref(ret);

    /* flush */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-flush',"
                 " 'arguments': {'handle': %" PRId64 "} }",
                 id);
    qobject_unref(ret);

    /* close */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-close',"
                 " 'arguments': {'handle': %" PRId64 "} }",
                 id);
    qobject_unref(ret);

    /* check content */
    path = g_build_filename(fixture->test_dir, "foo", NULL);
    f = fopen(path, "r");
    g_free(path);
    g_assert_nonnull(f);
    count = fread(tmp, 1, sizeof(tmp), f);
    g_assert_cmpint(count, ==, sizeof(helloworld));
    tmp[count] = 0;
    g_assert_cmpstr(tmp, ==, (char *)helloworld);
    fclose(f);

    /* open */
    ret = qmp_fd(fixture->fd, "{'execute': 'guest-file-open',"
                 " 'arguments': { 'path': 'foo', 'mode': 'r' } }");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);
    id = qdict_get_int(ret, "return");
    qobject_unref(ret);

    /* read */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-read',"
                 " 'arguments': { 'handle': %" PRId64 "} }",
                 id);
    val = qdict_get_qdict(ret, "return");
    count = qdict_get_int(val, "count");
    eof = qdict_get_bool(val, "eof");
    b64 = qdict_get_str(val, "buf-b64");
    g_assert_cmpint(count, ==, sizeof(helloworld));
    g_assert(eof);
    g_assert_cmpstr(b64, ==, enc);

    qobject_unref(ret);
    g_free(enc);

    /* read eof */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-read',"
                 " 'arguments': { 'handle': %" PRId64 "} }",
                 id);
    val = qdict_get_qdict(ret, "return");
    count = qdict_get_int(val, "count");
    eof = qdict_get_bool(val, "eof");
    b64 = qdict_get_str(val, "buf-b64");
    g_assert_cmpint(count, ==, 0);
    g_assert(eof);
    g_assert_cmpstr(b64, ==, "");
    qobject_unref(ret);

    /* seek */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-seek',"
                 " 'arguments': { 'handle': %" PRId64 ", "
                 " 'offset': %d, 'whence': %s } }",
                 id, 6, "set");
    qmp_assert_no_error(ret);
    val = qdict_get_qdict(ret, "return");
    count = qdict_get_int(val, "position");
    eof = qdict_get_bool(val, "eof");
    g_assert_cmpint(count, ==, 6);
    g_assert(!eof);
    qobject_unref(ret);

    /* partial read */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-read',"
                 " 'arguments': { 'handle': %" PRId64 "} }",
                 id);
    val = qdict_get_qdict(ret, "return");
    count = qdict_get_int(val, "count");
    eof = qdict_get_bool(val, "eof");
    b64 = qdict_get_str(val, "buf-b64");
    g_assert_cmpint(count, ==, sizeof(helloworld) - 6);
    g_assert(eof);
    dec = g_base64_decode(b64, &count);
    g_assert_cmpint(count, ==, sizeof(helloworld) - 6);
    g_assert_cmpmem(dec, count, helloworld + 6, sizeof(helloworld) - 6);
    g_free(dec);

    qobject_unref(ret);

    /* close */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-close',"
                 " 'arguments': {'handle': %" PRId64 "} }",
                 id);
    qobject_unref(ret);
}

static void test_qga_file_write_read(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    const unsigned char helloworld[] = "Hello World!\n";
    const char *b64;
    gchar *enc;
    QDict *ret, *val;
    int64_t id, eof;
    gsize count;

    /* open */
    ret = qmp_fd(fixture->fd, "{'execute': 'guest-file-open',"
                 " 'arguments': { 'path': 'foo', 'mode': 'w+' } }");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);
    id = qdict_get_int(ret, "return");
    qobject_unref(ret);

    enc = g_base64_encode(helloworld, sizeof(helloworld));
    /* write */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-write',"
                 " 'arguments': { 'handle': %" PRId64 ","
                 " 'buf-b64': %s } }", id, enc);
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);

    val = qdict_get_qdict(ret, "return");
    count = qdict_get_int(val, "count");
    eof = qdict_get_bool(val, "eof");
    g_assert_cmpint(count, ==, sizeof(helloworld));
    g_assert_cmpint(eof, ==, 0);
    qobject_unref(ret);

    /* read (check implicit flush) */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-read',"
                 " 'arguments': { 'handle': %" PRId64 "} }",
                 id);
    val = qdict_get_qdict(ret, "return");
    count = qdict_get_int(val, "count");
    eof = qdict_get_bool(val, "eof");
    b64 = qdict_get_str(val, "buf-b64");
    g_assert_cmpint(count, ==, 0);
    g_assert(eof);
    g_assert_cmpstr(b64, ==, "");
    qobject_unref(ret);

    /* seek to 0 */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-seek',"
                 " 'arguments': { 'handle': %" PRId64 ", "
                 " 'offset': %d, 'whence': %s } }",
                 id, 0, "set");
    qmp_assert_no_error(ret);
    val = qdict_get_qdict(ret, "return");
    count = qdict_get_int(val, "position");
    eof = qdict_get_bool(val, "eof");
    g_assert_cmpint(count, ==, 0);
    g_assert(!eof);
    qobject_unref(ret);

    /* read */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-read',"
                 " 'arguments': { 'handle': %" PRId64 "} }",
                 id);
    val = qdict_get_qdict(ret, "return");
    count = qdict_get_int(val, "count");
    eof = qdict_get_bool(val, "eof");
    b64 = qdict_get_str(val, "buf-b64");
    g_assert_cmpint(count, ==, sizeof(helloworld));
    g_assert(eof);
    g_assert_cmpstr(b64, ==, enc);
    qobject_unref(ret);
    g_free(enc);

    /* close */
    ret = qmp_fd(fixture->fd,
                 "{'execute': 'guest-file-close',"
                 " 'arguments': {'handle': %" PRId64 "} }",
                 id);
    qobject_unref(ret);
}

static void test_qga_get_time(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    int64_t time;

    ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-time'}");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);

    time = qdict_get_int(ret, "return");
    g_assert_cmpint(time, >, 0);
}

static void test_qga_blockedrpcs(gconstpointer data)
{
    TestFixture fix;
    QDict *ret, *error;
    const gchar *class, *desc;

    fixture_setup(&fix, "-b guest-ping,guest-get-time", NULL);

    /* check blocked RPCs */
    ret = qmp_fd(fix.fd, "{'execute': 'guest-ping'}");
    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_nonnull(g_strstr_len(desc, -1, "has been disabled"));
    qobject_unref(ret);

    ret = qmp_fd(fix.fd, "{'execute': 'guest-get-time'}");
    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_nonnull(g_strstr_len(desc, -1, "has been disabled"));
    qobject_unref(ret);

    /* check something work */
    ret = qmp_fd(fix.fd, "{'execute': 'guest-get-fsinfo'}");
    qmp_assert_no_error(ret);
    qobject_unref(ret);

    fixture_tear_down(&fix, NULL);
}

static void test_qga_allowedrpcs(gconstpointer data)
{
    TestFixture fix;
    QDict *ret, *error;
    const gchar *class, *desc;

    fixture_setup(&fix, "-a guest-ping,guest-get-time", NULL);

    /* check allowed RPCs */
    ret = qmp_fd(fix.fd, "{'execute': 'guest-ping'}");
    qmp_assert_no_error(ret);
    qobject_unref(ret);

    ret = qmp_fd(fix.fd, "{'execute': 'guest-get-time'}");
    qmp_assert_no_error(ret);
    qobject_unref(ret);

    /* check something else */
    ret = qmp_fd(fix.fd, "{'execute': 'guest-get-fsinfo'}");
    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_nonnull(g_strstr_len(desc, -1, "has been disabled"));
    qobject_unref(ret);

    fixture_tear_down(&fix, NULL);
}

static void test_qga_config(gconstpointer data)
{
    GError *error = NULL;
    g_autofree char *out = NULL;
    g_autofree char *err = NULL;
    g_autofree char *cwd = NULL;
    g_autofree char *cmd = NULL;
    g_auto(GStrv) argv = NULL;
    g_auto(GStrv) strv = NULL;
    g_autoptr(GKeyFile) kf = NULL;
    char *str;
    char *env[2];
    int status;
    gsize n;

    cwd = g_get_current_dir();
    cmd = g_strdup_printf("%s%cqga%cqemu-ga -D",
                          cwd, G_DIR_SEPARATOR, G_DIR_SEPARATOR);
    g_shell_parse_argv(cmd, NULL, &argv, &error);
    g_assert_no_error(error);

    env[0] = g_strdup_printf("QGA_CONF=tests%cdata%ctest-qga-config",
                             G_DIR_SEPARATOR, G_DIR_SEPARATOR);
    env[1] = NULL;
    g_spawn_sync(NULL, argv, env, 0,
                 NULL, NULL, &out, &err, &status, &error);

    g_assert_no_error(error);
    g_assert_cmpstr(err, ==, "");
    g_assert_cmpint(status, ==, 0);

    kf = g_key_file_new();
    g_key_file_load_from_data(kf, out, -1, G_KEY_FILE_NONE, &error);
    g_assert_no_error(error);

    str = g_key_file_get_start_group(kf);
    g_assert_cmpstr(str, ==, "general");
    g_free(str);

    g_assert_false(g_key_file_get_boolean(kf, "general", "daemon", &error));
    g_assert_no_error(error);

    str = g_key_file_get_string(kf, "general", "method", &error);
    g_assert_no_error(error);
    g_assert_cmpstr(str, ==, "virtio-serial");
    g_free(str);

    str = g_key_file_get_string(kf, "general", "path", &error);
    g_assert_no_error(error);
    g_assert_cmpstr(str, ==, "/path/to/org.qemu.guest_agent.0");
    g_free(str);

    str = g_key_file_get_string(kf, "general", "pidfile", &error);
    g_assert_no_error(error);
    g_assert_cmpstr(str, ==, "/var/foo/qemu-ga.pid");
    g_free(str);

    str = g_key_file_get_string(kf, "general", "statedir", &error);
    g_assert_no_error(error);
    g_assert_cmpstr(str, ==, "/var/state");
    g_free(str);

    g_assert_true(g_key_file_get_boolean(kf, "general", "verbose", &error));
    g_assert_no_error(error);

    strv = g_key_file_get_string_list(kf, "general", "block-rpcs", &n, &error);
    g_assert_cmpint(n, ==, 2);
    g_assert_true(g_strv_contains((const char * const *)strv,
                                  "guest-ping"));
    g_assert_true(g_strv_contains((const char * const *)strv,
                                  "guest-get-time"));
    g_assert_no_error(error);

    g_free(env[0]);
}

static void test_qga_fsfreeze_status(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    const gchar *status;

    ret = qmp_fd(fixture->fd, "{'execute': 'guest-fsfreeze-status'}");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);

    status = qdict_get_try_str(ret, "return");
    g_assert_cmpstr(status, ==, "thawed");
}

static QDict *wait_for_guest_exec_completion(int fd, int64_t pid)
{
    QDict *ret = NULL;
    int64_t now;
    bool exited;
    QDict *val;

    now = g_get_monotonic_time();
    do {
        ret = qmp_fd(fd,
                     "{'execute': 'guest-exec-status',"
                     " 'arguments': { 'pid': %" PRId64 " } }", pid);
        g_assert_nonnull(ret);
        val = qdict_get_qdict(ret, "return");
        exited = qdict_get_bool(val, "exited");
        if (!exited) {
            qobject_unref(ret);
        }
    } while (!exited &&
             g_get_monotonic_time() < now + 5 * G_TIME_SPAN_SECOND);
    g_assert(exited);

    return ret;
}

static void test_qga_guest_exec(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *val;
    const gchar *out;
    g_autofree guchar *decoded = NULL;
    int64_t pid, exitcode;
    gsize len;

    /* exec 'echo foo bar' */
    ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {"
                 " 'path': '/bin/echo', 'arg': [ '-n', '\" test_str \"' ],"
                 " 'capture-output': true } }");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);
    val = qdict_get_qdict(ret, "return");
    pid = qdict_get_int(val, "pid");
    g_assert_cmpint(pid, >, 0);
    qobject_unref(ret);

    ret = wait_for_guest_exec_completion(fixture->fd, pid);

    /* check stdout */
    val = qdict_get_qdict(ret, "return");
    exitcode = qdict_get_int(val, "exitcode");
    g_assert_cmpint(exitcode, ==, 0);
    out = qdict_get_str(val, "out-data");
    decoded = g_base64_decode(out, &len);
    g_assert_cmpint(len, ==, 12);
    g_assert_cmpstr((char *)decoded, ==, "\" test_str \"");
}

#if defined(G_OS_WIN32)
static void test_qga_guest_exec_separated(gconstpointer fix)
{
}
static void test_qga_guest_exec_merged(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *val;
    const gchar *class, *desc;
    g_autofree guchar *decoded = NULL;

    /* exec 'echo foo bar' */
    ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {"
                 " 'path': 'echo',"
                 " 'arg': [ 'execution never reaches here' ],"
                 " 'capture-output': 'merged' } }");

    g_assert_nonnull(ret);
    val = qdict_get_qdict(ret, "error");
    g_assert_nonnull(val);
    class = qdict_get_str(val, "class");
    desc = qdict_get_str(val, "desc");
    g_assert_cmpstr(class, ==, "GenericError");
    g_assert_cmpint(strlen(desc), >, 0);
}
#else
static void test_qga_guest_exec_separated(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *val;
    const gchar *out, *err;
    g_autofree guchar *out_decoded = NULL;
    g_autofree guchar *err_decoded = NULL;
    int64_t pid, exitcode;
    gsize len;

    /* exec 'echo foo bar' */
    ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {"
                 " 'path': '/bin/bash',"
                 " 'arg': [ '-c', 'for i in $(seq 4); do if (( $i %% 2 )); then echo stdout; else echo stderr 1>&2; fi; done;' ],"
                 " 'capture-output': 'separated' } }");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);
    val = qdict_get_qdict(ret, "return");
    pid = qdict_get_int(val, "pid");
    g_assert_cmpint(pid, >, 0);
    qobject_unref(ret);

    ret = wait_for_guest_exec_completion(fixture->fd, pid);

    val = qdict_get_qdict(ret, "return");
    exitcode = qdict_get_int(val, "exitcode");
    g_assert_cmpint(exitcode, ==, 0);

    /* check stdout */
    out = qdict_get_str(val, "out-data");
    out_decoded = g_base64_decode(out, &len);
    g_assert_cmpint(len, ==, 14);
    g_assert_cmpstr((char *)out_decoded, ==, "stdout\nstdout\n");

    /* check stderr */
    err = qdict_get_try_str(val, "err-data");
    err_decoded = g_base64_decode(err, &len);
    g_assert_cmpint(len, ==, 14);
    g_assert_cmpstr((char *)err_decoded, ==, "stderr\nstderr\n");
}

static void test_qga_guest_exec_merged(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *val;
    const gchar *out, *err;
    g_autofree guchar *decoded = NULL;
    int64_t pid, exitcode;
    gsize len;

    /* exec 'echo foo bar' */
    ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {"
                 " 'path': '/bin/bash',"
                 " 'arg': [ '-c', 'for i in $(seq 4); do if (( $i %% 2 )); then echo stdout; else echo stderr 1>&2; fi; done;' ],"
                 " 'capture-output': 'merged' } }");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);
    val = qdict_get_qdict(ret, "return");
    pid = qdict_get_int(val, "pid");
    g_assert_cmpint(pid, >, 0);
    qobject_unref(ret);

    ret = wait_for_guest_exec_completion(fixture->fd, pid);

    val = qdict_get_qdict(ret, "return");
    exitcode = qdict_get_int(val, "exitcode");
    g_assert_cmpint(exitcode, ==, 0);

    /* check stdout */
    out = qdict_get_str(val, "out-data");
    decoded = g_base64_decode(out, &len);
    g_assert_cmpint(len, ==, 28);
    g_assert_cmpstr((char *)decoded, ==, "stdout\nstderr\nstdout\nstderr\n");

    /* check stderr */
    err = qdict_get_try_str(val, "err-data");
    g_assert_null(err);
}
#endif

static void test_qga_guest_exec_invalid(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *error;
    const gchar *class, *desc;

    /* invalid command */
    ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {"
                 " 'path': '/bin/invalid-cmd42' } }");
    g_assert_nonnull(ret);
    error = qdict_get_qdict(ret, "error");
    g_assert_nonnull(error);
    class = qdict_get_str(error, "class");
    desc = qdict_get_str(error, "desc");
    g_assert_cmpstr(class, ==, "GenericError");
    g_assert_cmpint(strlen(desc), >, 0);
    qobject_unref(ret);

    /* invalid pid */
    ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec-status',"
                 " 'arguments': { 'pid': 0 } }");
    g_assert_nonnull(ret);
    error = qdict_get_qdict(ret, "error");
    g_assert_nonnull(error);
    class = qdict_get_str(error, "class");
    desc = qdict_get_str(error, "desc");
    g_assert_cmpstr(class, ==, "GenericError");
    g_assert_cmpint(strlen(desc), >, 0);
}

static void test_qga_guest_get_host_name(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *val;

    ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-host-name'}");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);

    val = qdict_get_qdict(ret, "return");
    g_assert(qdict_haskey(val, "host-name"));
}

static void test_qga_guest_get_timezone(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QDict *val;

    ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-timezone'}");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);

    /* Make sure there's at least offset */
    val = qdict_get_qdict(ret, "return");
    g_assert(qdict_haskey(val, "offset"));
}

static void test_qga_guest_get_users(gconstpointer fix)
{
    const TestFixture *fixture = fix;
    g_autoptr(QDict) ret = NULL;
    QList *val;

    ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-users'}");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);

    /* There is not much to test here */
    val = qdict_get_qlist(ret, "return");
    g_assert_nonnull(val);
}

static void test_qga_guest_get_osinfo(gconstpointer data)
{
    TestFixture fixture;
    const gchar *str;
    g_autoptr(QDict) ret = NULL;
    char *env[2];
    QDict *val;

    env[0] = g_strdup_printf(
        "QGA_OS_RELEASE=%s%c..%cdata%ctest-qga-os-release",
        g_test_get_dir(G_TEST_DIST), G_DIR_SEPARATOR, G_DIR_SEPARATOR, G_DIR_SEPARATOR);
    env[1] = NULL;
    fixture_setup(&fixture, NULL, env);

    ret = qmp_fd(fixture.fd, "{'execute': 'guest-get-osinfo'}");
    g_assert_nonnull(ret);
    qmp_assert_no_error(ret);

    val = qdict_get_qdict(ret, "return");

    str = qdict_get_try_str(val, "id");
    g_assert_nonnull(str);
    g_assert_cmpstr(str, ==, "qemu-ga-test");

    str = qdict_get_try_str(val, "name");
    g_assert_nonnull(str);
    g_assert_cmpstr(str, ==, "QEMU-GA");

    str = qdict_get_try_str(val, "pretty-name");
    g_assert_nonnull(str);
    g_assert_cmpstr(str, ==, "QEMU Guest Agent test");

    str = qdict_get_try_str(val, "version");
    g_assert_nonnull(str);
    g_assert_cmpstr(str, ==, "Test 1");

    str = qdict_get_try_str(val, "version-id");
    g_assert_nonnull(str);
    g_assert_cmpstr(str, ==, "1");

    str = qdict_get_try_str(val, "variant");
    g_assert_nonnull(str);
    g_assert_cmpstr(str, ==, "Unit test \"'$`\\ and \\\\ etc.");

    str = qdict_get_try_str(val, "variant-id");
    g_assert_nonnull(str);
    g_assert_cmpstr(str, ==, "unit-test");

    g_free(env[0]);
    fixture_tear_down(&fixture, NULL);
}

int main(int argc, char **argv)
{
    TestFixture fix;
    int ret;

#ifdef QEMU_SANITIZE_THREAD
    {
        g_test_skip("tsan enabled, https://github.com/google/sanitizers/issues/1116");
        return 0;
    }
#endif

    setlocale (LC_ALL, "");
    g_test_init(&argc, &argv, NULL);
    fixture_setup(&fix, NULL, NULL);

    g_test_add_data_func("/qga/sync-delimited", &fix, test_qga_sync_delimited);
    g_test_add_data_func("/qga/sync", &fix, test_qga_sync);
    g_test_add_data_func("/qga/ping", &fix, test_qga_ping);
    g_test_add_data_func("/qga/info", &fix, test_qga_info);
    g_test_add_data_func("/qga/network-get-interfaces", &fix,
                         test_qga_network_get_interfaces);
    if (!access("/sys/devices/system/cpu/cpu0", F_OK)) {
        g_test_add_data_func("/qga/get-vcpus", &fix, test_qga_get_vcpus);
    }
    g_test_add_data_func("/qga/get-fsinfo", &fix, test_qga_get_fsinfo);
    g_test_add_data_func("/qga/get-memory-block-info", &fix,
                         test_qga_get_memory_block_info);
    g_test_add_data_func("/qga/get-memory-blocks", &fix,
                         test_qga_get_memory_blocks);
    g_test_add_data_func("/qga/file-ops", &fix, test_qga_file_ops);
    g_test_add_data_func("/qga/file-write-read", &fix, test_qga_file_write_read);
    g_test_add_data_func("/qga/get-time", &fix, test_qga_get_time);
    g_test_add_data_func("/qga/id", &fix, test_qga_id);
    g_test_add_data_func("/qga/invalid-oob", &fix, test_qga_invalid_oob);
    g_test_add_data_func("/qga/invalid-cmd", &fix, test_qga_invalid_cmd);
    g_test_add_data_func("/qga/invalid-args", &fix, test_qga_invalid_args);
    g_test_add_data_func("/qga/fsfreeze-status", &fix,
                         test_qga_fsfreeze_status);

    g_test_add_data_func("/qga/blockedrpcs", NULL, test_qga_blockedrpcs);
    g_test_add_data_func("/qga/allowedrpcs", NULL, test_qga_allowedrpcs);
    g_test_add_data_func("/qga/config", NULL, test_qga_config);
    g_test_add_data_func("/qga/guest-exec", &fix, test_qga_guest_exec);
    g_test_add_data_func("/qga/guest-exec-separated", &fix,
                         test_qga_guest_exec_separated);
    g_test_add_data_func("/qga/guest-exec-merged", &fix,
                         test_qga_guest_exec_merged);
    g_test_add_data_func("/qga/guest-exec-invalid", &fix,
                         test_qga_guest_exec_invalid);
    g_test_add_data_func("/qga/guest-get-osinfo", &fix,
                         test_qga_guest_get_osinfo);
    g_test_add_data_func("/qga/guest-get-host-name", &fix,
                         test_qga_guest_get_host_name);
    g_test_add_data_func("/qga/guest-get-timezone", &fix,
                         test_qga_guest_get_timezone);
    g_test_add_data_func("/qga/guest-get-users", &fix,
                         test_qga_guest_get_users);

    ret = g_test_run();

    fixture_tear_down(&fix, NULL);

    return ret;
}
