summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunmi Ha <yunmi.ha@samsung.com>2017-06-28 15:44:48 +0900
committerYunmi Ha <yunmi.ha@samsung.com>2017-06-28 15:44:48 +0900
commit7bd49ee3e0316bda4c83fd0b19c9c337c996fd56 (patch)
tree750f35a4a783ad3f1908c97d6fa09794787079bb
parent8ebf7375c084ba13050f2faea0180a850462faca (diff)
downloaddeviced-7bd49ee3e0316bda4c83fd0b19c9c337c996fd56.tar.gz
deviced-7bd49ee3e0316bda4c83fd0b19c9c337c996fd56.tar.bz2
deviced-7bd49ee3e0316bda4c83fd0b19c9c337c996fd56.zip
auto-test: support proc dbus test
Change-Id: I79a4108db5353b14cec7565d7b8724c5045b9aff Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
-rw-r--r--src/auto-test/CMakeLists.txt1
-rw-r--r--src/auto-test/auto-test.conf5
-rwxr-xr-xsrc/auto-test/proc.c129
3 files changed, 135 insertions, 0 deletions
diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt
index 99b2e5a4..da6da428 100644
--- a/src/auto-test/CMakeLists.txt
+++ b/src/auto-test/CMakeLists.txt
@@ -26,6 +26,7 @@ SET(SRCS
display.c
led.c
power.c
+ proc.c
)
# extcon test
diff --git a/src/auto-test/auto-test.conf b/src/auto-test/auto-test.conf
index 00213a04..2e3dde8b 100644
--- a/src/auto-test/auto-test.conf
+++ b/src/auto-test/auto-test.conf
@@ -3,27 +3,32 @@ battery=1
display=1
led=1
power=1
+proc=1
[wearable]
battery=1
display=1
led=0
power=1
+proc=1
[tv]
battery=0
display=1
led=0
power=1
+proc=1
[ivi]
battery=0
display=1
led=0
power=1
+proc=1
[common]
battery=0
display=1
led=0
power=1
+proc=1
diff --git a/src/auto-test/proc.c b/src/auto-test/proc.c
new file mode 100755
index 00000000..8668c1ad
--- /dev/null
+++ b/src/auto-test/proc.c
@@ -0,0 +1,129 @@
+/*
+ * 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_PROC_OOMADJ_SET "oomadj_set"
+
+static bool set_proc_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_PROCESS,
+ DEVICED_INTERFACE_PROCESS,
+ 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_proc_oomadj(char *type, int argc, int pid, int score_adj)
+{
+ char *param[4];
+ char str_argc[10];
+ char str_pid[10];
+ char str_score_adj[10];
+
+ snprintf(str_argc, sizeof(str_argc), "%d", argc);
+ snprintf(str_pid, sizeof(str_pid), "%d", pid);
+ snprintf(str_score_adj, sizeof(str_score_adj), "%d", score_adj);
+
+ param[0] = type;
+ param[1] = str_argc;
+ param[2] = str_pid;
+ param[3] = str_score_adj;
+
+ return set_proc_method(METHOD_PROC_OOMADJ_SET, "siss", param);
+}
+
+void proc_test_all(int *success, int *fail)
+{
+ int s = 0;
+ int f = 0;
+
+ (set_proc_oomadj("oomadj_set", 2, getpid(), 300)) ? s++ : f++;
+ (set_proc_oomadj("oomadj_set", 2, getpid(), 100)) ? s++ : f++;
+
+ if (NULL != success) *success = s;
+ if (NULL != fail) *fail = f;
+}
+
+static void proc_init(void *data)
+{
+ int success = 0;
+ int fail = 0;
+
+ _I("start test");
+
+ proc_test_all(&success, &fail);
+
+ _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
+}
+
+static void proc_exit(void *data)
+{
+ _I("end test");
+}
+
+static int proc_unit(int argc, char **argv)
+{
+ if (argc < 4) {
+ int success = 0;
+ int fail = 0;
+
+ _I("start test");
+ proc_test_all(&success, &fail);
+ _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 {
+ _E("Unknown test case!!!");
+ }
+
+ return 0;
+}
+
+static const struct test_ops proc_test_ops = {
+ .priority = TEST_PRIORITY_NORMAL,
+ .name = "proc",
+ .init = proc_init,
+ .exit = proc_exit,
+ .unit = proc_unit,
+};
+
+TEST_OPS_REGISTER(&proc_test_ops)