From ba593f2f5b498fb7d2ee10ad3e01cd26d135fbde Mon Sep 17 00:00:00 2001
From: Sean Klein <smklein@google.com>
Date: Thu, 9 May 2019 11:25:20 -0700
Subject: [PATCH] [test][crypto] Relocate unit tests to exist alongside source

Change-Id: I141bb03798bf20a1308dc0d9fe708d498ea8e7c0
---
 zircon/system/{utest/crypto => ulib/crypto/test}/BUILD.gn  | 7 +++++++
 zircon/system/{utest/crypto => ulib/crypto/test}/aead.cpp  | 0
 zircon/system/{utest/crypto => ulib/crypto/test}/bytes.cpp | 0
 .../system/{utest/crypto => ulib/crypto/test}/cipher.cpp   | 0
 zircon/system/{utest/crypto => ulib/crypto/test}/hkdf.cpp  | 0
 zircon/system/{utest/crypto => ulib/crypto/test}/hmac.cpp  | 0
 .../system/{utest/crypto => ulib/crypto/test}/secret.cpp   | 0
 zircon/system/{utest/crypto => ulib/crypto/test}/utils.cpp | 0
 zircon/system/{utest/crypto => ulib/crypto/test}/utils.h   | 0
 zircon/system/utest/BUILD.gn                               | 2 +-
 zircon/system/utest/zxcrypt/BUILD.gn                       | 6 +++---
 zircon/system/utest/zxcrypt/test-device.h                  | 2 +-
 12 files changed, 12 insertions(+), 5 deletions(-)
 rename zircon/system/{utest/crypto => ulib/crypto/test}/BUILD.gn (87%)
 rename zircon/system/{utest/crypto => ulib/crypto/test}/aead.cpp (100%)
 rename zircon/system/{utest/crypto => ulib/crypto/test}/bytes.cpp (100%)
 rename zircon/system/{utest/crypto => ulib/crypto/test}/cipher.cpp (100%)
 rename zircon/system/{utest/crypto => ulib/crypto/test}/hkdf.cpp (100%)
 rename zircon/system/{utest/crypto => ulib/crypto/test}/hmac.cpp (100%)
 rename zircon/system/{utest/crypto => ulib/crypto/test}/secret.cpp (100%)
 rename zircon/system/{utest/crypto => ulib/crypto/test}/utils.cpp (100%)
 rename zircon/system/{utest/crypto => ulib/crypto/test}/utils.h (100%)

diff --git a/zircon/system/utest/crypto/BUILD.gn b/zircon/system/ulib/crypto/test/BUILD.gn
similarity index 87%
rename from zircon/system/utest/crypto/BUILD.gn
rename to zircon/system/ulib/crypto/test/BUILD.gn
index bea76c0cfd7..464a8389d0d 100644
--- a/zircon/system/utest/crypto/BUILD.gn
+++ b/zircon/system/ulib/crypto/test/BUILD.gn
@@ -2,6 +2,13 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+group("test") {
+  testonly = true
+  deps = [
+    ":crypto",
+  ]
+}
+
 test("crypto") {
   sources = [
     "aead.cpp",
diff --git a/zircon/system/utest/crypto/aead.cpp b/zircon/system/ulib/crypto/test/aead.cpp
similarity index 100%
rename from zircon/system/utest/crypto/aead.cpp
rename to zircon/system/ulib/crypto/test/aead.cpp
diff --git a/zircon/system/utest/crypto/bytes.cpp b/zircon/system/ulib/crypto/test/bytes.cpp
similarity index 100%
rename from zircon/system/utest/crypto/bytes.cpp
rename to zircon/system/ulib/crypto/test/bytes.cpp
diff --git a/zircon/system/utest/crypto/cipher.cpp b/zircon/system/ulib/crypto/test/cipher.cpp
similarity index 100%
rename from zircon/system/utest/crypto/cipher.cpp
rename to zircon/system/ulib/crypto/test/cipher.cpp
diff --git a/zircon/system/utest/crypto/hkdf.cpp b/zircon/system/ulib/crypto/test/hkdf.cpp
similarity index 100%
rename from zircon/system/utest/crypto/hkdf.cpp
rename to zircon/system/ulib/crypto/test/hkdf.cpp
diff --git a/zircon/system/utest/crypto/hmac.cpp b/zircon/system/ulib/crypto/test/hmac.cpp
similarity index 100%
rename from zircon/system/utest/crypto/hmac.cpp
rename to zircon/system/ulib/crypto/test/hmac.cpp
diff --git a/zircon/system/utest/crypto/secret.cpp b/zircon/system/ulib/crypto/test/secret.cpp
similarity index 100%
rename from zircon/system/utest/crypto/secret.cpp
rename to zircon/system/ulib/crypto/test/secret.cpp
diff --git a/zircon/system/utest/crypto/utils.cpp b/zircon/system/ulib/crypto/test/utils.cpp
similarity index 100%
rename from zircon/system/utest/crypto/utils.cpp
rename to zircon/system/ulib/crypto/test/utils.cpp
diff --git a/zircon/system/utest/crypto/utils.h b/zircon/system/ulib/crypto/test/utils.h
similarity index 100%
rename from zircon/system/utest/crypto/utils.h
rename to zircon/system/ulib/crypto/test/utils.h
diff --git a/zircon/system/utest/BUILD.gn b/zircon/system/utest/BUILD.gn
index d64f70d2673..5bef23e95b5 100644
--- a/zircon/system/utest/BUILD.gn
+++ b/zircon/system/utest/BUILD.gn
@@ -65,6 +65,7 @@ if (current_cpu != "") {
       "$zx/system/ulib/blobfs/test",
       "$zx/system/ulib/bootfs:bootfs-test",
       "$zx/system/ulib/c:tests",
+      "$zx/system/ulib/crypto/test",
       "$zx/system/ulib/cobalt-client/test",
       "$zx/system/ulib/ddk:ddk-unittest",
       "$zx/system/ulib/digest/test",
@@ -102,7 +103,6 @@ if (current_cpu != "") {
       "compiler",
       "core",
       "cprng",
-      "crypto",
       "ctor",
       "debugger",
       "devfs",
diff --git a/zircon/system/utest/zxcrypt/BUILD.gn b/zircon/system/utest/zxcrypt/BUILD.gn
index 38674e14887..5b9d8fa1659 100644
--- a/zircon/system/utest/zxcrypt/BUILD.gn
+++ b/zircon/system/utest/zxcrypt/BUILD.gn
@@ -10,9 +10,9 @@ test("zxcrypt") {
     "zxcrypt.cpp",
   ]
 
-  # This code does #include "crypto/foo.h" to reuse headers from
-  # $zx/system/utest/crypto.
-  include_dirs = [ "$zx/system/utest" ]
+  # This code does #include "crypto/test/foo.h" to reuse headers from
+  # $zx/system/ulib/crypto/test.
+  include_dirs = [ "$zx/system/ulib" ]
 
   deps = [
     "$zx/system/fidl/fuchsia-device:c",
diff --git a/zircon/system/utest/zxcrypt/test-device.h b/zircon/system/utest/zxcrypt/test-device.h
index 4fcbedead08..4cdb9a7462f 100644
--- a/zircon/system/utest/zxcrypt/test-device.h
+++ b/zircon/system/utest/zxcrypt/test-device.h
@@ -24,7 +24,7 @@
 #include <zircon/types.h>
 #include <zxcrypt/fdio-volume.h>
 
-#include "crypto/utils.h"
+#include "crypto/test/utils.h"
 
 #define DEFINE_EACH_DEVICE(Test)                                                                   \
     bool Test##Raw(Volume::Version version) { return Test(version, false /* not FVM */); }         \
-- 
GitLab