Add default testcases for testing the public API's availability
[platform/core/api/context.git] / testsuite / src / main.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "shared.h"
18 #include "default/DefaultTest.h"
19 #include "app-history/history.h"
20 #include "job-scheduler/JobSchedulerTest.h"
21
22 using namespace test;
23
24 static void __signal_handler(int signo)
25 {
26         if (signo == SIGINT && is_mainloop_running()) {
27                 g_print(PURPLE("\nskipping the testcase..."));
28                 stop_mainloop();
29         } else {
30                 g_print(PURPLE("\nterminating... (SIGNAL %d)\n"), signo);
31                 exit(EXIT_SUCCESS);
32         }
33 }
34
35 static void __print_usage()
36 {
37         g_print("Usage: context-test TESTSUITE\n\n");
38         g_print("TESTSUITE can be one of the followings:\n");
39         g_print("  a\t to test app-history\n");
40         g_print("  j\t to test job-scheduler\n");
41 }
42
43 int main(int argc, char** argv)
44 {
45         signal(SIGINT,  __signal_handler);
46         signal(SIGHUP,  __signal_handler);
47         signal(SIGTERM, __signal_handler);
48         signal(SIGQUIT, __signal_handler);
49
50         test_default(&argc, &argv);
51         g_print("\n");
52
53         if (argc < 2) {
54                 __print_usage();
55                 return EXIT_SUCCESS;
56         }
57
58         switch (argv[1][0]) {
59         case 'a':
60                 return test_app_history(&argc, &argv);
61         case 'j':
62                 return test_job_scheduler(&argc, &argv);
63         default:
64                 __print_usage();
65                 return EXIT_SUCCESS;
66         }
67 }