1 /* 2 * QTest testcase for the Aspeed GPIO Controller. 3 * 4 * Copyright (c) Meta Platforms, Inc. and affiliates. (http://www.meta.com) 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 #include "qemu/osdep.h" 26 #include "qemu/bitops.h" 27 #include "qemu/timer.h" 28 #include "qapi/qmp/qdict.h" 29 #include "libqtest-single.h" 30 31 static void test_set_colocated_pins(const void *data) 32 { 33 QTestState *s = (QTestState *)data; 34 35 /* 36 * gpioV4-7 occupy bits within a single 32-bit value, so we want to make 37 * sure that modifying one doesn't affect the other. 38 */ 39 qtest_qom_set_bool(s, "/machine/soc/gpio", "gpioV4", true); 40 qtest_qom_set_bool(s, "/machine/soc/gpio", "gpioV5", false); 41 qtest_qom_set_bool(s, "/machine/soc/gpio", "gpioV6", true); 42 qtest_qom_set_bool(s, "/machine/soc/gpio", "gpioV7", false); 43 g_assert(qtest_qom_get_bool(s, "/machine/soc/gpio", "gpioV4")); 44 g_assert(!qtest_qom_get_bool(s, "/machine/soc/gpio", "gpioV5")); 45 g_assert(qtest_qom_get_bool(s, "/machine/soc/gpio", "gpioV6")); 46 g_assert(!qtest_qom_get_bool(s, "/machine/soc/gpio", "gpioV7")); 47 } 48 49 int main(int argc, char **argv) 50 { 51 QTestState *s; 52 int r; 53 54 g_test_init(&argc, &argv, NULL); 55 56 s = qtest_init("-machine ast2600-evb"); 57 qtest_add_data_func("/ast2600/gpio/set_colocated_pins", s, 58 test_set_colocated_pins); 59 r = g_test_run(); 60 qtest_quit(s); 61 62 return r; 63 } 64