diff options
| author | Elliott Hughes <enh@google.com> | 2019-02-07 12:41:37 -0800 |
|---|---|---|
| committer | Elliott Hughes <enh@google.com> | 2019-02-11 13:15:56 -0800 |
| commit | 01705e4f1d87a30734363d0b9dde10de0866baef (patch) | |
| tree | 6cc739fbf1d1311c6392c7af79a5990ffacc9029 | |
| parent | ea57928f002306ad3994f5c209af9ccd185fb96b (diff) | |
| download | system_core-01705e4f1d87a30734363d0b9dde10de0866baef.tar.gz system_core-01705e4f1d87a30734363d0b9dde10de0866baef.tar.bz2 system_core-01705e4f1d87a30734363d0b9dde10de0866baef.zip | |
Clean up libcutils/libutils tests.
Move tests in the same directory as the corresponding code, so it's
easier to see what is/isn't tested.
Fix naming of libcutils_tests (plural) to match the singular that's more
common (even though the plural makes more sense to me).
Add these two to system/core/'s TEST_MAPPING.
Remove obsolete AndroidTest.xml.
Fix a flaky (timing-dependent) libcutils test.
Test: ran tests
Change-Id: I7e0a31ff45c8a152562bf66fc97161594249366e
| -rw-r--r-- | TEST_MAPPING | 3 | ||||
| -rw-r--r-- | libcutils/Android.bp | 69 | ||||
| -rw-r--r-- | libcutils/android_get_control_file_test.cpp (renamed from libcutils/tests/android_get_control_file_test.cpp) | 0 | ||||
| -rw-r--r-- | libcutils/android_get_control_socket_test.cpp (renamed from libcutils/tests/android_get_control_socket_test.cpp) | 0 | ||||
| -rw-r--r-- | libcutils/ashmem_test.cpp (renamed from libcutils/tests/AshmemTest.cpp) | 0 | ||||
| -rw-r--r-- | libcutils/fs_config_test.cpp (renamed from libcutils/tests/fs_config.cpp) | 0 | ||||
| -rw-r--r-- | libcutils/memset_test.cpp (renamed from libcutils/tests/MemsetTest.cpp) | 0 | ||||
| -rw-r--r-- | libcutils/multiuser_test.cpp (renamed from libcutils/tests/multiuser_test.cpp) | 0 | ||||
| -rw-r--r-- | libcutils/properties_test.cpp (renamed from libcutils/tests/PropertiesTest.cpp) | 0 | ||||
| -rw-r--r-- | libcutils/sched_policy_test.cpp (renamed from libcutils/tests/sched_policy_test.cpp) | 5 | ||||
| -rw-r--r-- | libcutils/sockets_test.cpp (renamed from libcutils/tests/sockets_test.cpp) | 0 | ||||
| -rw-r--r-- | libcutils/str_parms_test.cpp (renamed from libcutils/tests/test_str_parms.cpp) | 0 | ||||
| -rw-r--r-- | libcutils/tests/Android.bp | 92 | ||||
| -rw-r--r-- | libcutils/tests/AndroidTest.xml | 26 | ||||
| -rw-r--r-- | libcutils/trace-dev_test.cpp (renamed from libcutils/tests/trace-dev_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/Android.bp | 80 | ||||
| -rw-r--r-- | libutils/BitSet_test.cpp (renamed from libutils/tests/BitSet_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/FileMap_test.cpp (renamed from libutils/tests/FileMap_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/Looper_test.cpp (renamed from libutils/tests/Looper_test.cpp) | 55 | ||||
| -rw-r--r-- | libutils/LruCache_test.cpp (renamed from libutils/tests/LruCache_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/Mutex_test.cpp (renamed from libutils/tests/Mutex_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/RefBase_test.cpp (renamed from libutils/tests/RefBase_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/SharedBuffer_test.cpp (renamed from libutils/SharedBufferTest.cpp) | 0 | ||||
| -rw-r--r-- | libutils/Singleton_test.cpp (renamed from libutils/tests/Singleton_test.cpp) | 8 | ||||
| -rw-r--r-- | libutils/Singleton_test.h (renamed from libutils/tests/Singleton_test.h) | 0 | ||||
| -rw-r--r-- | libutils/Singleton_test1.cpp (renamed from libutils/tests/Singleton_test1.cpp) | 0 | ||||
| -rw-r--r-- | libutils/Singleton_test2.cpp (renamed from libutils/tests/Singleton_test2.cpp) | 0 | ||||
| -rw-r--r-- | libutils/String8_test.cpp (renamed from libutils/tests/String8_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/StrongPointer_test.cpp (renamed from libutils/tests/StrongPointer_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/SystemClock_test.cpp (renamed from libutils/tests/SystemClock_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/Unicode_test.cpp (renamed from libutils/tests/Unicode_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/Vector_test.cpp (renamed from libutils/tests/Vector_test.cpp) | 0 | ||||
| -rw-r--r-- | libutils/tests/Android.bp | 97 | ||||
| -rw-r--r-- | libutils/tests/README.txt | 8 | ||||
| -rw-r--r-- | libutils/tests/TestHelpers.h | 79 |
35 files changed, 205 insertions, 317 deletions
diff --git a/TEST_MAPPING b/TEST_MAPPING index bc5685b39..cc85408e0 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -19,6 +19,9 @@ "name": "libprocinfo_test" }, { + "name": "libutils_test" + }, + { "name": "memunreachable_test" }, { diff --git a/libcutils/Android.bp b/libcutils/Android.bp index 17c8a13b3..b4b8cd1ea 100644 --- a/libcutils/Android.bp +++ b/libcutils/Android.bp @@ -196,4 +196,71 @@ cc_library { ], } -subdirs = ["tests"] +cc_defaults { + name: "libcutils_test_default", + srcs: ["sockets_test.cpp"], + + target: { + android: { + srcs: [ + "android_get_control_file_test.cpp", + "android_get_control_socket_test.cpp", + "ashmem_test.cpp", + "fs_config_test.cpp", + "memset_test.cpp", + "multiuser_test.cpp", + "properties_test.cpp", + "sched_policy_test.cpp", + "str_parms_test.cpp", + "trace-dev_test.cpp", + ], + }, + + not_windows: { + srcs: [ + "str_parms_test.cpp", + ], + }, + }, + + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], +} + +test_libraries = [ + "libcutils", + "liblog", + "libbase", + "libjsoncpp", + "libprocessgroup", +] + +cc_test { + name: "libcutils_test", + test_suites: ["device-tests"], + defaults: ["libcutils_test_default"], + host_supported: true, + shared_libs: test_libraries, +} + +cc_test { + name: "libcutils_test_static", + test_suites: ["device-tests"], + defaults: ["libcutils_test_default"], + static_libs: ["libc"] + test_libraries, + stl: "libc++_static", + + target: { + android: { + static_executable: true, + }, + windows: { + host_ldlibs: ["-lws2_32"], + + enabled: true, + }, + }, +} diff --git a/libcutils/tests/android_get_control_file_test.cpp b/libcutils/android_get_control_file_test.cpp index 8de85307d..8de85307d 100644 --- a/libcutils/tests/android_get_control_file_test.cpp +++ b/libcutils/android_get_control_file_test.cpp diff --git a/libcutils/tests/android_get_control_socket_test.cpp b/libcutils/android_get_control_socket_test.cpp index e58674864..e58674864 100644 --- a/libcutils/tests/android_get_control_socket_test.cpp +++ b/libcutils/android_get_control_socket_test.cpp diff --git a/libcutils/tests/AshmemTest.cpp b/libcutils/ashmem_test.cpp index b37d020fb..b37d020fb 100644 --- a/libcutils/tests/AshmemTest.cpp +++ b/libcutils/ashmem_test.cpp diff --git a/libcutils/tests/fs_config.cpp b/libcutils/fs_config_test.cpp index c26315fea..c26315fea 100644 --- a/libcutils/tests/fs_config.cpp +++ b/libcutils/fs_config_test.cpp diff --git a/libcutils/tests/MemsetTest.cpp b/libcutils/memset_test.cpp index a98485faa..a98485faa 100644 --- a/libcutils/tests/MemsetTest.cpp +++ b/libcutils/memset_test.cpp diff --git a/libcutils/tests/multiuser_test.cpp b/libcutils/multiuser_test.cpp index 4b0fd130f..4b0fd130f 100644 --- a/libcutils/tests/multiuser_test.cpp +++ b/libcutils/multiuser_test.cpp diff --git a/libcutils/tests/PropertiesTest.cpp b/libcutils/properties_test.cpp index 79219720e..79219720e 100644 --- a/libcutils/tests/PropertiesTest.cpp +++ b/libcutils/properties_test.cpp diff --git a/libcutils/tests/sched_policy_test.cpp b/libcutils/sched_policy_test.cpp index 1f657e26b..a321c90bb 100644 --- a/libcutils/tests/sched_policy_test.cpp +++ b/libcutils/sched_policy_test.cpp @@ -90,17 +90,18 @@ TEST(SchedPolicy, set_sched_policy_timerslack) { // A measureable effect of scheduling policy is that the kernel has 800x // greater slack time in waking up a sleeping background thread. // - // Look for 100x difference in how long FB and BG threads actually sleep + // Look for 10x difference in how long FB and BG threads actually sleep // when trying to sleep for 1 ns. This difference is large enough not // to happen by chance, but small enough (compared to 800x) to keep inherent // fuzziness in scheduler behavior from causing false negatives. - const unsigned int BG_FG_SLACK_FACTOR = 100; + const unsigned int BG_FG_SLACK_FACTOR = 10; ASSERT_EQ(0, set_sched_policy(0, SP_BACKGROUND)); auto bgSleepTime = medianSleepTime(); ASSERT_EQ(0, set_sched_policy(0, SP_FOREGROUND)); auto fgSleepTime = medianSleepTime(); + ASSERT_GT(bgSleepTime, fgSleepTime * BG_FG_SLACK_FACTOR); } diff --git a/libcutils/tests/sockets_test.cpp b/libcutils/sockets_test.cpp index b762ac15e..b762ac15e 100644 --- a/libcutils/tests/sockets_test.cpp +++ b/libcutils/sockets_test.cpp diff --git a/libcutils/tests/test_str_parms.cpp b/libcutils/str_parms_test.cpp index d8f639b4b..d8f639b4b 100644 --- a/libcutils/tests/test_str_parms.cpp +++ b/libcutils/str_parms_test.cpp diff --git a/libcutils/tests/Android.bp b/libcutils/tests/Android.bp deleted file mode 100644 index 3892ce012..000000000 --- a/libcutils/tests/Android.bp +++ /dev/null @@ -1,92 +0,0 @@ -// 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. - -cc_defaults { - name: "libcutils_test_default", - srcs: ["sockets_test.cpp"], - - target: { - android: { - srcs: [ - "AshmemTest.cpp", - "fs_config.cpp", - "MemsetTest.cpp", - "PropertiesTest.cpp", - "sched_policy_test.cpp", - "trace-dev_test.cpp", - "test_str_parms.cpp", - "android_get_control_socket_test.cpp", - "android_get_control_file_test.cpp", - "multiuser_test.cpp", - ], - }, - - not_windows: { - srcs: [ - "test_str_parms.cpp", - "fs_config.cpp", - ], - }, - }, - - multilib: { - lib32: { - suffix: "32", - }, - lib64: { - suffix: "64", - }, - }, - - cflags: [ - "-Wall", - "-Wextra", - "-Werror", - ], -} - -test_libraries = [ - "libcutils", - "liblog", - "libbase", - "libjsoncpp", - "libprocessgroup", -] - -cc_test { - name: "libcutils_test", - test_suites: ["device-tests"], - defaults: ["libcutils_test_default"], - host_supported: true, - shared_libs: test_libraries, -} - -cc_test { - name: "libcutils_test_static", - test_suites: ["device-tests"], - defaults: ["libcutils_test_default"], - static_libs: ["libc"] + test_libraries, - stl: "libc++_static", - - target: { - android: { - static_executable: true, - }, - windows: { - host_ldlibs: ["-lws2_32"], - - enabled: true, - }, - }, -} diff --git a/libcutils/tests/AndroidTest.xml b/libcutils/tests/AndroidTest.xml deleted file mode 100644 index dd7aca257..000000000 --- a/libcutils/tests/AndroidTest.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2017 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. ---> -<configuration description="Config for libcutils_test"> - <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> - <option name="cleanup" value="true" /> - <option name="push" value="libcutils_test->/data/local/tmp/libcutils_test" /> - </target_preparer> - <option name="test-suite-tag" value="apct" /> - <test class="com.android.tradefed.testtype.GTest" > - <option name="native-test-device-path" value="/data/local/tmp" /> - <option name="module-name" value="libcutils_test" /> - </test> -</configuration>
\ No newline at end of file diff --git a/libcutils/tests/trace-dev_test.cpp b/libcutils/trace-dev_test.cpp index 832b36a0c..832b36a0c 100644 --- a/libcutils/tests/trace-dev_test.cpp +++ b/libcutils/trace-dev_test.cpp diff --git a/libutils/Android.bp b/libutils/Android.bp index fb7ca3254..93aa1e68c 100644 --- a/libutils/Android.bp +++ b/libutils/Android.bp @@ -195,17 +195,83 @@ cc_library { }, } -// Include subdirectory makefiles -// ============================================================ - cc_test { - name: "SharedBufferTest", + name: "libutils_test", + host_supported: true, + + srcs: [ + "BitSet_test.cpp", + "FileMap_test.cpp", + "LruCache_test.cpp", + "Mutex_test.cpp", + "SharedBuffer_test.cpp", + "Singleton_test.cpp", + "String8_test.cpp", + "StrongPointer_test.cpp", + "Unicode_test.cpp", + "Vector_test.cpp", + ], + + target: { + android: { + srcs: [ + "SystemClock_test.cpp", + ], + shared_libs: [ + "libz", + "liblog", + "libcutils", + "libutils", + "libbase", + ], + }, + linux: { + srcs: [ + "Looper_test.cpp", + "RefBase_test.cpp", + ], + }, + host: { + static_libs: [ + "libutils", + "liblog", + "libbase", + ], + }, + }, + + required: [ + "libutils_test_singleton1", + "libutils_test_singleton2", + ], + + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + "-Wthread-safety", + ], +} + +cc_test_library { + name: "libutils_test_singleton1", + host_supported: true, + relative_install_path: "libutils_test", + srcs: ["Singleton_test1.cpp"], + cflags: [ + "-Wall", + "-Werror", + ], +} + +cc_test_library { + name: "libutils_test_singleton2", host_supported: true, - static_libs: ["libutils"], - shared_libs: ["liblog"], - srcs: ["SharedBufferTest.cpp"], + relative_install_path: "libutils_test", + srcs: ["Singleton_test2.cpp"], cflags: [ "-Wall", "-Werror", ], + shared_libs: ["libutils_test_singleton1"], } diff --git a/libutils/tests/BitSet_test.cpp b/libutils/BitSet_test.cpp index fbcf02595..fbcf02595 100644 --- a/libutils/tests/BitSet_test.cpp +++ b/libutils/BitSet_test.cpp diff --git a/libutils/tests/FileMap_test.cpp b/libutils/FileMap_test.cpp index 576d89bbe..576d89bbe 100644 --- a/libutils/tests/FileMap_test.cpp +++ b/libutils/FileMap_test.cpp diff --git a/libutils/tests/Looper_test.cpp b/libutils/Looper_test.cpp index 2282ced3d..6fdc0edc9 100644 --- a/libutils/tests/Looper_test.cpp +++ b/libutils/Looper_test.cpp @@ -9,7 +9,7 @@ #include <unistd.h> #include <time.h> -#include "TestHelpers.h" +#include <utils/threads.h> // # of milliseconds to fudge stopwatch measurements #define TIMING_TOLERANCE_MS 25 @@ -23,6 +23,59 @@ enum { MSG_TEST4 = 4, }; +class Pipe { +public: + int sendFd; + int receiveFd; + + Pipe() { + int fds[2]; + ::pipe(fds); + + receiveFd = fds[0]; + sendFd = fds[1]; + } + + ~Pipe() { + if (sendFd != -1) { + ::close(sendFd); + } + + if (receiveFd != -1) { + ::close(receiveFd); + } + } + + status_t writeSignal() { + ssize_t nWritten = ::write(sendFd, "*", 1); + return nWritten == 1 ? 0 : -errno; + } + + status_t readSignal() { + char buf[1]; + ssize_t nRead = ::read(receiveFd, buf, 1); + return nRead == 1 ? 0 : nRead == 0 ? -EPIPE : -errno; + } +}; + +class DelayedTask : public Thread { + int mDelayMillis; + +public: + explicit DelayedTask(int delayMillis) : mDelayMillis(delayMillis) { } + +protected: + virtual ~DelayedTask() { } + + virtual void doTask() = 0; + + virtual bool threadLoop() { + usleep(mDelayMillis * 1000); + doTask(); + return false; + } +}; + class DelayedWake : public DelayedTask { sp<Looper> mLooper; diff --git a/libutils/tests/LruCache_test.cpp b/libutils/LruCache_test.cpp index c4d917b40..c4d917b40 100644 --- a/libutils/tests/LruCache_test.cpp +++ b/libutils/LruCache_test.cpp diff --git a/libutils/tests/Mutex_test.cpp b/libutils/Mutex_test.cpp index 8a1805f51..8a1805f51 100644 --- a/libutils/tests/Mutex_test.cpp +++ b/libutils/Mutex_test.cpp diff --git a/libutils/tests/RefBase_test.cpp b/libutils/RefBase_test.cpp index 2e0cf6e46..2e0cf6e46 100644 --- a/libutils/tests/RefBase_test.cpp +++ b/libutils/RefBase_test.cpp diff --git a/libutils/SharedBufferTest.cpp b/libutils/SharedBuffer_test.cpp index 33a4e0c90..33a4e0c90 100644 --- a/libutils/SharedBufferTest.cpp +++ b/libutils/SharedBuffer_test.cpp diff --git a/libutils/tests/Singleton_test.cpp b/libutils/Singleton_test.cpp index 9acd3c3c2..61084b0be 100644 --- a/libutils/tests/Singleton_test.cpp +++ b/libutils/Singleton_test.cpp @@ -30,15 +30,15 @@ namespace android { TEST(SingletonTest, bug35674422) { std::string path = android::base::GetExecutableDirectory(); - // libutils_tests_singleton1.so contains the ANDROID_SINGLETON_STATIC_INSTANCE + // libutils_test_singleton1.so contains the ANDROID_SINGLETON_STATIC_INSTANCE // definition of SingletonTestData, load it first. - std::string lib = android::base::StringPrintf("%s/libutils_tests_singleton1.so", path.c_str()); + std::string lib = android::base::StringPrintf("%s/libutils_test_singleton1.so", path.c_str()); void* handle1 = dlopen(lib.c_str(), RTLD_NOW); ASSERT_TRUE(handle1 != nullptr) << dlerror(); - // libutils_tests_singleton2.so references SingletonTestData but should not + // libutils_test_singleton2.so references SingletonTestData but should not // have a definition - lib = android::base::StringPrintf("%s/libutils_tests_singleton2.so", path.c_str()); + lib = android::base::StringPrintf("%s/libutils_test_singleton2.so", path.c_str()); void* handle2 = dlopen(lib.c_str(), RTLD_NOW); ASSERT_TRUE(handle2 != nullptr) << dlerror(); diff --git a/libutils/tests/Singleton_test.h b/libutils/Singleton_test.h index c77d9ffe6..c77d9ffe6 100644 --- a/libutils/tests/Singleton_test.h +++ b/libutils/Singleton_test.h diff --git a/libutils/tests/Singleton_test1.cpp b/libutils/Singleton_test1.cpp index 4a91ec08a..4a91ec08a 100644 --- a/libutils/tests/Singleton_test1.cpp +++ b/libutils/Singleton_test1.cpp diff --git a/libutils/tests/Singleton_test2.cpp b/libutils/Singleton_test2.cpp index eb2a9dfc0..eb2a9dfc0 100644 --- a/libutils/tests/Singleton_test2.cpp +++ b/libutils/Singleton_test2.cpp diff --git a/libutils/tests/String8_test.cpp b/libutils/String8_test.cpp index 3947a5fb9..3947a5fb9 100644 --- a/libutils/tests/String8_test.cpp +++ b/libutils/String8_test.cpp diff --git a/libutils/tests/StrongPointer_test.cpp b/libutils/StrongPointer_test.cpp index 153cf9683..153cf9683 100644 --- a/libutils/tests/StrongPointer_test.cpp +++ b/libutils/StrongPointer_test.cpp diff --git a/libutils/tests/SystemClock_test.cpp b/libutils/SystemClock_test.cpp index 5ad060b04..5ad060b04 100644 --- a/libutils/tests/SystemClock_test.cpp +++ b/libutils/SystemClock_test.cpp diff --git a/libutils/tests/Unicode_test.cpp b/libutils/Unicode_test.cpp index b92eef866..b92eef866 100644 --- a/libutils/tests/Unicode_test.cpp +++ b/libutils/Unicode_test.cpp diff --git a/libutils/tests/Vector_test.cpp b/libutils/Vector_test.cpp index 5336c40c3..5336c40c3 100644 --- a/libutils/tests/Vector_test.cpp +++ b/libutils/Vector_test.cpp diff --git a/libutils/tests/Android.bp b/libutils/tests/Android.bp deleted file mode 100644 index 62f5acb4e..000000000 --- a/libutils/tests/Android.bp +++ /dev/null @@ -1,97 +0,0 @@ -// -// 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. - -cc_test { - name: "libutils_tests", - host_supported: true, - - srcs: [ - "BitSet_test.cpp", - "FileMap_test.cpp", - "LruCache_test.cpp", - "Mutex_test.cpp", - "Singleton_test.cpp", - "String8_test.cpp", - "StrongPointer_test.cpp", - "Unicode_test.cpp", - "Vector_test.cpp", - ], - - target: { - android: { - srcs: [ - "SystemClock_test.cpp", - ], - shared_libs: [ - "libz", - "liblog", - "libcutils", - "libutils", - "libbase", - ], - }, - linux: { - srcs: [ - "Looper_test.cpp", - "RefBase_test.cpp", - ], - }, - host: { - static_libs: [ - "libutils", - "liblog", - "libbase", - ], - }, - }, - - required: [ - "libutils_tests_singleton1", - "libutils_tests_singleton2", - ], - - cflags: [ - "-Wall", - "-Wextra", - "-Werror", - "-Wthread-safety", - ], -} - -cc_test_library { - name: "libutils_tests_singleton1", - host_supported: true, - relative_install_path: "libutils_tests", - srcs: ["Singleton_test1.cpp"], - cflags: [ - "-Wall", - "-Werror", - ], -} - -cc_test_library { - name: "libutils_tests_singleton2", - host_supported: true, - relative_install_path: "libutils_tests", - srcs: ["Singleton_test2.cpp"], - cflags: [ - "-Wall", - "-Werror", - ], - shared_libs: ["libutils_tests_singleton1"], -} diff --git a/libutils/tests/README.txt b/libutils/tests/README.txt deleted file mode 100644 index ad54e577b..000000000 --- a/libutils/tests/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -Run device tests: - -mma -j<whatever> -(after adb root; adb disable-verity; adb reboot) -adb root -adb remount -adb sync -adb shell /data/nativetest/libutils_tests/libutils_tests diff --git a/libutils/tests/TestHelpers.h b/libutils/tests/TestHelpers.h deleted file mode 100644 index 6801cd739..000000000 --- a/libutils/tests/TestHelpers.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef TESTHELPERS_H -#define TESTHELPERS_H - -#include <utils/threads.h> - -namespace android { - -class Pipe { -public: - int sendFd; - int receiveFd; - - Pipe() { - int fds[2]; - ::pipe(fds); - - receiveFd = fds[0]; - sendFd = fds[1]; - } - - ~Pipe() { - if (sendFd != -1) { - ::close(sendFd); - } - - if (receiveFd != -1) { - ::close(receiveFd); - } - } - - status_t writeSignal() { - ssize_t nWritten = ::write(sendFd, "*", 1); - return nWritten == 1 ? 0 : -errno; - } - - status_t readSignal() { - char buf[1]; - ssize_t nRead = ::read(receiveFd, buf, 1); - return nRead == 1 ? 0 : nRead == 0 ? -EPIPE : -errno; - } -}; - -class DelayedTask : public Thread { - int mDelayMillis; - -public: - explicit DelayedTask(int delayMillis) : mDelayMillis(delayMillis) { } - -protected: - virtual ~DelayedTask() { } - - virtual void doTask() = 0; - - virtual bool threadLoop() { - usleep(mDelayMillis * 1000); - doTask(); - return false; - } -}; - -} // namespace android - -#endif // TESTHELPERS_H |
