xref: /qemu/tests/qtest/virtio-balloon-test.c (revision 55fa4be6f76a3e1b1caa33a8f0ab4dc217d32e49)
1*55fa4be6SGao Shiyuan /*
2*55fa4be6SGao Shiyuan  * QTest fuzzer-generated testcase for virtio balloon device
3*55fa4be6SGao Shiyuan  *
4*55fa4be6SGao Shiyuan  * Copyright (c) 2024 Gao Shiyuan <gaoshiyuan@baidu.com>
5*55fa4be6SGao Shiyuan  *
6*55fa4be6SGao Shiyuan  * SPDX-License-Identifier: GPL-2.0-or-later
7*55fa4be6SGao Shiyuan  */
8*55fa4be6SGao Shiyuan 
9*55fa4be6SGao Shiyuan #include "qemu/osdep.h"
10*55fa4be6SGao Shiyuan #include "libqtest.h"
11*55fa4be6SGao Shiyuan 
12*55fa4be6SGao Shiyuan /*
13*55fa4be6SGao Shiyuan  * https://gitlab.com/qemu-project/qemu/-/issues/2576
14*55fa4be6SGao Shiyuan  * Used to trigger:
15*55fa4be6SGao Shiyuan  *   virtio_address_space_lookup: Assertion `mrs.mr' failed.
16*55fa4be6SGao Shiyuan  */
17*55fa4be6SGao Shiyuan static void oss_fuzz_71649(void)
18*55fa4be6SGao Shiyuan {
19*55fa4be6SGao Shiyuan     QTestState *s = qtest_init("-device virtio-balloon -machine q35"
20*55fa4be6SGao Shiyuan                                " -nodefaults");
21*55fa4be6SGao Shiyuan 
22*55fa4be6SGao Shiyuan     qtest_outl(s, 0xcf8, 0x80000890);
23*55fa4be6SGao Shiyuan     qtest_outl(s, 0xcfc, 0x2);
24*55fa4be6SGao Shiyuan     qtest_outl(s, 0xcf8, 0x80000891);
25*55fa4be6SGao Shiyuan     qtest_inl(s, 0xcfc);
26*55fa4be6SGao Shiyuan     qtest_quit(s);
27*55fa4be6SGao Shiyuan }
28*55fa4be6SGao Shiyuan 
29*55fa4be6SGao Shiyuan int main(int argc, char **argv)
30*55fa4be6SGao Shiyuan {
31*55fa4be6SGao Shiyuan     g_test_init(&argc, &argv, NULL);
32*55fa4be6SGao Shiyuan 
33*55fa4be6SGao Shiyuan     qtest_add_func("fuzz/virtio/oss_fuzz_71649", oss_fuzz_71649);
34*55fa4be6SGao Shiyuan 
35*55fa4be6SGao Shiyuan     return g_test_run();
36*55fa4be6SGao Shiyuan }
37*55fa4be6SGao Shiyuan 
38