/*
 * Various tests for emulated CD-ROM drives.
 *
 * Copyright (c) 2018 Red Hat Inc.
 *
 * Author:
 *    Thomas Huth <thuth@redhat.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2
 * or later. See the COPYING file in the top-level directory.
 */

#include "qemu/osdep.h"
#include "libqtest.h"
#include "boot-sector.h"
#include "qapi/qmp/qdict.h"

static char isoimage[] = "cdrom-boot-iso-XXXXXX";

static int exec_xorrisofs(const char **args)
{
    gchar *out_err = NULL;
    gint exit_status = -1;
    bool success;

    success = g_spawn_sync(NULL, (gchar **)args, NULL,
                           G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL,
                           NULL, NULL, NULL, &out_err, &exit_status, NULL);
    if (!success) {
        return -ENOENT;
    }
    if (out_err) {
        fputs(out_err, stderr);
        g_free(out_err);
    }

    return exit_status;
}

static int prepare_image(const char *arch, char *isoimage)
{
    char srcdir[] = "cdrom-test-dir-XXXXXX";
    char *codefile = NULL;
    int ifh, ret = -1;
    const char *args[] = {
        "xorrisofs", "-quiet", "-l", "-no-emul-boot",
        "-b", NULL, "-o", isoimage, srcdir, NULL
    };

    ifh = mkstemp(isoimage);
    if (ifh < 0) {
        perror("Error creating temporary iso image file");
        return -1;
    }
    if (!g_mkdtemp(srcdir)) {
        perror("Error creating temporary directory");
        goto cleanup;
    }

    if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64") ||
        g_str_equal(arch, "s390x")) {
        codefile = g_strdup_printf("%s/bootcode-XXXXXX", srcdir);
        ret = boot_sector_init(codefile);
        if (ret) {
            goto cleanup;
        }
    } else {
        /* Just create a dummy file */
        char txt[] = "empty disc";
        codefile = g_strdup_printf("%s/readme.txt", srcdir);
        if (!g_file_set_contents(codefile, txt, sizeof(txt) - 1, NULL)) {
            fprintf(stderr, "Failed to create '%s'\n", codefile);
            goto cleanup;
        }
    }

    args[5] = strchr(codefile, '/') + 1;
    ret = exec_xorrisofs(args);
    if (ret) {
        fprintf(stderr, "xorrisofs failed: %i\n", ret);
    }

    unlink(codefile);

cleanup:
    g_free(codefile);
    rmdir(srcdir);
    close(ifh);

    return ret;
}

/**
 * Check that at least the -cdrom parameter is basically working, i.e. we can
 * see the filename of the ISO image in the output of "info block" afterwards
 */
static void test_cdrom_param(gconstpointer data)
{
    QTestState *qts;
    char *resp;

    qts = qtest_initf("-M %s -cdrom %s", (const char *)data, isoimage);
    resp = qtest_hmp(qts, "info block");
    g_assert(strstr(resp, isoimage) != 0);
    g_free(resp);
    qtest_quit(qts);
}

static void add_cdrom_param_tests(const char **machines)
{
    while (*machines) {
        if (qtest_has_machine(*machines)) {
            char *testname = g_strdup_printf("cdrom/param/%s", *machines);
            qtest_add_data_func(testname, *machines, test_cdrom_param);
            g_free(testname);
        }
        machines++;
    }
}

static void test_cdboot(gconstpointer data)
{
    QTestState *qts;

    qts = qtest_initf("-accel kvm -accel tcg -no-shutdown %s%s", (const char *)data,
                      isoimage);
    boot_sector_test(qts);
    qtest_quit(qts);
}

static void add_x86_tests(void)
{
    if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
        g_test_skip("No KVM or TCG accelerator available, skipping boot tests");
        return;
    }

    qtest_add_data_func("cdrom/boot/default", "-cdrom ", test_cdboot);
    if (qtest_has_device("virtio-scsi-ccw")) {
        qtest_add_data_func("cdrom/boot/virtio-scsi",
                            "-device virtio-scsi -device scsi-cd,drive=cdr "
                            "-blockdev file,node-name=cdr,filename=",
                            test_cdboot);
    }
    /*
     * Unstable CI test under load
     * See https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg05509.html
     */
    if (g_test_slow() && qtest_has_machine("isapc")) {
        qtest_add_data_func("cdrom/boot/isapc", "-M isapc "
                            "-drive if=ide,media=cdrom,file=", test_cdboot);
    }
    if (qtest_has_device("am53c974")) {
        qtest_add_data_func("cdrom/boot/am53c974",
                            "-device am53c974 -device scsi-cd,drive=cd1 "
                            "-drive if=none,id=cd1,format=raw,file=",
                            test_cdboot);
    }
    if (qtest_has_device("dc390")) {
        qtest_add_data_func("cdrom/boot/dc390",
                            "-device dc390 -device scsi-cd,drive=cd1 "
                            "-blockdev file,node-name=cd1,filename=",
                            test_cdboot);
    }
    if (qtest_has_device("lsi53c895a")) {
        qtest_add_data_func("cdrom/boot/lsi53c895a",
                            "-device lsi53c895a -device scsi-cd,drive=cd1 "
                            "-blockdev file,node-name=cd1,filename=",
                            test_cdboot);
    }
    if (qtest_has_device("megasas")) {
        qtest_add_data_func("cdrom/boot/megasas", "-M q35 "
                            "-device megasas -device scsi-cd,drive=cd1 "
                            "-blockdev file,node-name=cd1,filename=",
                            test_cdboot);
    }
    if (qtest_has_device("megasas-gen2")) {
        qtest_add_data_func("cdrom/boot/megasas-gen2", "-M q35 "
                            "-device megasas-gen2 -device scsi-cd,drive=cd1 "
                            "-blockdev file,node-name=cd1,filename=",
                            test_cdboot);
    }
}

static void add_s390x_tests(void)
{
    if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
        g_test_skip("No KVM or TCG accelerator available, skipping boot tests");
    }
    if (!qtest_has_device("virtio-blk-ccw")) {
        return;
    }

    qtest_add_data_func("cdrom/boot/default", "-cdrom ", test_cdboot);

    if (!qtest_has_device("virtio-scsi-ccw")) {
        return;
    }

    qtest_add_data_func("cdrom/boot/virtio-scsi",
                        "-device virtio-scsi -device scsi-cd,drive=cdr "
                        "-blockdev file,node-name=cdr,filename=", test_cdboot);
    qtest_add_data_func("cdrom/boot/with-bootindex",
                        "-device virtio-serial -device virtio-scsi "
                        "-device virtio-blk,drive=d1 "
                        "-drive driver=null-co,read-zeroes=on,if=none,id=d1 "
                        "-device virtio-blk,drive=d2,bootindex=1 "
                        "-drive if=none,id=d2,media=cdrom,file=", test_cdboot);
    if (qtest_has_device("x-terminal3270")) {
        qtest_add_data_func("cdrom/boot/without-bootindex",
                            "-device virtio-scsi -device virtio-serial "
                            "-device x-terminal3270 -device virtio-blk,drive=d1 "
                            "-drive driver=null-co,read-zeroes=on,if=none,id=d1 "
                            "-device virtio-blk,drive=d2 "
                            "-drive if=none,id=d2,media=cdrom,file=",
                            test_cdboot);
    }
}

int main(int argc, char **argv)
{
    int ret;
    const char *arch = qtest_get_arch();
    const char *xorrisocheck[] = { "xorrisofs", "-version", NULL };

    g_test_init(&argc, &argv, NULL);

    if (exec_xorrisofs(xorrisocheck)) {
        /* xorrisofs not available - so can't run tests */
        return g_test_run();
    }

    ret = prepare_image(arch, isoimage);
    if (ret) {
        return ret;
    }

    if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64")) {
        add_x86_tests();
    } else if (g_str_equal(arch, "s390x")) {
        add_s390x_tests();
    } else if (g_str_equal(arch, "ppc64")) {
        const char *ppcmachines[] = {
            "pseries", "mac99", "g3beige", "40p", NULL
        };
        add_cdrom_param_tests(ppcmachines);
    } else if (g_str_equal(arch, "sparc")) {
        const char *sparcmachines[] = {
            "LX", "SPARCClassic", "SPARCbook", "SS-10", "SS-20", "SS-4",
            "SS-5", "SS-600MP", "Voyager", "leon3_generic", NULL
        };
        add_cdrom_param_tests(sparcmachines);
    } else if (g_str_equal(arch, "sparc64")) {
        const char *sparc64machines[] = {
            "niagara", "sun4u", "sun4v", NULL
        };
        add_cdrom_param_tests(sparc64machines);
    } else if (!strncmp(arch, "mips64", 6)) {
        const char *mips64machines[] = {
            "magnum", "malta", "pica61", NULL
        };
        add_cdrom_param_tests(mips64machines);
    } else if (g_str_equal(arch, "arm") || g_str_equal(arch, "aarch64")) {
        const char *armmachines[] = {
            "realview-eb", "realview-eb-mpcore", "realview-pb-a8",
            "realview-pbx-a9", "versatileab", "versatilepb", "vexpress-a15",
            "vexpress-a9", "virt", NULL
        };
        add_cdrom_param_tests(armmachines);
    } else {
        const char *nonemachine[] = { "none", NULL };
        add_cdrom_param_tests(nonemachine);
    }

    ret = g_test_run();

    unlink(isoimage);

    return ret;
}
