4 * Copyright (c) 2018 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 requstorageed 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_STORAGE_GETSTORAGE "getstorage"
21 #define METHOD_STORAGE_GETSTATUS "GetStatus"
23 static bool request_storage_method(const char *method, GVariant *param)
26 unsigned long long val1, val2;
29 msg = dbus_handle_method_sync_with_reply_var(STORAGED_BUS_NAME,
30 STORAGED_PATH_STORAGE,
31 STORAGED_INTERFACE_STORAGE,
35 _E("fail (%s): no reply", method);
39 if (!dh_get_param_from_var(msg, "(tt)", &val1, &val2))
40 _E("fail (%s): no message", method);
43 _E("fail (%s): returned total storage (%d)", method, val1);
45 _I("success (%s): Total: %4.0llu Avail: %4.0llu", method, val1, val2);
54 static bool storage_getstorage()
56 _D("----------------------------------------------------------------------------------");
57 return request_storage_method(METHOD_STORAGE_GETSTORAGE, NULL);
60 static bool storage_getstatus(char *path)
62 _D("----------------------------------------------------------------------------------");
63 return request_storage_method(METHOD_STORAGE_GETSTATUS, g_variant_new("(s)", path));
66 void storage_test_all(int *success, int *fail)
71 (storage_getstorage()) ? s++ : f++;
72 (storage_getstatus("/opt/usr/home")) ? s++ : f++;
73 _D("----------------------------------------------------------------------------------");
75 if (NULL != success) *success = s;
76 if (NULL != fail) *fail = f;
79 static void storage_init(void *data)
86 storage_test_all(&success, &fail);
88 _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
91 static void storage_exit(void *data)
96 static int storage_unit(int argc, char **argv)
103 storage_test_all(&success, &fail);
104 _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
105 } else if (0 == strcasecmp(argv[2], METHOD_STORAGE_GETSTORAGE)) {
106 storage_getstorage();
107 } else if (0 == strcasecmp(argv[2], METHOD_STORAGE_GETSTATUS)) {
108 storage_getstatus(argv[3]);
110 _E("Unknown test case!!!");
112 _D("----------------------------------------------------------------------------------");
117 static const struct test_ops storage_test_ops = {
118 .priority = TEST_PRIORITY_NORMAL,
120 .init = storage_init,
121 .exit = storage_exit,
122 .unit = storage_unit,
125 TEST_OPS_REGISTER(&storage_test_ops)