tizen 2.3 release
[framework/system/deviced.git] / src / auto-test / board-info.c
1 /*
2  * test
3  *
4  * Copyright (c) 2013 Samsung Electronics Co., Ltd.
5  *
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
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  */
18
19 #include "test.h"
20
21 #define METHOD_GET_NUM  "GetNum"
22 #define METHOD_GET_SERIAL       "GetSerial"
23 #define METHOD_GET_REVISION     "GetHWRev"
24
25 void board_serial(void)
26 {
27         DBusError err;
28         DBusMessage *msg;
29         int ret, val;
30         char *data;
31
32         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, DEVICED_PATH_BOARD,
33                 DEVICED_INTERFACE_BOARD, METHOD_GET_SERIAL, NULL, NULL);
34         if (!msg) {
35                 _E("fail send message");
36                 return;
37         }
38
39         dbus_error_init(&err);
40
41         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &data, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
42         if (!ret) {
43                 _E("no message : [%s:%s]", err.name, err.message);
44                 return;
45         }
46         dbus_message_unref(msg);
47         dbus_error_free(&err);
48
49         _D("%s %d", data, val);
50         if (val < 0)
51                 _R("[NG] ---- %s     : V(if your target is eng, NG is Normal)",
52                 __func__);
53         else
54                 _R("[OK] ---- %s     : V(%s)", __func__, data);
55 }
56
57 static void board_revision(void)
58 {
59         DBusError err;
60         DBusMessage *msg;
61         int ret, val;
62
63         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, DEVICED_PATH_BOARD,
64                 DEVICED_INTERFACE_BOARD, METHOD_GET_REVISION, NULL, NULL);
65         if (!msg) {
66                 _E("fail send message");
67                 return;
68         }
69         dbus_error_init(&err);
70
71         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
72
73         if (!ret) {
74                 _E("no message : [%s:%s]", err.name, err.message);
75                 return;
76         }
77         dbus_message_unref(msg);
78         dbus_error_free(&err);
79         _E("%s-%s : %d", DEVICED_INTERFACE_BOARD, METHOD_GET_REVISION, val);
80         if(val >= 8) {
81                 _D("Rinato Neo");
82         } else {
83                 _D("Rinato");
84         }
85         if (val < 0)
86                 _R("[NG] ---- %s", __func__);
87         else
88                 _R("[OK] ---- %s   : V(%d)", __func__, val);
89 }
90
91 void board_numer(void)
92 {
93         DBusError err;
94         DBusMessage *msg;
95         int ret, val;
96         char *data;
97
98         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, DEVICED_PATH_BOARD,
99                 DEVICED_INTERFACE_BOARD, METHOD_GET_NUM, NULL, NULL);
100         if (!msg) {
101                 _E("fail send message");
102                 return;
103         }
104
105         dbus_error_init(&err);
106
107         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &data, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
108         if (!ret) {
109                 _E("no message : [%s:%s]", err.name, err.message);
110                 return;
111         }
112         dbus_message_unref(msg);
113         dbus_error_free(&err);
114
115         _D("%s %d", data, val);
116         if (val < 0)
117                 _R("[NG] ---- %s      : V(if your target is eng, NG is Normal)",
118                 __func__);
119         else
120                 _R("[OK] ---- %s      : V(%s)", __func__, data);
121 }
122
123 static void board_init(void *data)
124 {
125         _I("start test");
126         board_revision();
127         board_serial();
128         board_numer();
129 }
130
131 static void board_exit(void *data)
132 {
133         _I("end test");
134 }
135
136 static int board_unit(int argc, char **argv)
137 {
138         board_revision();
139         board_serial();
140         board_numer();
141         return 0;
142 }
143
144 static const struct test_ops board_test_ops = {
145         .priority = TEST_PRIORITY_NORMAL,
146         .name     = "board",
147         .init     = board_init,
148         .exit    = board_exit,
149         .unit    = board_unit,
150 };
151
152 TEST_OPS_REGISTER(&board_test_ops)