logd: add LogBufferTest.cpp

Add a standalone test of log buffers that does not interact with the
logd running on the device.

Test: this new test
Change-Id: Ie4ecc50289ef164aa47cc72ddeeb9b28e776db94
diff --git a/logd/Android.bp b/logd/Android.bp
index d79e258..32bfefe 100644
--- a/logd/Android.bp
+++ b/logd/Android.bp
@@ -110,3 +110,60 @@
     src: "logtagd.rc",
     sub_dir: "init",
 }
+
+// -----------------------------------------------------------------------------
+// Unit tests.
+// -----------------------------------------------------------------------------
+
+cc_defaults {
+    name: "logd-unit-test-defaults",
+
+    cflags: [
+        "-fstack-protector-all",
+        "-g",
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+        "-fno-builtin",
+
+        "-DAUDITD_LOG_TAG=1003",
+        "-DCHATTY_LOG_TAG=1004",
+    ],
+
+    srcs: [
+        "logd_test.cpp",
+        "LogBufferTest.cpp",
+    ],
+
+    static_libs: [
+        "libbase",
+        "libcutils",
+        "liblog",
+        "liblogd",
+        "libselinux",
+    ],
+}
+
+// Build tests for the logger. Run with:
+//   adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
+cc_test {
+    name: "logd-unit-tests",
+    defaults: ["logd-unit-test-defaults"],
+}
+
+cc_test {
+    name: "CtsLogdTestCases",
+    defaults: ["logd-unit-test-defaults"],
+    multilib: {
+        lib32: {
+            suffix: "32",
+        },
+        lib64: {
+            suffix: "64",
+        },
+    },
+    test_suites: [
+        "cts",
+        "vts10",
+    ],
+}