Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f0f9ca0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Split log_capture into android and host targets"

parents 61451cc6 7fc2c9df
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -353,12 +353,16 @@ cc_test {
            srcs: [
                ":BluetoothHalTestSources_hci_host",
                ":BluetoothOsTestSources_host",
                ":BluetoothHostTestingLogCapture",
                ":BluetoothHostTestingLogCaptureTest",
            ],
        },
        android: {
            srcs: [
                ":BluetoothHalTestSources_hci_android_hidl",
                ":BluetoothOsTestSources_android",
                ":BluetoothAndroidTestingLogCapture",
                ":BluetoothAndroidTestingLogCaptureTest",
            ],
            static_libs: [
                "android.system.suspend.control-V1-ndk",
+0 −2
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ filegroup {
filegroup {
    name: "BluetoothCommonTestSources",
    srcs: [
        ":BluetoothCommonTestingLogCapture",
        ":BluetoothCommonTestingLogCaptureTest",
        "bidi_queue_unittest.cc",
        "blocking_queue_unittest.cc",
        "byte_array_test.cc",
+18 −4
Original line number Diff line number Diff line
@@ -8,15 +8,29 @@ package {
}

filegroup {
    name: "BluetoothCommonTestingLogCapture",
    name: "BluetoothAndroidTestingLogCapture",
    srcs: [
            "log_capture.cc",
            "android/log_capture.cc",
  ],
}

filegroup {
    name: "BluetoothCommonTestingLogCaptureTest",
    name: "BluetoothAndroidTestingLogCaptureTest",
    srcs: [
            "log_capture_test.cc",
            "android/log_capture_test.cc",
    ],
}

filegroup {
    name: "BluetoothHostTestingLogCapture",
    srcs: [
            "host/log_capture.cc",
  ],
}

filegroup {
    name: "BluetoothHostTestingLogCaptureTest",
    srcs: [
            "host/log_capture_test.cc",
    ],
}
+84 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "common/testing/log_capture.h"

#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>

#include <cstddef>
#include <sstream>
#include <string>

#include "os/log.h"

namespace bluetooth {
namespace testing {

LogCapture::LogCapture() {
  LOG_INFO(
      "Log capture disabled for android build dup_fd:%d fd:%d original_stderr_fd:%d",
      dup_fd_,
      fd_,
      original_stderr_fd_);
}

LogCapture::~LogCapture() {}

LogCapture* LogCapture::Rewind() {
  return this;
}

bool LogCapture::Find(std::string to_find) {
  // For |atest| assume all log captures succeed
  return true;
}

void LogCapture::Flush() {}

void LogCapture::Sync() {}

void LogCapture::Reset() {}

std::string LogCapture::Read() {
  return std::string();
}

size_t LogCapture::Size() const {
  size_t size{0UL};
  return size;
}

void LogCapture::WaitUntilLogContains(std::promise<void>* promise, std::string text) {
  std::async([promise, text]() { promise->set_value(); });
  promise->get_future().wait();
}

std::pair<int, int> LogCapture::create_backing_store() const {
  int dup_fd = -1;
  int fd = -1;
  return std::make_pair(dup_fd, fd);
}

bool LogCapture::set_non_blocking(int fd) const {
  return true;
}

void LogCapture::clean_up() {}

}  // namespace testing
}  // namespace bluetooth
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "../log_capture.h"

#include <gtest/gtest.h>

#include <cstring>
#include <memory>
#include <string>

#include "common/init_flags.h"
#include "os/log.h"

namespace bluetooth {
namespace testing {

class LogCaptureTest : public ::testing::Test {
 protected:
  void SetUp() override {}

  void TearDown() override {}
};

TEST_F(LogCaptureTest, not_working_over_atest) {}

}  // namespace testing
}  // namespace bluetooth
Loading