sensorctl: seperate auto test and manual test
[platform/core/system/sensord.git] / src / sensorctl / tester_auto.cpp
1 /*
2  * sensorctl
3  *
4  * Copyright (c) 2017 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
20 #include "log.h"
21 #include "tester.h"
22 #include "test_bench.h"
23
24 #define TEST_AUTO "auto"
25
26 class tester_auto : public tester {
27 public:
28         tester_auto(const char *name);
29         virtual ~tester_auto();
30
31         bool setup(sensor_type_t type, int argc, char *argv[]);
32         bool teardown(void);
33
34         bool run(int argc, char *argv[]);
35         void usage(void);
36 };
37
38 tester_auto::tester_auto(const char *name)
39 : tester(name)
40 {
41 }
42
43 tester_auto::~tester_auto()
44 {
45 }
46
47 bool tester_auto::setup(sensor_type_t type, int argc, char *argv[])
48 {
49         test_option::filter = "(?!manual|skip)[\\w\\.]+";
50
51         if (!test_option::set_options(argc, argv)) {
52                 usage();
53                 return false;
54         }
55
56         return true;
57 }
58
59 bool tester_auto::teardown(void)
60 {
61         return true;
62 }
63
64 bool tester_auto::run(int argc, char *argv[])
65 {
66         test_bench::run_all_testcases();
67         return true;
68 }
69
70 void tester_auto::usage(void)
71 {
72         _N("Usage : sensorctl test auto [--help] [--list] [--filter=<regex>]\n");
73         _N("                            [--verbose] [--shuffle] [--repeat]\n");
74         _N("                            [--output]\n");
75
76         _N("Examples:\n");
77         _N("  sensorctl test auto --list\n");
78         _N("  sensorctl test auto --filter=accelerometer.interval*\n");
79         _N("  sensorctl test auto --filter=accelerometer.start\n");
80         _N("  sensorctl test auto --filter=accelerometer.verify\n");
81         _N("  sensorctl test auto --filter=ipc.socket*\n");
82         _N("  sensorctl test auto --shuffle\n");
83         _N("  sensorctl test auto --verbose\n");
84         _N("  sensorctl test auto --output=results.log\n");
85 }
86
87 REGISTER_TESTER(TEST_AUTO, tester_auto);