summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2017-03-17 12:29:41 -0500
committerMark Salyzyn2017-03-17 12:41:39 -0500
commit57075240038be316a6a08a5e4a627ddf73740b4a (patch)
tree9d092abbe2d0b634788d3e98ef3cc6b0a4391f71 /liblog/tests
parentcc404b51fc424cbb786abce8b8f36b1dce1c0ab9 (diff)
downloadplatform-system-core-57075240038be316a6a08a5e4a627ddf73740b4a.tar.gz
platform-system-core-57075240038be316a6a08a5e4a627ddf73740b4a.tar.xz
platform-system-core-57075240038be316a6a08a5e4a627ddf73740b4a.zip
liblog: test: *.android_errorWriteWithinfoLog__android_logger_list_read__*
We would experience failures as test runs interfere with each other. Create a unique tag for each test run signature. Switch from using TEST_PREFIX to TEST_LOGGER to identify the logger transport being inspected and make that part of the signature. Make sure 32 bit and 64 bit tests do not interfere. Test: gTest liblog-unit-tests cts-tradefed run cts -m CtsLiblogTestCases Bug: 36232924 Change-Id: I4d58242e5ef8e68e2d4b27cecf538938e17acf3f
Diffstat (limited to 'liblog/tests')
-rw-r--r--liblog/tests/liblog_test.cpp28
-rw-r--r--liblog/tests/liblog_test_default.cpp2
-rw-r--r--liblog/tests/liblog_test_local.cpp2
-rw-r--r--liblog/tests/liblog_test_stderr.cpp2
-rw-r--r--liblog/tests/liblog_test_stderr_local.cpp2
5 files changed, 24 insertions, 12 deletions
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index e68c8f23f..cc95425a9 100644
--- a/liblog/tests/liblog_test.cpp
+++ b/liblog/tests/liblog_test.cpp
@@ -42,7 +42,10 @@
42#include <private/android_logger.h> 42#include <private/android_logger.h>
43 43
44#ifndef TEST_PREFIX 44#ifndef TEST_PREFIX
45#ifdef __ANDROID__ // make sure we always run code if compiled for android 45#ifdef TEST_LOGGER
46#define TEST_PREFIX android_set_log_transport(TEST_LOGGER);
47// make sure we always run code despite overrides if compiled for android
48#elif defined(__ANDROID__)
46#define TEST_PREFIX 49#define TEST_PREFIX
47#endif 50#endif
48#endif 51#endif
@@ -2137,10 +2140,19 @@ static void android_errorWriteWithInfoLog_helper(int TAG, const char* SUBTAG,
2137} 2140}
2138#endif 2141#endif
2139 2142
2143// Make multiple tests and re-tests orthogonal to prevent falsing.
2144#ifdef TEST_LOGGER
2145#define UNIQUE_TAG(X) \
2146 (0x12340000 + (((X) + sizeof(int) + sizeof(void*)) << 8) + TEST_LOGGER)
2147#else
2148#define UNIQUE_TAG(X) \
2149 (0x12340000 + (((X) + sizeof(int) + sizeof(void*)) << 8) + 0xBA)
2150#endif
2151
2140TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__typical) { 2152TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__typical) {
2141#ifdef TEST_PREFIX 2153#ifdef TEST_PREFIX
2142 int count; 2154 int count;
2143 android_errorWriteWithInfoLog_helper(123456781, "test-subtag", -1, 2155 android_errorWriteWithInfoLog_helper(UNIQUE_TAG(1), "test-subtag", -1,
2144 max_payload_buf, 200, count); 2156 max_payload_buf, 200, count);
2145 EXPECT_EQ(SUPPORTS_END_TO_END, count); 2157 EXPECT_EQ(SUPPORTS_END_TO_END, count);
2146#else 2158#else
@@ -2152,7 +2164,7 @@ TEST(liblog,
2152 android_errorWriteWithInfoLog__android_logger_list_read__data_too_large) { 2164 android_errorWriteWithInfoLog__android_logger_list_read__data_too_large) {
2153#ifdef TEST_PREFIX 2165#ifdef TEST_PREFIX
2154 int count; 2166 int count;
2155 android_errorWriteWithInfoLog_helper(123456782, "test-subtag", -1, 2167 android_errorWriteWithInfoLog_helper(UNIQUE_TAG(2), "test-subtag", -1,
2156 max_payload_buf, sizeof(max_payload_buf), 2168 max_payload_buf, sizeof(max_payload_buf),
2157 count); 2169 count);
2158 EXPECT_EQ(SUPPORTS_END_TO_END, count); 2170 EXPECT_EQ(SUPPORTS_END_TO_END, count);
@@ -2165,8 +2177,8 @@ TEST(liblog,
2165 android_errorWriteWithInfoLog__android_logger_list_read__null_data) { 2177 android_errorWriteWithInfoLog__android_logger_list_read__null_data) {
2166#ifdef TEST_PREFIX 2178#ifdef TEST_PREFIX
2167 int count; 2179 int count;
2168 android_errorWriteWithInfoLog_helper(123456783, "test-subtag", -1, NULL, 200, 2180 android_errorWriteWithInfoLog_helper(UNIQUE_TAG(3), "test-subtag", -1, NULL,
2169 count); 2181 200, count);
2170 EXPECT_EQ(0, count); 2182 EXPECT_EQ(0, count);
2171#else 2183#else
2172 GTEST_LOG_(INFO) << "This test does nothing.\n"; 2184 GTEST_LOG_(INFO) << "This test does nothing.\n";
@@ -2178,7 +2190,7 @@ TEST(liblog,
2178#ifdef TEST_PREFIX 2190#ifdef TEST_PREFIX
2179 int count; 2191 int count;
2180 android_errorWriteWithInfoLog_helper( 2192 android_errorWriteWithInfoLog_helper(
2181 123456784, "abcdefghijklmnopqrstuvwxyz now i know my abc", -1, 2193 UNIQUE_TAG(4), "abcdefghijklmnopqrstuvwxyz now i know my abc", -1,
2182 max_payload_buf, 200, count); 2194 max_payload_buf, 200, count);
2183 EXPECT_EQ(SUPPORTS_END_TO_END, count); 2195 EXPECT_EQ(SUPPORTS_END_TO_END, count);
2184#else 2196#else
@@ -2313,7 +2325,7 @@ static void android_errorWriteLog_helper(int TAG, const char* SUBTAG,
2313TEST(liblog, android_errorWriteLog__android_logger_list_read__success) { 2325TEST(liblog, android_errorWriteLog__android_logger_list_read__success) {
2314#ifdef TEST_PREFIX 2326#ifdef TEST_PREFIX
2315 int count; 2327 int count;
2316 android_errorWriteLog_helper(123456785, "test-subtag", count); 2328 android_errorWriteLog_helper(UNIQUE_TAG(5), "test-subtag", count);
2317 EXPECT_EQ(SUPPORTS_END_TO_END, count); 2329 EXPECT_EQ(SUPPORTS_END_TO_END, count);
2318#else 2330#else
2319 GTEST_LOG_(INFO) << "This test does nothing.\n"; 2331 GTEST_LOG_(INFO) << "This test does nothing.\n";
@@ -2323,7 +2335,7 @@ TEST(liblog, android_errorWriteLog__android_logger_list_read__success) {
2323TEST(liblog, android_errorWriteLog__android_logger_list_read__null_subtag) { 2335TEST(liblog, android_errorWriteLog__android_logger_list_read__null_subtag) {
2324#ifdef TEST_PREFIX 2336#ifdef TEST_PREFIX
2325 int count; 2337 int count;
2326 android_errorWriteLog_helper(123456786, NULL, count); 2338 android_errorWriteLog_helper(UNIQUE_TAG(6), NULL, count);
2327 EXPECT_EQ(0, count); 2339 EXPECT_EQ(0, count);
2328#else 2340#else
2329 GTEST_LOG_(INFO) << "This test does nothing.\n"; 2341 GTEST_LOG_(INFO) << "This test does nothing.\n";
diff --git a/liblog/tests/liblog_test_default.cpp b/liblog/tests/liblog_test_default.cpp
index cbd0d259e..9fc443c28 100644
--- a/liblog/tests/liblog_test_default.cpp
+++ b/liblog/tests/liblog_test_default.cpp
@@ -1,5 +1,5 @@
1#ifdef __ANDROID__ 1#ifdef __ANDROID__
2#include <log/log_transport.h> 2#include <log/log_transport.h>
3#define TEST_PREFIX android_set_log_transport(LOGGER_DEFAULT); 3#define TEST_LOGGER LOGGER_DEFAULT
4#endif 4#endif
5#include "liblog_test.cpp" 5#include "liblog_test.cpp"
diff --git a/liblog/tests/liblog_test_local.cpp b/liblog/tests/liblog_test_local.cpp
index 9d7b3d7c9..451beca54 100644
--- a/liblog/tests/liblog_test_local.cpp
+++ b/liblog/tests/liblog_test_local.cpp
@@ -1,4 +1,4 @@
1#include <log/log_transport.h> 1#include <log/log_transport.h>
2#define liblog liblog_local 2#define liblog liblog_local
3#define TEST_PREFIX android_set_log_transport(LOGGER_LOCAL); 3#define TEST_LOGGER LOGGER_LOCAL
4#include "liblog_test.cpp" 4#include "liblog_test.cpp"
diff --git a/liblog/tests/liblog_test_stderr.cpp b/liblog/tests/liblog_test_stderr.cpp
index f9e4e1f9b..abc1b9c3e 100644
--- a/liblog/tests/liblog_test_stderr.cpp
+++ b/liblog/tests/liblog_test_stderr.cpp
@@ -1,5 +1,5 @@
1#include <log/log_transport.h> 1#include <log/log_transport.h>
2#define liblog liblog_stderr 2#define liblog liblog_stderr
3#define TEST_PREFIX android_set_log_transport(LOGGER_STDERR); 3#define TEST_LOGGER LOGGER_STDERR
4#define USING_LOGGER_STDERR 4#define USING_LOGGER_STDERR
5#include "liblog_test.cpp" 5#include "liblog_test.cpp"
diff --git a/liblog/tests/liblog_test_stderr_local.cpp b/liblog/tests/liblog_test_stderr_local.cpp
index 21406ca0a..bb5c7aebc 100644
--- a/liblog/tests/liblog_test_stderr_local.cpp
+++ b/liblog/tests/liblog_test_stderr_local.cpp
@@ -1,4 +1,4 @@
1#include <log/log_transport.h> 1#include <log/log_transport.h>
2#define liblog liblog_stderr_local 2#define liblog liblog_stderr_local
3#define TEST_PREFIX android_set_log_transport(LOGGER_LOCAL | LOGGER_STDERR); 3#define TEST_LOGGER (LOGGER_LOCAL | LOGGER_STDERR)
4#include "liblog_test.cpp" 4#include "liblog_test.cpp"