auto-test: add uevent control before/after the battery test 98/270998/2 submit/tizen/20220222.024249
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 14 Feb 2022 04:02:59 +0000 (13:02 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 14 Feb 2022 04:29:56 +0000 (13:29 +0900)
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 <y0.cho@samsung.com>
tests/auto-test/battery.c

index d65c5bb..14b3964 100644 (file)
@@ -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;
 }