From: Youngjae Cho Date: Mon, 14 Feb 2022 04:02:59 +0000 (+0900) Subject: auto-test: add uevent control before/after the battery test X-Git-Tag: submit/tizen/20220222.024249^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=747765693d3ffd4fe513c8c2a2f9d2dba61e5059;p=platform%2Fcore%2Fsystem%2Fdeviced.git auto-test: add uevent control before/after the battery test During battery test, uevent must be ignored as test-driver generates pseudo-uevent and a real-uevent might corrupt it. Change-Id: Idf44757c00e2f2fadda75d87cec3a2982ee0871e Signed-off-by: Youngjae Cho --- diff --git a/tests/auto-test/battery.c b/tests/auto-test/battery.c index d65c5bb..14b3964 100644 --- a/tests/auto-test/battery.c +++ b/tests/auto-test/battery.c @@ -933,22 +933,59 @@ void battery_test_all(int *success, int *fail) if (NULL != fail) *fail = f; } +/* 0: disable udev + * 1: enable udev */ +static void control_udev(int val) +{ + static const char *ctl[] = { "stop", "start" }; + int retdbus; + int retval; + GVariant *reply; + + const char *control = ctl[(!!val)]; + + retdbus = gdbus_call_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + "udev", + g_variant_new("(sis)", "udev", 1, control), + &reply); + + if (retdbus < 0) { + _D("Failed to %s udev", control); + return; + } + + if (!g_variant_get_safe(reply, "(i)", &retval)) { + _D("Failed to get reply gvariant"); + return; + } + + if (retval != 0) { + _D("Failed to %s udev, %d", control, retval); + return; + } + + _D("udev: %s", control); +} + static void battery_init(void *data) { int success = 0; int fail = 0; + control_udev(0); _I("Start test."); battery_test_all(&success, &fail); _I("Total=%d Success=%d Fail=%d", success+fail, success, fail); + control_udev(1); } static void battery_exit(void *data) { _I("End test."); - } static int battery_unit(int argc, char **argv) @@ -957,6 +994,8 @@ static int battery_unit(int argc, char **argv) char *power_source = NULL; struct device_battery_info info; + control_udev(0); + if (argc < 4) { int success = 0; int fail = 0; @@ -1008,6 +1047,8 @@ static int battery_unit(int argc, char **argv) _E("Unknown test case."); } + control_udev(1); + return 0; }