target/mips: Move MUL opcode check from decode_mxu() to decode_legacy()
[qemu/ar7.git] / tests / qtest / fuzz-test.c
blob6f161c93be713431f47f165ebcfb0e3db13e5d07
1 /*
2 * QTest testcase for fuzz case
4 * Copyright (c) 2020 Li Qiang <liq3ea@gmail.com>
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
10 #include "qemu/osdep.h"
12 #include "libqos/libqtest.h"
15 * This used to trigger the assert in scsi_dma_complete
16 * https://bugs.launchpad.net/qemu/+bug/1878263
18 static void test_lp1878263_megasas_zero_iov_cnt(void)
20 QTestState *s;
22 s = qtest_init("-nographic -monitor none -serial none "
23 "-M q35 -device megasas -device scsi-cd,drive=null0 "
24 "-blockdev driver=null-co,read-zeroes=on,node-name=null0");
25 qtest_outl(s, 0xcf8, 0x80001818);
26 qtest_outl(s, 0xcfc, 0xc101);
27 qtest_outl(s, 0xcf8, 0x8000181c);
28 qtest_outl(s, 0xcf8, 0x80001804);
29 qtest_outw(s, 0xcfc, 0x7);
30 qtest_outl(s, 0xcf8, 0x8000186a);
31 qtest_writeb(s, 0x14, 0xfe);
32 qtest_writeb(s, 0x0, 0x02);
33 qtest_outb(s, 0xc1c0, 0x17);
34 qtest_quit(s);
37 static void test_lp1878642_pci_bus_get_irq_level_assert(void)
39 QTestState *s;
41 s = qtest_init("-M pc-q35-5.0 "
42 "-nographic -monitor none -serial none");
44 qtest_outl(s, 0xcf8, 0x8400f841);
45 qtest_outl(s, 0xcfc, 0xebed205d);
46 qtest_outl(s, 0x5d02, 0xebed205d);
47 qtest_quit(s);
51 * Here a MemoryRegionCache pointed to an MMIO region but had a
52 * larger size than the underlying region.
54 static void test_mmio_oob_from_memory_region_cache(void)
56 QTestState *s;
58 s = qtest_init("-M pc-q35-5.2 -display none -m 512M "
59 "-device virtio-scsi,num_queues=8,addr=03.0 ");
61 qtest_outl(s, 0xcf8, 0x80001811);
62 qtest_outb(s, 0xcfc, 0x6e);
63 qtest_outl(s, 0xcf8, 0x80001824);
64 qtest_outl(s, 0xcf8, 0x80001813);
65 qtest_outl(s, 0xcfc, 0xa080000);
66 qtest_outl(s, 0xcf8, 0x80001802);
67 qtest_outl(s, 0xcfc, 0x5a175a63);
68 qtest_outb(s, 0x6e08, 0x9e);
69 qtest_writeb(s, 0x9f003, 0xff);
70 qtest_writeb(s, 0x9f004, 0x01);
71 qtest_writeb(s, 0x9e012, 0x0e);
72 qtest_writeb(s, 0x9e01b, 0x0e);
73 qtest_writeb(s, 0x9f006, 0x01);
74 qtest_writeb(s, 0x9f008, 0x01);
75 qtest_writeb(s, 0x9f00a, 0x01);
76 qtest_writeb(s, 0x9f00c, 0x01);
77 qtest_writeb(s, 0x9f00e, 0x01);
78 qtest_writeb(s, 0x9f010, 0x01);
79 qtest_writeb(s, 0x9f012, 0x01);
80 qtest_writeb(s, 0x9f014, 0x01);
81 qtest_writeb(s, 0x9f016, 0x01);
82 qtest_writeb(s, 0x9f018, 0x01);
83 qtest_writeb(s, 0x9f01a, 0x01);
84 qtest_writeb(s, 0x9f01c, 0x01);
85 qtest_writeb(s, 0x9f01e, 0x01);
86 qtest_writeb(s, 0x9f020, 0x01);
87 qtest_writeb(s, 0x9f022, 0x01);
88 qtest_writeb(s, 0x9f024, 0x01);
89 qtest_writeb(s, 0x9f026, 0x01);
90 qtest_writeb(s, 0x9f028, 0x01);
91 qtest_writeb(s, 0x9f02a, 0x01);
92 qtest_writeb(s, 0x9f02c, 0x01);
93 qtest_writeb(s, 0x9f02e, 0x01);
94 qtest_writeb(s, 0x9f030, 0x01);
95 qtest_outb(s, 0x6e10, 0x00);
96 qtest_quit(s);
99 int main(int argc, char **argv)
101 const char *arch = qtest_get_arch();
103 g_test_init(&argc, &argv, NULL);
105 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
106 qtest_add_func("fuzz/test_lp1878263_megasas_zero_iov_cnt",
107 test_lp1878263_megasas_zero_iov_cnt);
108 qtest_add_func("fuzz/test_lp1878642_pci_bus_get_irq_level_assert",
109 test_lp1878642_pci_bus_get_irq_level_assert);
110 qtest_add_func("fuzz/test_mmio_oob_from_memory_region_cache",
111 test_mmio_oob_from_memory_region_cache);
114 return g_test_run();