示例#1
0
static void virtio_serial_hotplug(void)
{
    global_qtest = qtest_initf("-device virtio-serial-ccw");
    qtest_qmp_device_add("virtserialport", "hp-port", "{}");
    qtest_qmp_device_del("hp-port");
    qtest_end();
}
示例#2
0
static void test_drive_add_empty(void)
{
    QDict *response;
    const char *response_return;

    /* Start with an empty drive */
    qtest_start("-drive if=none,id=drive0");

    /* Delete the drive */
    response = qmp("{\"execute\": \"human-monitor-command\","
                   " \"arguments\": {"
                   "   \"command-line\": \"drive_del drive0\""
                   "}}");
    g_assert(response);
    response_return = qdict_get_try_str(response, "return");
    g_assert(response_return);
    g_assert(strcmp(response_return, "") == 0);
    QDECREF(response);

    /* Ensure re-adding the drive works - there should be no duplicate ID error
     * because the old drive must be gone.
     */
    response = qmp("{\"execute\": \"human-monitor-command\","
                   " \"arguments\": {"
                   "   \"command-line\": \"drive_add 0 if=none,id=drive0\""
                   "}}");
    g_assert(response);
    response_return = qdict_get_try_str(response, "return");
    g_assert(response_return);
    g_assert(strcmp(response_return, "OK\r\n") == 0);
    QDECREF(response);

    qtest_end();
}
示例#3
0
static void test_plug_with_device_add_x86(gconstpointer data)
{
    const PlugTestData *td = data;
    char *args;
    unsigned int s, c, t;

    args = g_strdup_printf("-machine %s -cpu %s "
                           "-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
                           td->machine, td->cpu_model,
                           td->sockets, td->cores, td->threads, td->maxcpus);
    qtest_start(args);

    for (s = 1; s < td->sockets; s++) {
        for (c = 0; c < td->cores; c++) {
            for (t = 0; t < td->threads; t++) {
                char *id = g_strdup_printf("id-%i-%i-%i", s, c, t);
                qtest_qmp_device_add(td->device_model, id,
                                     "{'socket-id':%u, 'core-id':%u,"
                                     " 'thread-id':%u}",
                                     s, c, t);
                g_free(id);
            }
        }
    }

    qtest_end();
    g_free(args);
}
示例#4
0
int main(int argc, char **argv)
{
    int ret;
    char *args;
    const char *devstr = "e1000";

    if (g_str_equal(qtest_get_arch(), "s390x")) {
        devstr = "virtio-net-ccw";
    }

    g_test_init(&argc, &argv, NULL);
    qtest_add_func("/netfilter/addremove_one", add_one_netfilter);
    qtest_add_func("/netfilter/remove_netdev_one",
                   remove_netdev_with_one_netfilter);
    qtest_add_func("/netfilter/addremove_multi", add_multi_netfilter);
    qtest_add_func("/netfilter/remove_netdev_multi",
                   remove_netdev_with_multi_netfilter);

    args = g_strdup_printf("-netdev user,id=qtest-bn0 "
                           "-device %s,netdev=qtest-bn0", devstr);
    qtest_start(args);
    ret = g_test_run();

    qtest_end();
    g_free(args);

    return ret;
}
示例#5
0
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);
    qtest_add_func("/ehci/pci/init", pci_init);
    qtest_add_func("/ehci/pci/uhci-port-1", pci_uhci_port_1);
    qtest_add_func("/ehci/pci/ehci-port-1", pci_ehci_port_1);
    qtest_add_func("/ehci/pci/ehci-config", pci_ehci_config);
    qtest_add_func("/ehci/pci/uhci-port-2", pci_uhci_port_2);
    qtest_add_func("/ehci/pci/ehci-port-2", pci_ehci_port_2);
    qtest_add_func("/ehci/pci/ehci-port-3-hotplug", pci_ehci_port_hotplug);

    qtest_start("-machine q35 -device ich9-usb-ehci1,bus=pcie.0,addr=1d.7,"
                "multifunction=on,id=ich9-ehci-1 "
                "-device ich9-usb-uhci1,bus=pcie.0,addr=1d.0,"
                "multifunction=on,masterbus=ich9-ehci-1.0,firstport=0 "
                "-device ich9-usb-uhci2,bus=pcie.0,addr=1d.1,"
                "multifunction=on,masterbus=ich9-ehci-1.0,firstport=2 "
                "-device ich9-usb-uhci3,bus=pcie.0,addr=1d.2,"
                "multifunction=on,masterbus=ich9-ehci-1.0,firstport=4 "
                "-drive if=none,id=usbcdrom,media=cdrom "
                "-device usb-tablet,bus=ich9-ehci-1.0,port=1,usb_version=1 "
                "-device usb-storage,bus=ich9-ehci-1.0,port=2,drive=usbcdrom ");
    ret = g_test_run();

    qtest_end();

    return ret;
}
示例#6
0
static void add_pc_test_cases(void)
{
    QDict *response, *minfo;
    QList *list;
    const QListEntry *p;
    QObject *qobj;
    QString *qstr;
    const char *mname, *path;
    PCTestData *data;

    qtest_start("-machine none");
    response = qmp("{ 'execute': 'query-machines' }");
    g_assert(response);
    list = qdict_get_qlist(response, "return");
    g_assert(list);

    for (p = qlist_first(list); p; p = qlist_next(p)) {
        minfo = qobject_to_qdict(qlist_entry_obj(p));
        g_assert(minfo);
        qobj = qdict_get(minfo, "name");
        g_assert(qobj);
        qstr = qobject_to_qstring(qobj);
        g_assert(qstr);
        mname = qstring_get_str(qstr);
        if (!g_str_has_prefix(mname, "pc-")) {
            continue;
        }
        data = g_malloc(sizeof(PCTestData));
        data->machine = mname;
        data->cpu_model = "Haswell"; /* 1.3+ theoretically */
        data->sockets = 1;
        data->cores = 3;
        data->threads = 2;
        data->maxcpus = data->sockets * data->cores * data->threads * 2;
        if (g_str_has_suffix(mname, "-1.4") ||
            (strcmp(mname, "pc-1.3") == 0) ||
            (strcmp(mname, "pc-1.2") == 0) ||
            (strcmp(mname, "pc-1.1") == 0) ||
            (strcmp(mname, "pc-1.0") == 0) ||
            (strcmp(mname, "pc-0.15") == 0) ||
            (strcmp(mname, "pc-0.14") == 0) ||
            (strcmp(mname, "pc-0.13") == 0) ||
            (strcmp(mname, "pc-0.12") == 0) ||
            (strcmp(mname, "pc-0.11") == 0) ||
            (strcmp(mname, "pc-0.10") == 0)) {
            path = g_strdup_printf("cpu/%s/init/%ux%ux%u&maxcpus=%u",
                                   mname, data->sockets, data->cores,
                                   data->threads, data->maxcpus);
            qtest_add_data_func(path, data, test_pc_without_cpu_add);
        } else {
            path = g_strdup_printf("cpu/%s/add/%ux%ux%u&maxcpus=%u",
                                   mname, data->sockets, data->cores,
                                   data->threads, data->maxcpus);
            qtest_add_data_func(path, data, test_pc_with_cpu_add);
        }
    }
    qtest_end();
}
示例#7
0
static void virtio_scsi_hotplug(void)
{
    global_qtest = qtest_initf("-drive if=none,id=drv0,file=null-co://,format=raw "
                                "-drive if=none,id=drv1,file=null-co://,format=raw "
                                "-device virtio-scsi-ccw "
                                "-device scsi-hd,drive=drv0");
    qtest_qmp_device_add("scsi-hd", "scsihd", "{'drive': 'drv1'}");
    qtest_qmp_device_del("scsihd");

    qtest_end();
}
示例#8
0
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);
    qtest_add_func("/rtl8139/nop", nop);

    qtest_start("-device rtl8139");
    ret = g_test_run();

    qtest_end();

    return ret;
}
示例#9
0
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);
    qtest_add_func("/pvpanic/panic", test_panic);

    qtest_start("-device pvpanic");
    ret = g_test_run();

    qtest_end();

    return ret;
}
示例#10
0
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);
    qtest_add_func("/ne2000/pci/nop", pci_nop);

    qtest_start("-device ne2k_pci");
    ret = g_test_run();

    qtest_end();

    return ret;
}
示例#11
0
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);
    qtest_add_func("/ipoctal232/tpci200/nop", nop);

    qtest_start("-device tpci200,id=ipack0 -device ipoctal232,bus=ipack0.0");
    ret = g_test_run();

    qtest_end();

    return ret;
}
示例#12
0
int main(int argc, char **argv)
{
    const char *arch = qtest_get_arch();
    char *cmdline;
    int fd;
    int ret;

    /* Check architecture */
    if (strcmp(arch, "i386") && strcmp(arch, "x86_64")) {
        g_test_message("Skipping test for non-x86\n");
        return 0;
    }

    /* Create a temporary raw image */
    fd = mkstemp(test_image);
    g_assert(fd >= 0);
    ret = ftruncate(fd, TEST_IMAGE_SIZE);
    g_assert(ret == 0);
    close(fd);

    /* Run the tests */
    g_test_init(&argc, &argv, NULL);

    cmdline = g_strdup_printf("-vnc none ");

    qtest_start(cmdline);
    qtest_irq_intercept_in(global_qtest, "ioapic");
    qtest_add_func("/fdc/cmos", test_cmos);
    qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start);
    qtest_add_func("/fdc/read_without_media", test_read_without_media);
    qtest_add_func("/fdc/media_change", test_media_change);
    qtest_add_func("/fdc/sense_interrupt", test_sense_interrupt);
    qtest_add_func("/fdc/relative_seek", test_relative_seek);
    qtest_add_func("/fdc/read_id", test_read_id);
    qtest_add_func("/fdc/verify", test_verify);
    qtest_add_func("/fdc/media_insert", test_media_insert);
    qtest_add_func("/fdc/read_no_dma_1", test_read_no_dma_1);
    qtest_add_func("/fdc/read_no_dma_18", test_read_no_dma_18);
    qtest_add_func("/fdc/read_no_dma_19", test_read_no_dma_19);
    qtest_add_func("/fdc/fuzz-registers", fuzz_registers);

    ret = g_test_run();

    /* Cleanup */
    qtest_end();
    unlink(test_image);

    return ret;
}
示例#13
0
文件: test-hmp.c 项目: twnkl/qemu
static void test_machine(gconstpointer data)
{
    const char *machine = data;
    char *args;

    args = g_strdup_printf("-S -M %s", machine);
    qtest_start(args);

    test_info_commands();
    test_commands();

    qtest_end();
    g_free(args);
    g_free((void *)data);
}
示例#14
0
文件: ivshmem-test.c 项目: gkurz/qemu
static void test_ivshmem_hotplug(void)
{
    const char *arch = qtest_get_arch();

    qtest_start("-object memory-backend-ram,size=1M,id=mb1");

    qtest_qmp_device_add("ivshmem-plain", "iv1",
                         "{'addr': %s, 'memdev': 'mb1'}",
                         stringify(PCI_SLOT_HP));
    if (strcmp(arch, "ppc64") != 0) {
        qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP);
    }

    qtest_end();
}
示例#15
0
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);
    qtest_add_func("/spapr-phb/device", test_phb_device);

    qtest_start("-device " TYPE_SPAPR_PCI_HOST_BRIDGE ",index=100");

    ret = g_test_run();

    qtest_end();

    return ret;
}
示例#16
0
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);

    qtest_add_func("/ohci/pci/init", test_ohci_init);
    qtest_add_func("/ohci/pci/hotplug", test_ohci_hotplug);

    qtest_start("-device pci-ohci,id=ohci");
    ret = g_test_run();
    qtest_end();

    return ret;
}
示例#17
0
文件: ioh3420-test.c 项目: 8tab/qemu
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);
    qtest_add_func("/ioh3420/nop", nop);

    qtest_start("-machine q35 -device ioh3420,bus=pcie.0,addr=1c.0,port=1,"
                "chassis=1,multifunction=on");
    ret = g_test_run();

    qtest_end();

    return ret;
}
示例#18
0
static void test_device_intro_list(void)
{
    QList *types;
    char *help;

    qtest_start(common_args);

    types = device_type_list(true);
    QDECREF(types);

    help = hmp("device_add help");
    g_free(help);

    qtest_end();
}
示例#19
0
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);
    qtest_add_func("/nvme/nop", nop);

    qtest_start("-drive id=drv0,if=none,file=/dev/null,format=raw "
                "-device nvme,drive=drv0,serial=foo");
    ret = g_test_run();

    qtest_end();

    return ret;
}
示例#20
0
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);
    qtest_add_func("/virtio/serial/pci/nop", pci_nop);
    qtest_add_func("/virtio/serial/pci/hotplug", hotplug);

    qtest_start("-device virtio-serial-pci");
    ret = g_test_run();

    qtest_end();

    return ret;
}
示例#21
0
int main(int argc, char **argv)
{
    int ret;

    g_test_init(&argc, &argv, NULL);

    qtest_add_func("/xhci/pci/init", test_xhci_init);
    qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
    qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);

    qtest_start("-device nec-usb-xhci,id=xhci"
                " -drive id=drive0,if=none,file=/dev/null,format=raw");
    ret = g_test_run();
    qtest_end();

    return ret;
}
示例#22
0
static void test_plug_with_device_add_coreid(gconstpointer data)
{
    const PlugTestData *td = data;
    char *args;
    unsigned int c;

    args = g_strdup_printf("-machine %s -cpu %s "
                           "-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
                           td->machine, td->cpu_model,
                           td->sockets, td->cores, td->threads, td->maxcpus);
    qtest_start(args);

    for (c = 1; c < td->cores; c++) {
        char *id = g_strdup_printf("id-%i", c);
        qtest_qmp_device_add(td->device_model, id, "{'core-id':%u}", c);
        g_free(id);
    }

    qtest_end();
    g_free(args);
}
示例#23
0
static void test_plug_without_cpu_add(gconstpointer data)
{
    const PlugTestData *s = data;
    char *args;
    QDict *response;

    args = g_strdup_printf("-machine %s -cpu %s "
                           "-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
                           s->machine, s->cpu_model,
                           s->sockets, s->cores, s->threads, s->maxcpus);
    qtest_start(args);

    response = qmp("{ 'execute': 'cpu-add',"
                   "  'arguments': { 'id': %d } }",
                   s->sockets * s->cores * s->threads);
    g_assert(response);
    g_assert(qdict_haskey(response, "error"));
    qobject_unref(response);

    qtest_end();
    g_free(args);
}
示例#24
0
文件: pc-cpu-test.c 项目: Xilinx/qemu
static void test_pc_with_cpu_add(gconstpointer data)
{
    const PCTestData *s = data;
    char *args;
    QDict *response;
    unsigned int i;

    args = g_strdup_printf("-machine %s -cpu %s "
                           "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
                           s->machine, s->cpu_model,
                           s->sockets, s->cores, s->threads, s->maxcpus);
    qtest_start(args);

    for (i = s->sockets * s->cores * s->threads; i < s->maxcpus; i++) {
        response = qmp("{ 'execute': 'cpu-add',"
                       "  'arguments': { 'id': %d } }", i);
        g_assert(response);
        g_assert(!qdict_haskey(response, "error"));
        QDECREF(response);
    }

    qtest_end();
    g_free(args);
}
示例#25
0
static void test_end(void)
{
    qtest_end();
}
示例#26
0
static void test_device_intro_none(void)
{
    qtest_start(common_args);
    test_one_device("nonexistent");
    qtest_end();
}
示例#27
0
static void ich9_test(void)
{
    qtest_start("-machine q35 -device ich9-intel-hda,bus=pcie.0,addr=1b.0,id="
                HDA_ID CODEC_DEVICES);
    qtest_end();
}
示例#28
0
/* Tests only initialization so far. TODO: Replace with functional tests */
static void ich6_test(void)
{
    qtest_start("-device intel-hda,id=" HDA_ID CODEC_DEVICES);
    qtest_end();
}
示例#29
0
static void test_device_intro_abstract(void)
{
    qtest_start(common_args);
    test_one_device("device");
    qtest_end();
}
示例#30
0
static void test_end(TestData *d)
{
    g_free(d->dev);
    qpci_free_pc(d->bus);
    qtest_end();
}