proc.c
extcon.c
ir.c
+ time.c
)
# extcon test
proc=1
extcon=1
ir=1
+time=1
[wearable]
battery=1
proc=1
extcon=1
ir=0
+time=1
[tv]
battery=0
proc=1
extcon=1
ir=0
+time=1
[ivi]
battery=0
proc=1
extcon=1
ir=0
+time=1
[common]
battery=0
proc=1
extcon=1
ir=0
+time=1
#define METHOD_EXTCON_ENABLE "enable"
#define METHOD_EXTCON_DISABLE "disable"
+#define METHOD_SYSNOTI_GETCRADLE "GetCradle"
+#define METHOD_SYSNOTI_GETHDMI "GetHDMI"
+
static bool request_extcon_method(const char *method, char *sig, char *param[])
{
DBusMessage *msg;
return ret;
}
+static bool get_sysnoti_method(const char *method)
+{
+ DBusMessage *msg;
+ int val;
+ bool ret = FALSE;
+
+ msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
+ DEVICED_PATH_SYSNOTI,
+ DEVICED_INTERFACE_SYSNOTI,
+ method, NULL, NULL);
+ if (!msg) {
+ _E("fail (%s): no reply", method);
+ return ret;
+ }
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0)
+ _E("fail (%s): no message", method);
+ else {
+ if ((val == -ENOTSUP) || (val == -ENOSYS)) {
+ _I("Not supported feature! (%s): %d", method, val);
+ ret = TRUE;
+ } else if ((val == -EINVAL) || (val == -ENOENT)) {
+ _E("fail : returned fail (%d)", val);
+ } else {
+ _I("success (%s): %d", method, val);
+ ret = TRUE;
+ }
+ }
+
+ dbus_message_unref(msg);
+ return ret;
+}
+
static bool get_extcon_status(char *device_name)
{
DBusMessage *msg;
return request_extcon_method(METHOD_EXTCON_DISABLE, "s", param);
}
+static bool get_sysnoti_cradle()
+{
+ return get_sysnoti_method(METHOD_SYSNOTI_GETCRADLE);
+}
+
+static bool get_sysnoti_hdmi()
+{
+ return get_sysnoti_method(METHOD_SYSNOTI_GETHDMI);
+}
void extcon_test_all(int *success, int *fail)
{
(get_extcon_status("Headphone")) ? s++ : f++;
(set_extcon_disable("Headphone")) ? s++ : f++;
+ (get_sysnoti_cradle()) ? s++ : f++;
+ (get_sysnoti_hdmi()) ? s++ : f++;
+
if (NULL != success) *success = s;
if (NULL != fail) *fail = f;
}
set_extcon_enable(argv[4]);
} else if (0 == strcasecmp(argv[3], METHOD_EXTCON_DISABLE)) {
set_extcon_disable(argv[4]);
+ } else if (0 == strcasecmp(argv[3], METHOD_SYSNOTI_GETCRADLE)) {
+ get_sysnoti_cradle();
+ } else if (0 == strcasecmp(argv[3], METHOD_SYSNOTI_GETHDMI)) {
+ get_sysnoti_hdmi();
} else {
_E("Unknown test case!!!");
}
*/
#include "test.h"
-#define METHOD_PROC_OOMADJ_SET "oomadj_set"
+#define METHOD_PROC_OOMADJ_SET "oomadj_set"
+
+#define METHOD_SYSNOTI_GETREVISION "GetRevision"
+
static bool set_proc_method(const char *method, char *sig, char *param[])
{
return set_proc_method(METHOD_PROC_OOMADJ_SET, "siss", param);
}
+static bool get_sysnoti_revision()
+{
+ DBusMessage *msg;
+ int val;
+ bool ret = FALSE;
+
+ msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
+ DEVICED_PATH_SYSNOTI,
+ DEVICED_INTERFACE_SYSNOTI,
+ METHOD_SYSNOTI_GETREVISION, NULL, NULL);
+ if (!msg) {
+ _E("fail : no reply");
+ return ret;
+ }
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0)
+ _E("fail : no message");
+ else {
+ if ((val == -ENOTSUP) || (val == -ENOSYS)) {
+ _I("Not supported feature! : %d", val);
+ ret = TRUE;
+ } else if (val < 0) {
+ _E("fail : returned fail (%d)", val);
+ } else {
+ _I("success : %d", val);
+ ret = TRUE;
+ }
+ }
+
+ dbus_message_unref(msg);
+ return ret;
+}
+
void proc_test_all(int *success, int *fail)
{
int s = 0;
(set_proc_oomadj("oomadj_set", 2, getpid(), 300)) ? s++ : f++;
(set_proc_oomadj("oomadj_set", 2, getpid(), 100)) ? s++ : f++;
+ (get_sysnoti_revision()) ? s++ : f++;
+
if (NULL != success) *success = s;
if (NULL != fail) *fail = f;
}
_I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
} else if (0 == strcmp(argv[3], METHOD_PROC_OOMADJ_SET)) {
set_proc_oomadj(argv[4], atoi(argv[5]), atoi(argv[6]), atoi(argv[7]));
+ } else if (0 == strcmp(argv[3], METHOD_SYSNOTI_GETREVISION)) {
+ get_sysnoti_revision();
} else {
_E("Unknown test case!!!");
}
--- /dev/null
+/*
+ * test
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "test.h"
+
+#define METHOD_TIME_SET_DATETIME "set_datetime"
+#define METHOD_TIME_SET_TIMEZONE "set_timezone"
+
+static bool request_sysnoti_method(const char *method, char *sig, char *param[])
+{
+ DBusMessage *msg;
+ int val;
+ bool ret = FALSE;
+
+ msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
+ DEVICED_PATH_SYSNOTI,
+ DEVICED_INTERFACE_SYSNOTI,
+ method, sig, param);
+ if (!msg) {
+ _E("fail (%s): no reply", method);
+ return ret;
+ }
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0)
+ _E("fail (%s): no message", method);
+ else {
+ if ((val == -ENOTSUP) || (val == -ENOSYS)) {
+ _I("Not supported feature! (%s): %d", method, val);
+ ret = TRUE;
+ } else if (val < 0) {
+ _E("fail (%s): returned fail (%d)", method, val);
+ } else {
+ _I("success (%s): %d", method, val);
+ ret = TRUE;
+ }
+ }
+
+ dbus_message_unref(msg);
+ return ret;
+}
+
+static bool set_time_datetime(int date_time)
+{
+ char *param[3];
+ char str_type[20];
+ char str_argc[10];
+ char str_time[10];
+
+ snprintf(str_type, sizeof(str_type), "%s", METHOD_TIME_SET_DATETIME);
+ snprintf(str_argc, sizeof(str_argc), "%d", 1);
+ snprintf(str_time, sizeof(str_time), "%d", date_time);
+
+ param[0] = str_type;
+ param[1] = str_argc;
+ param[2] = str_time;
+
+ return request_sysnoti_method(METHOD_TIME_SET_DATETIME, "sis", param);
+}
+
+static bool set_time_timezone(char *localtime_path)
+{
+ char *param[3];
+ char str_type[20];
+ char str_argc[10];
+
+ snprintf(str_type, sizeof(str_type), "%s", METHOD_TIME_SET_TIMEZONE);
+ snprintf(str_argc, sizeof(str_argc), "%d", 1);
+
+ param[0] = str_type;
+ param[1] = str_argc;
+ param[2] = localtime_path;
+
+ return request_sysnoti_method(METHOD_TIME_SET_TIMEZONE, "sis", param);
+}
+
+void time_test_all(int *success, int *fail)
+{
+ int s = 0;
+ int f = 0;
+
+ (set_time_datetime(time(NULL)-600)) ? s++ : f++;
+ (set_time_datetime(time(NULL))) ? s++ : f++;
+ (set_time_timezone("/usr/share/zoneinfo/America/Cancun")) ? s++ : f++;
+ (set_time_timezone("/usr/share/zoneinfo/Asia/Seoul")) ? s++ : f++;
+
+ if (NULL != success) *success = s;
+ if (NULL != fail) *fail = f;
+}
+
+static void time_init(void *data)
+{
+ int success = 0;
+ int fail = 0;
+
+ _I("start test");
+
+ time_test_all(&success, &fail);
+
+ _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
+}
+
+static void time_exit(void *data)
+{
+ _I("end test");
+}
+
+static int time_unit(int argc, char **argv)
+{
+ if (argc < 4) {
+ int success = 0;
+ int fail = 0;
+
+ _I("start test");
+ time_test_all(&success, &fail);
+ _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
+ } else if (0 == strcasecmp(argv[3], METHOD_TIME_SET_DATETIME)) {
+ set_time_datetime(atoi(argv[4]));
+ } else if (0 == strcasecmp(argv[3], METHOD_TIME_SET_TIMEZONE)) {
+ set_time_timezone(argv[4]);
+ } else {
+ _E("Unknown test case!!!");
+ }
+
+ return 0;
+}
+
+static const struct test_ops time_test_ops = {
+ .priority = TEST_PRIORITY_NORMAL,
+ .name = "time",
+ .init = time_init,
+ .exit = time_exit,
+ .unit = time_unit,
+};
+
+TEST_OPS_REGISTER(&time_test_ops)