OSDN Git Service

test_vendor_lib: Use libbase's CHECK/DCHECK
authorDennis Cheng <dennischeng@google.com>
Mon, 27 Jul 2015 22:55:15 +0000 (15:55 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Wed, 5 Aug 2015 23:21:06 +0000 (23:21 +0000)
This upload pulls in libchrome to the test vendor library and uses CHECK
and DCHECK from base/logging.h.

Bug: 21586676
Change-Id: Ia88b4aa3728493d798e8d36076a351a00fad7c6b

15 files changed:
vendor_libs/test_vendor_lib/BUILD.gn
vendor_libs/test_vendor_lib/include/bredr_controller.h
vendor_libs/test_vendor_lib/include/command_packet.h
vendor_libs/test_vendor_lib/include/event_packet.h
vendor_libs/test_vendor_lib/include/hci_handler.h
vendor_libs/test_vendor_lib/include/hci_transport.h
vendor_libs/test_vendor_lib/include/packet_stream.h
vendor_libs/test_vendor_lib/src/bredr_controller.cc
vendor_libs/test_vendor_lib/src/bt_vendor.cc
vendor_libs/test_vendor_lib/src/command_packet.cc
vendor_libs/test_vendor_lib/src/event_packet.cc
vendor_libs/test_vendor_lib/src/hci_handler.cc
vendor_libs/test_vendor_lib/src/hci_transport.cc
vendor_libs/test_vendor_lib/src/packet.cc
vendor_libs/test_vendor_lib/src/packet_stream.cc

index dac1af6..b62b92f 100644 (file)
@@ -19,7 +19,9 @@ shared_library("test_vendor_lib") {
     "//stack/include",
   ]
 
-  # TODO(dennischeng): Add libchrome as a dependency.
+  deps = [
+    "//third_party/libchrome",
+  ]
 }
 
 # TODO(dennischeng): Add a unit test target.
index d3c8abe..ebd52c8 100644 (file)
@@ -20,7 +20,7 @@
 #include <vector>
 #include <unordered_map>
 
-#include <base/macros.h>
+#include "base/macros.h"
 
 namespace test_vendor_lib {
 
index 2d64ee1..16bb24c 100644 (file)
 
 #pragma once
 
-#include "vendor_libs/test_vendor_lib/include/packet.h"
-
 #include <cstdint>
 #include <vector>
 
-#include <base/macros.h>
+#include "base/macros.h"
+#include "vendor_libs/test_vendor_lib/include/packet.h"
 
 namespace test_vendor_lib {
 
index 23a9f9d..e7025d9 100644 (file)
 
 #pragma once
 
-#include "vendor_libs/test_vendor_lib/include/packet.h"
-
 #include <cstdint>
 #include <memory>
 #include <vector>
 
+#include "vendor_libs/test_vendor_lib/include/packet.h"
+
 namespace test_vendor_lib {
 
 // The following is specified in the Bluetooth Core Specification Version 4.2,
index b11d6ef..b90ab59 100644 (file)
 
 #pragma once
 
-#include "vendor_libs/test_vendor_lib/include/command_packet.h"
-#include "vendor_libs/test_vendor_lib/include/packet.h"
-
 #include <cstdint>
 #include <memory>
 #include <unordered_map>
 #include <vector>
 
-#include <base/macros.h>
+#include "base/macros.h"
+#include "vendor_libs/test_vendor_lib/include/command_packet.h"
+#include "vendor_libs/test_vendor_lib/include/packet.h"
 
 namespace test_vendor_lib {
 
index 184fb0f..9a1bd31 100644 (file)
 
 #pragma once
 
-#include "vendor_libs/test_vendor_lib/include/command_packet.h"
-#include "vendor_libs/test_vendor_lib/include/event_packet.h"
-#include "vendor_libs/test_vendor_lib/include/packet.h"
-#include "vendor_libs/test_vendor_lib/include/packet_stream.h"
-
 #include <functional>
 #include <memory>
 #include <queue>
 
-#include <base/macros.h>
-
 extern "C" {
 #include <sys/epoll.h>
 }  // extern "C"
 
+#include "base/macros.h"
+#include "vendor_libs/test_vendor_lib/include/command_packet.h"
+#include "vendor_libs/test_vendor_lib/include/event_packet.h"
+#include "vendor_libs/test_vendor_lib/include/packet.h"
+#include "vendor_libs/test_vendor_lib/include/packet_stream.h"
+
 namespace test_vendor_lib {
 
 // Manages communication channel between HCI and the controller. Listens for
index 2b9fab3..1d2bbde 100644 (file)
 
 #pragma once
 
-#include "vendor_libs/test_vendor_lib/include/command_packet.h"
-#include "vendor_libs/test_vendor_lib/include/event_packet.h"
-#include "vendor_libs/test_vendor_lib/include/packet.h"
-
 #include <cstdint>
 #include <vector>
 #include <memory>
 
+#include "vendor_libs/test_vendor_lib/include/command_packet.h"
+#include "vendor_libs/test_vendor_lib/include/event_packet.h"
+#include "vendor_libs/test_vendor_lib/include/packet.h"
+
 namespace test_vendor_lib {
 
 // Provides abstractions for IO with Packet objects. Used to receive commands
index 5b07276..fd7bfed 100644 (file)
@@ -17,6 +17,8 @@
 #define LOG_TAG "bredr_controller"
 
 #include "vendor_libs/test_vendor_lib/include/bredr_controller.h"
+
+#include "base/logging.h"
 #include "vendor_libs/test_vendor_lib/include/event_packet.h"
 #include "vendor_libs/test_vendor_lib/include/hci_handler.h"
 #include "vendor_libs/test_vendor_lib/include/hci_transport.h"
@@ -24,8 +26,6 @@
 extern "C" {
 #include "stack/include/hcidefs.h"
 #include "osi/include/log.h"
-
-#include <assert.h>
 }  // extern "C"
 
 namespace {
@@ -185,16 +185,14 @@ BREDRController* g_controller = nullptr;
 // static
 BREDRController* BREDRController::Get() {
   // Initialize should have been called already.
-  // TODO(dennischeng): use CHECK and DCHECK when libbase is imported.
-  assert(g_controller);
+  CHECK(g_controller);
   return g_controller;
 }
 
 // static
 void BREDRController::Initialize() {
   // Multiple calls to Initialize should not be made.
-  // TODO(dennischeng): use CHECK and DCHECK when libbase is imported.
-  assert(!g_controller);
+  CHECK(!g_controller);
   g_controller = new BREDRController();
 }
 
@@ -311,7 +309,7 @@ void BREDRController::HciSetEventMask(const std::vector<uint8_t>& /* args */) {
 
 void BREDRController::HciWriteInquiryMode(const std::vector<uint8_t>& args) {
   LogCommand("Write Inquiry Mode");
-  assert(args.size() == 1);
+  CHECK(args.size() == 1);
   inquiry_mode_ = args[0];
   SendEmptySuccessCommandComplete(HCI_WRITE_INQUIRY_MODE);
 }
index e5bab5e..4dc5076 100644 (file)
 
 #define LOG_TAG "bt_vendor"
 
+#include <pthread.h>
+
+#include "base/logging.h"
 #include "hci/include/bt_vendor_lib.h"
 #include "vendor_libs/test_vendor_lib/include/bredr_controller.h"
 #include "vendor_libs/test_vendor_lib/include/hci_handler.h"
 #include "vendor_libs/test_vendor_lib/include/hci_transport.h"
 
-#include <pthread.h>
-
 extern "C" {
 #include "osi/include/log.h"
 
-#include <assert.h>
 #include <unistd.h>
 }  // extern "C"
 
@@ -50,8 +50,7 @@ static int TestVendorInitialize(const bt_vendor_callbacks_t* p_cb,
                           unsigned char* /* local_bdaddr */) {
   LOG_INFO(LOG_TAG, "Initializing test controller.");
 
-  // TODO(dennischeng): use CHECK and DCHECK when libbase is imported.
-  assert(p_cb);
+  CHECK(p_cb);
   vendor_callbacks = const_cast<bt_vendor_callbacks_t*>(p_cb);
 
   // Initialize global objects. The order of initialization does not matter,
index 404ab7c..7197233 100644 (file)
@@ -22,8 +22,6 @@ extern "C" {
 #include "hci/include/hci_hal.h"
 #include "osi/include/log.h"
 #include "stack/include/hcidefs.h"
-
-#include <assert.h>
 }  // extern "C"
 
 namespace test_vendor_lib {
index 1aad065..75a1f46 100644 (file)
@@ -24,8 +24,6 @@
 extern "C" {
 #include "osi/include/log.h"
 #include "stack/include/hcidefs.h"
-
-#include <assert.h>
 }  // extern "C"
 
 namespace test_vendor_lib {
index 6c064e0..9b08d96 100644 (file)
 #define LOG_TAG "hci_handler"
 
 #include "vendor_libs/test_vendor_lib/include/hci_handler.h"
+
+#include "base/logging.h"
 #include "vendor_libs/test_vendor_lib/include/hci_transport.h"
 
 extern "C" {
 #include "osi/include/log.h"
-
-#include <assert.h>
 }  // extern "C"
 
 namespace test_vendor_lib {
@@ -41,16 +41,14 @@ void HciHandler::RegisterTransportCallbacks() {
 // static
 HciHandler* HciHandler::Get() {
   // Initialize should have been called already.
-  // TODO(dennischeng): use CHECK and DCHECK when libbase is imported.
-  assert(g_handler);
+  CHECK(g_handler);
   return g_handler;
 }
 
 // static
 void HciHandler::Initialize() {
   // Multiple calls to Initialize should not be made.
-  // TODO(dennischeng): use CHECK and DCHECK when libbase is imported.
-  assert(!g_handler);
+  CHECK(!g_handler);
   g_handler = new HciHandler();
 }
 
index 3d2f1e7..82c7020 100644 (file)
 
 #include "vendor_libs/test_vendor_lib/include/hci_transport.h"
 
-extern "C" {
-#include "stack/include/hcidefs.h"
-#include "osi/include/log.h"
+#include "base/logging.h"
 
+extern "C" {
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-#include <assert.h>
 #include <fcntl.h>
 #include <unistd.h>
+
+#include "stack/include/hcidefs.h"
+#include "osi/include/log.h"
 }  // extern "C"
 
 namespace {
@@ -62,16 +63,14 @@ int HciTransport::GetHciFd() const {
 // static
 HciTransport* HciTransport::Get() {
   // Initialize should have been called already.
-  // TODO(dennischeng): use CHECK and DCHECK when libbase is imported.
-  assert(g_transporter);
+  CHECK(g_transporter);
   return g_transporter;
 }
 
 // static
 void HciTransport::Initialize() {
   // Multiple calls to Initialize should not be made.
-  // TODO(dennischeng): use CHECK and DCHECK when libbase is imported.
-  assert(!g_transporter);
+  CHECK(!g_transporter);
   g_transporter = new HciTransport();
 }
 
index 72f26b6..b5f8a66 100644 (file)
@@ -18,6 +18,8 @@
 
 #include "vendor_libs/test_vendor_lib/include/packet.h"
 
+#include "base/logging.h"
+
 #include <algorithm>
 
 extern "C" {
@@ -40,7 +42,7 @@ bool Packet::Encode(const std::vector<uint8_t>& header,
 
 const std::vector<uint8_t>& Packet::GetHeader() const {
   // Every packet must have a header.
-  assert(GetHeaderSize() > 0);
+  CHECK(GetHeaderSize() > 0);
   return header_;
 }
 
index 152c345..74300b4 100644 (file)
 
 #include "vendor_libs/test_vendor_lib/include/packet_stream.h"
 
-extern "C" {
-#include "osi/include/log.h"
+#include "base/logging.h"
 
+extern "C" {
 #include <errno.h>
 #include <unistd.h>
+
+#include "osi/include/log.h"
 }  // extern "C"
 
 namespace test_vendor_lib {
@@ -130,8 +132,7 @@ bool PacketStream::ReceiveAll(std::vector<uint8_t>& destination,
 
 bool PacketStream::SendAll(const std::vector<uint8_t>& source,
                            size_t num_octets_to_send) const {
-  // TODO(dennischeng): use CHECK and DCHECK when libbase is imported.
-  assert(source.size() >= num_octets_to_send);
+  CHECK(source.size() >= num_octets_to_send);
   size_t octets_remaining = num_octets_to_send;
   do {
     int num_octets_sent = write(