Initialize Tizen 2.3
[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_SERIAL       "GetSerial"
22 #define METHOD_GET_REVISION     "GetHWRev"
23
24 void get_serial(void)
25 {
26         DBusError err;
27         DBusMessage *msg;
28         int ret, val;
29         char *data;
30
31         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, DEVICED_PATH_BOARD,
32                 DEVICED_INTERFACE_BOARD, METHOD_GET_SERIAL, NULL, NULL);
33         if (!msg) {
34                 _E("fail send message");
35                 return;
36         }
37
38         dbus_error_init(&err);
39
40         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &data, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
41         if (!ret) {
42                 _E("no message : [%s:%s]", err.name, err.message);
43                 return;
44         }
45         dbus_message_unref(msg);
46         dbus_error_free(&err);
47
48         _D("%s %d", data, val);
49 }
50
51 static void get_revision(void)
52 {
53         DBusError err;
54         DBusMessage *msg;
55         int ret, val;
56
57         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, DEVICED_PATH_BOARD,
58                 DEVICED_INTERFACE_BOARD, METHOD_GET_REVISION, NULL, NULL);
59         if (!msg) {
60                 _E("fail send message");
61                 return;
62         }
63         dbus_error_init(&err);
64
65         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
66
67         if (!ret) {
68                 _E("no message : [%s:%s]", err.name, err.message);
69                 return;
70         }
71         dbus_message_unref(msg);
72         dbus_error_free(&err);
73         _E("%s-%s : %d", DEVICED_INTERFACE_BOARD, METHOD_GET_REVISION, val);
74         if(val >= 8) {
75                 _D("Rinato Neo");
76         } else {
77                 _D("Rinato");
78         }
79 }
80
81 static void board_init(void *data)
82 {
83         _I("start test");
84         get_revision();
85         get_serial();
86 }
87
88 static void board_exit(void *data)
89 {
90         _I("end test");
91 }
92
93 static int board_unit(int argc, char **argv)
94 {
95         get_revision();
96         get_serial();
97         return 0;
98 }
99
100 static const struct test_ops board_test_ops = {
101         .priority = TEST_PRIORITY_NORMAL,
102         .name     = "board",
103         .init     = board_init,
104         .exit    = board_exit,
105         .unit    = board_unit,
106 };
107
108 TEST_OPS_REGISTER(&board_test_ops)