4 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 static const struct device_change_type {
23 } device_change_types[] = {
28 static int udev(int index)
31 int ret = 0, val = 0, err;
33 err = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME,
35 DEVICED_INTERFACE_SYSNOTI,
37 g_variant_new("(sis)", "udev", 1, device_change_types[index].status),
40 _E("fail : %s %s %s %s",
41 DEVICED_BUS_NAME, DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI,
46 if (!g_variant_get_safe(msg, "(i)", &val))
47 _E("fail : no message");
49 if ((val == -ENOTSUP) || (val == -ENOSYS)) {
50 _I("Not supported feature! : %d", val);
53 _E("fail : returned fail (%d)", val);
55 _I("success : %d", val);
60 _I("%s", device_change_types[index].status);
62 _R("[NG] ---- %s : %s",
63 __func__, device_change_types[index].status);
65 _R("[OK] ---- %s : %s",
66 __func__, device_change_types[index].status);
69 sleep(TEST_WAIT_TIME_INTERVAL);
73 static void unit(char *unit, char *status)
82 unit_len = strlen(unit);
83 status_len = strlen(status);
85 for (index = 0; index < ARRAY_SIZE(device_change_types); index++) {
86 if (unit_len != strlen(device_change_types[index].name) ||
87 status_len != strlen(device_change_types[index].status))
89 if (strncmp(unit, device_change_types[index].name, unit_len) != 0 ||
90 strncmp(status, device_change_types[index].status, status_len) != 0)
96 static void udev_init(void *data)
101 for (index = 0; index < ARRAY_SIZE(device_change_types); index++)
105 static void udev_exit(void *data)
110 static int udev_unit(int argc, char **argv)
115 unit(argv[2], argv[3]);
119 static const struct test_ops udev_test_ops = {
120 .priority = TEST_PRIORITY_HIGH,
127 TEST_OPS_REGISTER(&udev_test_ops)