blob: 487e96c494df1fd0ad952fae18bbc3eb057b500a [file] [log] [blame]
Chris Manton25cc8282020-02-18 07:56:15 -08001/*
2 * Copyright 2020 The Android Open Source Project
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#define LOG_TAG "bt_headless"
18
19#include <unordered_map>
20
21#include "base/logging.h" // LOG() stdout and android log
22#include "osi/include/log.h" // android log only
23#include "test/headless/get_options.h"
24#include "test/headless/headless.h"
25#include "test/headless/nop/nop.h"
26#include "test/headless/pairing/pairing.h"
27#include "test/headless/read/read.h"
28#include "test/headless/sdp/sdp.h"
29
30using namespace bluetooth::test::headless;
31
32namespace {
33
34class Main : public HeadlessTest<int> {
35 public:
36 Main(const bluetooth::test::headless::GetOpt& options)
37 : HeadlessTest<int>(options) {
38 test_nodes_.emplace(
39 "nop", std::make_unique<bluetooth::test::headless::Nop>(options));
40 test_nodes_.emplace(
41 "pairing",
42 std::make_unique<bluetooth::test::headless::Pairing>(options));
43 test_nodes_.emplace(
44 "read", std::make_unique<bluetooth::test::headless::Read>(options));
45 test_nodes_.emplace(
46 "sdp", std::make_unique<bluetooth::test::headless::Sdp>(options));
47 }
48
49 int Run() override {
50 if (options_.close_stderr_) {
51 fclose(stderr);
52 }
53 return HeadlessTest<int>::Run();
54 }
55};
56
57} // namespace
58
59int main(int argc, char** argv) {
60 fflush(nullptr);
61 setvbuf(stdout, nullptr, _IOLBF, 0);
62
63 bluetooth::test::headless::GetOpt options(argc, argv);
64 if (!options.IsValid()) {
65 return -1;
66 }
67
68 Main main(options);
69 return main.Run();
70}