4 * Copyright (c) 2013 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 #define METHOD_GET_STORAGE "getstorage"
21 #define METHOD_MEM_TRIM "MemTrim"
23 static void mem_trim(void *data, DBusMessage *msg, DBusError *tmp)
31 dbus_error_init(&err);
32 ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
34 _E("no message [%s:%s]", err.name, err.message);
35 dbus_error_free(&err);
38 _D("succeed mem trim : %d", result);
41 static int request_mem_trim(void)
45 ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
46 DEVICED_PATH_STORAGE, DEVICED_INTERFACE_STORAGE,
47 METHOD_MEM_TRIM, NULL, NULL, mem_trim, -1, NULL);
49 _D("request mem trim");
53 static int storage(void)
61 msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
63 DEVICED_INTERFACE_STORAGE,
64 METHOD_GET_STORAGE, NULL, NULL);
66 _E("fail : %s %s %s %s",
67 DEVICED_BUS_NAME, DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI,
72 dbus_error_init(&err);
74 ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT64, &dTotal, DBUS_TYPE_INT64, &dAvail, DBUS_TYPE_INVALID);;
76 _E("no message : [%s:%s]", err.name, err.message);
78 _I("total : %4.4lf avail %4.4lf", dTotal, dAvail);
80 _R("[NG] ---- %s", __func__);
82 _R("[OK] ---- %s : T(%4.4lf) A(%4.4lf)",
83 __func__, dTotal, dAvail);
84 dbus_message_unref(msg);
85 dbus_error_free(&err);
86 sleep(TEST_WAIT_TIME_INTERVAL);
90 static void storage_init(void *data)
96 static void storage_exit(void *data)
101 static int storage_unit(int argc, char **argv)
105 if (strcmp(argv[2], "value") == 0)
107 else if (strcmp(argv[2], "signal") == 0) {
109 ecore_main_loop_begin();
114 static const struct test_ops storage_test_ops = {
115 .priority = TEST_PRIORITY_NORMAL,
117 .init = storage_init,
118 .exit = storage_exit,
119 .unit = storage_unit,
122 TEST_OPS_REGISTER(&storage_test_ops)