liblog: android_log_isloggable failing apct

(cherry pick from commit efe8ecc1d9)

- periodic failures in apct, dropped second serial test
  in refresh_cache, trusting check_cache or global.
- The retry loop to see if is_loggable recovers of 1000
  was hiding subsequent tests, drop to 10 retries.
- On the whole, the average performance remains the same.

Bug: 25792367
Change-Id: I4110440ef46671d7a1c128689bde623808bed04f
This commit is contained in:
Mark Salyzyn 2016-04-14 15:31:56 -07:00
parent a9e818f463
commit 504daa654e
2 changed files with 15 additions and 21 deletions

View File

@ -63,7 +63,6 @@ static int check_cache(struct cache *cache)
static void refresh_cache(struct cache *cache, const char *key)
{
uint32_t serial;
char buf[PROP_VALUE_MAX];
if (!cache->pinfo) {
@ -71,13 +70,8 @@ static void refresh_cache(struct cache *cache, const char *key)
if (!cache->pinfo) {
return;
}
cache->serial = -1;
}
serial = __system_property_serial(cache->pinfo);
if (serial == cache->serial) {
return;
}
cache->serial = serial;
cache->serial = __system_property_serial(cache->pinfo);
__system_property_read(cache->pinfo, 0, buf);
switch(buf[0]) {
case 't': case 'T':

View File

@ -1277,7 +1277,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, levels[j].level));
}
@ -1286,7 +1286,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, levels[j].level));
}
@ -1318,7 +1318,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1327,7 +1327,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1347,7 +1347,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1356,7 +1356,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1378,7 +1378,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1387,7 +1387,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1407,7 +1407,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1416,7 +1416,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1452,7 +1452,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1461,7 +1461,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1481,7 +1481,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1490,7 +1490,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}