From 2dda549429ddd8d43597c21b2e5d372089b4d7b3 Mon Sep 17 00:00:00 2001
From: Sean Klein <smklein@google.com>
Date: Thu, 9 May 2019 11:21:26 -0700
Subject: [PATCH] [test][cobalt-client] Relocate unit tests to exist alongside
 source

Change-Id: I0f9b5d25d3ac30cdf9ea980dfa73b7dbac2bef03
---
 .../system/ulib/cobalt-client/test/BUILD.gn   | 20 +++++++++++
 .../test}/cobalt_logger_test.cpp              |  0
 .../cobalt-client/test}/collector_test.cpp    |  0
 .../cobalt-client/test}/counter_test.cpp      |  0
 .../cobalt-client/test}/fake_logger.h         |  0
 .../cobalt-client/test}/histogram_test.cpp    |  0
 .../system/ulib/cobalt-client/test/main.cpp   | 19 +++++++++++
 .../test}/metric_options_test.cpp             |  0
 .../cobalt-client/test}/timer_test.cpp        |  0
 .../test}/types_internal_test.cpp             |  0
 zircon/system/utest/BUILD.gn                  |  1 -
 zircon/system/utest/cobalt-client/BUILD.gn    | 34 -------------------
 12 files changed, 39 insertions(+), 35 deletions(-)
 rename zircon/system/{utest/cobalt-client => ulib/cobalt-client/test}/cobalt_logger_test.cpp (100%)
 rename zircon/system/{utest/cobalt-client => ulib/cobalt-client/test}/collector_test.cpp (100%)
 rename zircon/system/{utest/cobalt-client => ulib/cobalt-client/test}/counter_test.cpp (100%)
 rename zircon/system/{utest/cobalt-client => ulib/cobalt-client/test}/fake_logger.h (100%)
 rename zircon/system/{utest/cobalt-client => ulib/cobalt-client/test}/histogram_test.cpp (100%)
 create mode 100644 zircon/system/ulib/cobalt-client/test/main.cpp
 rename zircon/system/{utest/cobalt-client => ulib/cobalt-client/test}/metric_options_test.cpp (100%)
 rename zircon/system/{utest/cobalt-client => ulib/cobalt-client/test}/timer_test.cpp (100%)
 rename zircon/system/{utest/cobalt-client => ulib/cobalt-client/test}/types_internal_test.cpp (100%)
 delete mode 100644 zircon/system/utest/cobalt-client/BUILD.gn

diff --git a/zircon/system/ulib/cobalt-client/test/BUILD.gn b/zircon/system/ulib/cobalt-client/test/BUILD.gn
index aa80d5a1822..636173938bd 100644
--- a/zircon/system/ulib/cobalt-client/test/BUILD.gn
+++ b/zircon/system/ulib/cobalt-client/test/BUILD.gn
@@ -11,11 +11,31 @@ group("test") {
 
 test("cobalt-client-unit") {
   sources = [
+    "cobalt_logger_test.cpp",
+    "collector_test.cpp",
+    "counter_test.cpp",
+    "histogram_test.cpp",
     "in-memory-logger-test.cpp",
+    "main.cpp",
+    "metric_options_test.cpp",
+    "timer_test.cpp",
+    "types_internal_test.cpp",
   ]
   deps = [
+    "$zx/system/fidl/fuchsia-cobalt:c",
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-mem:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
     "$zx/system/ulib/cobalt-client",
     "$zx/system/ulib/cobalt-client:in-memory-logger",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fidl-utils",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
     "$zx/system/ulib/zxtest",
   ]
 }
diff --git a/zircon/system/utest/cobalt-client/cobalt_logger_test.cpp b/zircon/system/ulib/cobalt-client/test/cobalt_logger_test.cpp
similarity index 100%
rename from zircon/system/utest/cobalt-client/cobalt_logger_test.cpp
rename to zircon/system/ulib/cobalt-client/test/cobalt_logger_test.cpp
diff --git a/zircon/system/utest/cobalt-client/collector_test.cpp b/zircon/system/ulib/cobalt-client/test/collector_test.cpp
similarity index 100%
rename from zircon/system/utest/cobalt-client/collector_test.cpp
rename to zircon/system/ulib/cobalt-client/test/collector_test.cpp
diff --git a/zircon/system/utest/cobalt-client/counter_test.cpp b/zircon/system/ulib/cobalt-client/test/counter_test.cpp
similarity index 100%
rename from zircon/system/utest/cobalt-client/counter_test.cpp
rename to zircon/system/ulib/cobalt-client/test/counter_test.cpp
diff --git a/zircon/system/utest/cobalt-client/fake_logger.h b/zircon/system/ulib/cobalt-client/test/fake_logger.h
similarity index 100%
rename from zircon/system/utest/cobalt-client/fake_logger.h
rename to zircon/system/ulib/cobalt-client/test/fake_logger.h
diff --git a/zircon/system/utest/cobalt-client/histogram_test.cpp b/zircon/system/ulib/cobalt-client/test/histogram_test.cpp
similarity index 100%
rename from zircon/system/utest/cobalt-client/histogram_test.cpp
rename to zircon/system/ulib/cobalt-client/test/histogram_test.cpp
diff --git a/zircon/system/ulib/cobalt-client/test/main.cpp b/zircon/system/ulib/cobalt-client/test/main.cpp
new file mode 100644
index 00000000000..8daa95fafe6
--- /dev/null
+++ b/zircon/system/ulib/cobalt-client/test/main.cpp
@@ -0,0 +1,19 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <unittest/unittest.h>
+#include <zxtest/c/zxtest.h>
+
+int main(int argc, char** argv) {
+    const bool success = unittest_run_all_tests(argc, argv);
+    if (!success) {
+        return EXIT_FAILURE;
+    }
+
+    const bool zxtest_success = RUN_ALL_TESTS(argc, argv) == 0;
+    if (!zxtest_success) {
+        return EXIT_FAILURE;
+    }
+    return EXIT_SUCCESS;
+}
diff --git a/zircon/system/utest/cobalt-client/metric_options_test.cpp b/zircon/system/ulib/cobalt-client/test/metric_options_test.cpp
similarity index 100%
rename from zircon/system/utest/cobalt-client/metric_options_test.cpp
rename to zircon/system/ulib/cobalt-client/test/metric_options_test.cpp
diff --git a/zircon/system/utest/cobalt-client/timer_test.cpp b/zircon/system/ulib/cobalt-client/test/timer_test.cpp
similarity index 100%
rename from zircon/system/utest/cobalt-client/timer_test.cpp
rename to zircon/system/ulib/cobalt-client/test/timer_test.cpp
diff --git a/zircon/system/utest/cobalt-client/types_internal_test.cpp b/zircon/system/ulib/cobalt-client/test/types_internal_test.cpp
similarity index 100%
rename from zircon/system/utest/cobalt-client/types_internal_test.cpp
rename to zircon/system/ulib/cobalt-client/test/types_internal_test.cpp
diff --git a/zircon/system/utest/BUILD.gn b/zircon/system/utest/BUILD.gn
index ee393e5224d..d64f70d2673 100644
--- a/zircon/system/utest/BUILD.gn
+++ b/zircon/system/utest/BUILD.gn
@@ -99,7 +99,6 @@ if (current_cpu != "") {
       "channel-fatal",
       "chromeos-disk-setup",
       "cleanup",
-      "cobalt-client",
       "compiler",
       "core",
       "cprng",
diff --git a/zircon/system/utest/cobalt-client/BUILD.gn b/zircon/system/utest/cobalt-client/BUILD.gn
deleted file mode 100644
index bb8e48ae74a..00000000000
--- a/zircon/system/utest/cobalt-client/BUILD.gn
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2019 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-test("cobalt-client") {
-  sources = [
-    "cobalt_logger_test.cpp",
-    "collector_test.cpp",
-    "counter_test.cpp",
-    "histogram_test.cpp",
-    "metric_options_test.cpp",
-    "timer_test.cpp",
-    "types_internal_test.cpp",
-  ]
-  deps = [
-    "$zx/system/fidl/fuchsia-cobalt:c",
-    "$zx/system/fidl/fuchsia-io:c",
-    "$zx/system/fidl/fuchsia-mem:c",
-    "$zx/system/ulib/async",
-    "$zx/system/ulib/async:async-cpp",
-    "$zx/system/ulib/async:async-default",
-    "$zx/system/ulib/async-loop",
-    "$zx/system/ulib/async-loop:async-loop-cpp",
-    "$zx/system/ulib/cobalt-client",
-    "$zx/system/ulib/fbl",
-    "$zx/system/ulib/fdio",
-    "$zx/system/ulib/fidl",
-    "$zx/system/ulib/fidl-utils",
-    "$zx/system/ulib/sync",
-    "$zx/system/ulib/unittest",
-    "$zx/system/ulib/zircon",
-    "$zx/system/ulib/zx",
-  ]
-}
-- 
GitLab