From 0daaa72b0fa8b18435c1a6d159742f8fef865a99 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Fri, 6 Dec 2019 15:57:54 -0800 Subject: [PATCH] libsnapshot: add library for test helpers Add libsnapshot_test_helpers for update engine tests to properly set up depended modules. Test: update_engine_unittests Test: libsnapshot_test Change-Id: Idd90a74cd6fb489f6ae14f44493b2288205c4a94 --- fs_mgr/libsnapshot/Android.bp | 29 +++++++++++++++++++ .../libsnapshot}/test_helpers.h | 0 .../partition_cow_creator_test.cpp | 3 +- .../snapshot_metadata_updater_test.cpp | 2 +- fs_mgr/libsnapshot/snapshot_test.cpp | 2 +- fs_mgr/libsnapshot/test_helpers.cpp | 2 +- 6 files changed, 34 insertions(+), 4 deletions(-) rename fs_mgr/libsnapshot/{ => include_test/libsnapshot}/test_helpers.h (100%) diff --git a/fs_mgr/libsnapshot/Android.bp b/fs_mgr/libsnapshot/Android.bp index 1d72c7041..30d01a662 100644 --- a/fs_mgr/libsnapshot/Android.bp +++ b/fs_mgr/libsnapshot/Android.bp @@ -121,6 +121,34 @@ cc_library_static { ], } +cc_library_static { + name: "libsnapshot_test_helpers", + defaults: ["libsnapshot_defaults"], + export_include_dirs: [ + "include_test", + ], + srcs: [ + "test_helpers.cpp", + ], + shared_libs: [ + "android.hardware.boot@1.1", + "libcrypto", + ], + export_shared_lib_headers: [ + "android.hardware.boot@1.1", + ], + header_libs: [ + "libstorage_literals_headers", + ], + export_header_lib_headers: [ + "libstorage_literals_headers", + ], + static_libs: [ + "libgtest", + "libgmock", + ], +} + cc_test { name: "libsnapshot_test", defaults: ["libsnapshot_defaults"], @@ -144,6 +172,7 @@ cc_test { "libgmock", "liblp", "libsnapshot", + "libsnapshot_test_helpers", "libsparse", "libz", ], diff --git a/fs_mgr/libsnapshot/test_helpers.h b/fs_mgr/libsnapshot/include_test/libsnapshot/test_helpers.h similarity index 100% rename from fs_mgr/libsnapshot/test_helpers.h rename to fs_mgr/libsnapshot/include_test/libsnapshot/test_helpers.h diff --git a/fs_mgr/libsnapshot/partition_cow_creator_test.cpp b/fs_mgr/libsnapshot/partition_cow_creator_test.cpp index eae6c35d8..9da3f0525 100644 --- a/fs_mgr/libsnapshot/partition_cow_creator_test.cpp +++ b/fs_mgr/libsnapshot/partition_cow_creator_test.cpp @@ -18,9 +18,10 @@ #include #include +#include + #include "dm_snapshot_internals.h" #include "partition_cow_creator.h" -#include "test_helpers.h" #include "utility.h" using namespace android::fs_mgr; diff --git a/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp b/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp index 4fd875951..337be4f68 100644 --- a/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp +++ b/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp @@ -24,7 +24,7 @@ #include #include -#include "test_helpers.h" +#include using namespace android::storage_literals; using android::fs_mgr::LpMetadata; diff --git a/fs_mgr/libsnapshot/snapshot_test.cpp b/fs_mgr/libsnapshot/snapshot_test.cpp index 9e5fef3b7..ff943f2c8 100644 --- a/fs_mgr/libsnapshot/snapshot_test.cpp +++ b/fs_mgr/libsnapshot/snapshot_test.cpp @@ -38,7 +38,7 @@ #include #include -#include "test_helpers.h" +#include #include "utility.h" namespace android { diff --git a/fs_mgr/libsnapshot/test_helpers.cpp b/fs_mgr/libsnapshot/test_helpers.cpp index 2d623477b..f7f25afd4 100644 --- a/fs_mgr/libsnapshot/test_helpers.cpp +++ b/fs_mgr/libsnapshot/test_helpers.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "test_helpers.h" +#include #include #include