4 * Copyright (c) 2017 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 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.
25 #include <sensor_internal.h>
31 std::vector<tester *> tester_manager::testers;
33 tester::tester(const char *name)
36 tester_manager::register_tester(this);
39 tester_manager::tester_manager()
43 tester_manager::~tester_manager()
47 void tester_manager::register_tester(tester *test)
49 testers.push_back(test);
52 bool tester_manager::run(int argc, char *argv[])
55 sensor_type_t type = ACCELEROMETER_SENSOR;
57 if (argc < TESTER_ARGC) {
62 if (strncmp(argv[2], "auto", 4) != 0)
63 type = get_sensor_type(argv[2]);
65 tester *_tester = get_tester(argv[2]);
66 RETVM_IF(!_tester, false, "Cannot find matched tester\n");
68 ret = _tester->setup(type, argc, argv);
69 RETVM_IF(!ret, false, "Failed to setup injector\n");
71 ret = _tester->run(argc, argv);
72 RETVM_IF(!ret, false, "Failed to run tester\n");
74 ret = _tester->teardown();
75 RETVM_IF(!ret, false, "Failed to tear down tester\n");
80 tester *tester_manager::get_tester(const char *name)
82 int count = testers.size();
84 for (int i = 0; i < count; ++i) {
85 if (strncmp(name, "auto", 4) == 0) {
86 if (testers[i]->name() == "auto")
89 if (testers[i]->name() == "manual")
96 void tester_manager::stop(void)
98 if (mainloop::is_running())
102 void tester_manager::usage(void)
104 _N("usage: sensorctl test auto [options] [--help]\n");
105 _N("usage: sensorctl test <sensor_type> [--help]\n");
110 _N(" Run all testcases automatically.\n");
111 _N("sensor_type:\n");
112 _N(" Run the specific sensor manually.\n");
114 _N(" Prints the synopsis and a list of options.\n");