summaryrefslogtreecommitdiffstats
path: root/libutils
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2014-10-16 20:47:51 -0700
committerDan Albert <danalbert@google.com>2014-11-04 17:19:55 -0800
commit27d166cb3aecc003b2ea576ec23695aff78de1a5 (patch)
treebf74b1d1b951199d2b6a48411ea477401c047521 /libutils
parenta11ac45536f0722becefccdb6b58378c5d9d0d4b (diff)
downloadsystem_core-27d166cb3aecc003b2ea576ec23695aff78de1a5.zip
system_core-27d166cb3aecc003b2ea576ec23695aff78de1a5.tar.gz
system_core-27d166cb3aecc003b2ea576ec23695aff78de1a5.tar.bz2
Clean up some test makefiles.
Needed for building with libc++ as the default STL. Bug: 15193147 Change-Id: I8b462bd288fbea7e0ab182f85ffcbf438afb6aa4
Diffstat (limited to 'libutils')
-rw-r--r--libutils/tests/Android.mk37
-rw-r--r--libutils/tests/BasicHashtable_test.cpp19
-rw-r--r--libutils/tests/LruCache_test.cpp15
3 files changed, 47 insertions, 24 deletions
diff --git a/libutils/tests/Android.mk b/libutils/tests/Android.mk
index ab03d87..634f44f 100644
--- a/libutils/tests/Android.mk
+++ b/libutils/tests/Android.mk
@@ -1,8 +1,28 @@
+#
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
# Build the unit tests.
LOCAL_PATH := $(call my-dir)
-# Build the unit tests.
-test_src_files := \
+include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_MODULE := libutils_tests
+
+LOCAL_SRC_FILES := \
BasicHashtable_test.cpp \
BlobCache_test.cpp \
BitSet_test.cpp \
@@ -10,19 +30,12 @@ test_src_files := \
LruCache_test.cpp \
String8_test.cpp \
Unicode_test.cpp \
- Vector_test.cpp
+ Vector_test.cpp \
-shared_libraries := \
+LOCAL_SHARED_LIBRARIES := \
libz \
liblog \
libcutils \
libutils \
-$(foreach file,$(test_src_files), \
- $(eval include $(CLEAR_VARS)) \
- $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \
- $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \
- $(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
- $(eval include $(BUILD_NATIVE_TEST)) \
-)
+include $(BUILD_NATIVE_TEST)
diff --git a/libutils/tests/BasicHashtable_test.cpp b/libutils/tests/BasicHashtable_test.cpp
index a61b1e1..4b3a717 100644
--- a/libutils/tests/BasicHashtable_test.cpp
+++ b/libutils/tests/BasicHashtable_test.cpp
@@ -21,12 +21,12 @@
#include <gtest/gtest.h>
#include <unistd.h>
-namespace android {
+namespace {
typedef int SimpleKey;
typedef int SimpleValue;
-typedef key_value_pair_t<SimpleKey, SimpleValue> SimpleEntry;
-typedef BasicHashtable<SimpleKey, SimpleEntry> SimpleHashtable;
+typedef android::key_value_pair_t<SimpleKey, SimpleValue> SimpleEntry;
+typedef android::BasicHashtable<SimpleKey, SimpleEntry> SimpleHashtable;
struct ComplexKey {
int k;
@@ -56,10 +56,6 @@ struct ComplexKey {
ssize_t ComplexKey::instanceCount = 0;
-template<> inline hash_t hash_type(const ComplexKey& value) {
- return hash_type(value.k);
-}
-
struct ComplexValue {
int v;
@@ -80,9 +76,18 @@ struct ComplexValue {
ssize_t ComplexValue::instanceCount = 0;
+} // namespace
+
+
+namespace android {
+
typedef key_value_pair_t<ComplexKey, ComplexValue> ComplexEntry;
typedef BasicHashtable<ComplexKey, ComplexEntry> ComplexHashtable;
+template<> inline hash_t hash_type(const ComplexKey& value) {
+ return hash_type(value.k);
+}
+
class BasicHashtableTest : public testing::Test {
protected:
virtual void SetUp() {
diff --git a/libutils/tests/LruCache_test.cpp b/libutils/tests/LruCache_test.cpp
index bcbea32..6534211 100644
--- a/libutils/tests/LruCache_test.cpp
+++ b/libutils/tests/LruCache_test.cpp
@@ -20,7 +20,7 @@
#include <cutils/log.h>
#include <gtest/gtest.h>
-namespace android {
+namespace {
typedef int SimpleKey;
typedef const char* StringValue;
@@ -53,10 +53,6 @@ struct ComplexKey {
ssize_t ComplexKey::instanceCount = 0;
-template<> inline hash_t hash_type(const ComplexKey& value) {
- return hash_type(value.k);
-}
-
struct ComplexValue {
int v;
@@ -77,8 +73,17 @@ struct ComplexValue {
ssize_t ComplexValue::instanceCount = 0;
+} // namespace
+
+
+namespace android {
+
typedef LruCache<ComplexKey, ComplexValue> ComplexCache;
+template<> inline android::hash_t hash_type(const ComplexKey& value) {
+ return hash_type(value.k);
+}
+
class EntryRemovedCallback : public OnEntryRemoved<SimpleKey, StringValue> {
public:
EntryRemovedCallback() : callbackCount(0), lastKey(-1), lastValue(NULL) { }