• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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 #include "common/testing/log_capture.h"
18 
19 #include <errno.h>
20 #include <fcntl.h>
21 #include <sys/stat.h>
22 
23 #include <cstddef>
24 #include <sstream>
25 #include <string>
26 
27 #include "os/log.h"
28 
29 namespace bluetooth {
30 namespace testing {
31 
LogCapture()32 LogCapture::LogCapture() {
33   LOG_INFO(
34       "Log capture disabled for android build dup_fd:%d fd:%d original_stderr_fd:%d",
35       dup_fd_,
36       fd_,
37       original_stderr_fd_);
38 }
39 
~LogCapture()40 LogCapture::~LogCapture() {}
41 
Rewind()42 LogCapture* LogCapture::Rewind() {
43   return this;
44 }
45 
Find(std::string to_find)46 bool LogCapture::Find(std::string to_find) {
47   // For |atest| assume all log captures succeed
48   return true;
49 }
50 
Flush()51 void LogCapture::Flush() {}
52 
Sync()53 void LogCapture::Sync() {}
54 
Reset()55 void LogCapture::Reset() {}
56 
Read()57 std::string LogCapture::Read() {
58   return std::string();
59 }
60 
Size() const61 size_t LogCapture::Size() const {
62   size_t size{0UL};
63   return size;
64 }
65 
WaitUntilLogContains(std::promise<void> * promise,std::string text)66 void LogCapture::WaitUntilLogContains(std::promise<void>* promise, std::string text) {
67   std::async([promise, text]() { promise->set_value(); });
68   promise->get_future().wait();
69 }
70 
create_backing_store() const71 std::pair<int, int> LogCapture::create_backing_store() const {
72   int dup_fd = -1;
73   int fd = -1;
74   return std::make_pair(dup_fd, fd);
75 }
76 
set_non_blocking(int fd) const77 bool LogCapture::set_non_blocking(int fd) const {
78   return true;
79 }
80 
clean_up()81 void LogCapture::clean_up() {}
82 
83 }  // namespace testing
84 }  // namespace bluetooth
85