Make sure that the same tests are on all platforms.
In order to be able to generate a list of tests for cts, the same set of tests must exist across all platforms. This CL adds empty tests where a test was conditionally compiled out. This CL creates a single library libBionicTests that includes all of the tests found in bionic-unit-tests-static. Also fix a few missing include files in some test files. Tested by running and compiling the tests for every platform and verifying the same number of tests are on each platform. Change-Id: I9989d4bfebb0f9c409a0ce7e87169299eac605a2
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
|
||||
#if __BIONIC__
|
||||
#if defined(__BIONIC__)
|
||||
|
||||
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
|
||||
#include <sys/_system_properties.h>
|
||||
@@ -69,7 +69,54 @@ private:
|
||||
void *old_pa;
|
||||
};
|
||||
|
||||
static void foreach_test_callback(const prop_info *pi, void* cookie) {
|
||||
size_t *count = static_cast<size_t *>(cookie);
|
||||
|
||||
ASSERT_NE((prop_info *)NULL, pi);
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
static void hierarchical_test_callback(const prop_info *pi, void *cookie) {
|
||||
bool (*ok)[8][8] = static_cast<bool (*)[8][8]>(cookie);
|
||||
|
||||
char name[PROP_NAME_MAX];
|
||||
char value[PROP_VALUE_MAX];
|
||||
|
||||
__system_property_read(pi, name, value);
|
||||
|
||||
int name_i, name_j, name_k;
|
||||
int value_i, value_j, value_k;
|
||||
ASSERT_EQ(3, sscanf(name, "property_%d.%d.%d", &name_i, &name_j, &name_k));
|
||||
ASSERT_EQ(3, sscanf(value, "value_%d.%d.%d", &value_i, &value_j, &value_k));
|
||||
ASSERT_EQ(name_i, value_i);
|
||||
ASSERT_GE(name_i, 0);
|
||||
ASSERT_LT(name_i, 8);
|
||||
ASSERT_EQ(name_j, value_j);
|
||||
ASSERT_GE(name_j, 0);
|
||||
ASSERT_LT(name_j, 8);
|
||||
ASSERT_EQ(name_k, value_k);
|
||||
ASSERT_GE(name_k, 0);
|
||||
ASSERT_LT(name_k, 8);
|
||||
|
||||
ok[name_i][name_j][name_k] = true;
|
||||
}
|
||||
|
||||
static void *PropertyWaitHelperFn(void *arg) {
|
||||
int *flag = (int *)arg;
|
||||
prop_info *pi;
|
||||
pi = (prop_info *)__system_property_find("property");
|
||||
usleep(100000);
|
||||
|
||||
*flag = 1;
|
||||
__system_property_update(pi, "value3", 6);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // __BIONIC__
|
||||
|
||||
TEST(properties, add) {
|
||||
#if defined(__BIONIC__)
|
||||
LocalPropertyTestState pa;
|
||||
ASSERT_TRUE(pa.valid);
|
||||
|
||||
@@ -87,9 +134,13 @@ TEST(properties, add) {
|
||||
|
||||
ASSERT_EQ(6, __system_property_get("property_other", propvalue));
|
||||
ASSERT_STREQ(propvalue, "value3");
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
TEST(properties, update) {
|
||||
#if defined(__BIONIC__)
|
||||
LocalPropertyTestState pa;
|
||||
ASSERT_TRUE(pa.valid);
|
||||
|
||||
@@ -120,9 +171,13 @@ TEST(properties, update) {
|
||||
|
||||
ASSERT_EQ(6, __system_property_get("property_other", propvalue));
|
||||
ASSERT_STREQ(propvalue, "value6");
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
TEST(properties, fill) {
|
||||
#if defined(__BIONIC__)
|
||||
LocalPropertyTestState pa;
|
||||
ASSERT_TRUE(pa.valid);
|
||||
char prop_name[PROP_NAME_MAX];
|
||||
@@ -161,16 +216,13 @@ TEST(properties, fill) {
|
||||
ASSERT_EQ(PROP_VALUE_MAX - 1, __system_property_get(prop_name, prop_value_ret));
|
||||
ASSERT_EQ(0, memcmp(prop_value, prop_value_ret, PROP_VALUE_MAX));
|
||||
}
|
||||
}
|
||||
|
||||
static void foreach_test_callback(const prop_info *pi, void* cookie) {
|
||||
size_t *count = static_cast<size_t *>(cookie);
|
||||
|
||||
ASSERT_NE((prop_info *)NULL, pi);
|
||||
(*count)++;
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
TEST(properties, foreach) {
|
||||
#if defined(__BIONIC__)
|
||||
LocalPropertyTestState pa;
|
||||
ASSERT_TRUE(pa.valid);
|
||||
size_t count = 0;
|
||||
@@ -181,9 +233,13 @@ TEST(properties, foreach) {
|
||||
|
||||
ASSERT_EQ(0, __system_property_foreach(foreach_test_callback, &count));
|
||||
ASSERT_EQ(3U, count);
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
TEST(properties, find_nth) {
|
||||
#if defined(__BIONIC__)
|
||||
LocalPropertyTestState pa;
|
||||
ASSERT_TRUE(pa.valid);
|
||||
|
||||
@@ -201,34 +257,13 @@ TEST(properties, find_nth) {
|
||||
ASSERT_EQ((const prop_info *)NULL, __system_property_find_nth(100));
|
||||
ASSERT_EQ((const prop_info *)NULL, __system_property_find_nth(200));
|
||||
ASSERT_EQ((const prop_info *)NULL, __system_property_find_nth(247));
|
||||
}
|
||||
|
||||
static void hierarchical_test_callback(const prop_info *pi, void *cookie) {
|
||||
bool (*ok)[8][8] = static_cast<bool (*)[8][8]>(cookie);
|
||||
|
||||
char name[PROP_NAME_MAX];
|
||||
char value[PROP_VALUE_MAX];
|
||||
|
||||
__system_property_read(pi, name, value);
|
||||
|
||||
int name_i, name_j, name_k;
|
||||
int value_i, value_j, value_k;
|
||||
ASSERT_EQ(3, sscanf(name, "property_%d.%d.%d", &name_i, &name_j, &name_k));
|
||||
ASSERT_EQ(3, sscanf(value, "value_%d.%d.%d", &value_i, &value_j, &value_k));
|
||||
ASSERT_EQ(name_i, value_i);
|
||||
ASSERT_GE(name_i, 0);
|
||||
ASSERT_LT(name_i, 8);
|
||||
ASSERT_EQ(name_j, value_j);
|
||||
ASSERT_GE(name_j, 0);
|
||||
ASSERT_LT(name_j, 8);
|
||||
ASSERT_EQ(name_k, value_k);
|
||||
ASSERT_GE(name_k, 0);
|
||||
ASSERT_LT(name_k, 8);
|
||||
|
||||
ok[name_i][name_j][name_k] = true;
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
TEST(properties, fill_hierarchical) {
|
||||
#if defined(__BIONIC__)
|
||||
LocalPropertyTestState pa;
|
||||
ASSERT_TRUE(pa.valid);
|
||||
char prop_name[PROP_NAME_MAX];
|
||||
@@ -279,9 +314,13 @@ TEST(properties, fill_hierarchical) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
TEST(properties, errors) {
|
||||
#if defined(__BIONIC__)
|
||||
LocalPropertyTestState pa;
|
||||
ASSERT_TRUE(pa.valid);
|
||||
char prop_value[PROP_NAME_MAX];
|
||||
@@ -296,9 +335,13 @@ TEST(properties, errors) {
|
||||
ASSERT_EQ(-1, __system_property_add("name", PROP_NAME_MAX, "value", 5));
|
||||
ASSERT_EQ(-1, __system_property_add("name", 4, "value", PROP_VALUE_MAX));
|
||||
ASSERT_EQ(-1, __system_property_update(NULL, "value", PROP_VALUE_MAX));
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
TEST(properties, serial) {
|
||||
#if defined(__BIONIC__)
|
||||
LocalPropertyTestState pa;
|
||||
ASSERT_TRUE(pa.valid);
|
||||
const prop_info *pi;
|
||||
@@ -309,22 +352,13 @@ TEST(properties, serial) {
|
||||
serial = __system_property_serial(pi);
|
||||
ASSERT_EQ(0, __system_property_update((prop_info *)pi, "value2", 6));
|
||||
ASSERT_NE(serial, __system_property_serial(pi));
|
||||
}
|
||||
|
||||
static void *PropertyWaitHelperFn(void *arg)
|
||||
{
|
||||
int *flag = (int *)arg;
|
||||
prop_info *pi;
|
||||
pi = (prop_info *)__system_property_find("property");
|
||||
usleep(100000);
|
||||
|
||||
*flag = 1;
|
||||
__system_property_update(pi, "value3", 6);
|
||||
|
||||
return NULL;
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
TEST(properties, wait) {
|
||||
#if defined(__BIONIC__)
|
||||
LocalPropertyTestState pa;
|
||||
ASSERT_TRUE(pa.valid);
|
||||
unsigned int serial;
|
||||
@@ -346,6 +380,9 @@ TEST(properties, wait) {
|
||||
|
||||
void* result;
|
||||
ASSERT_EQ(0, pthread_join(t, &result));
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
class KilledByFault {
|
||||
@@ -362,6 +399,7 @@ bool KilledByFault::operator()(int exit_status) const {
|
||||
}
|
||||
|
||||
TEST(properties_DeathTest, read_only) {
|
||||
#if defined(__BIONIC__)
|
||||
::testing::FLAGS_gtest_death_test_style = "threadsafe";
|
||||
|
||||
// This test only makes sense if we're talking to the real system property service.
|
||||
@@ -371,6 +409,7 @@ TEST(properties_DeathTest, read_only) {
|
||||
}
|
||||
|
||||
ASSERT_EXIT(__system_property_add("property", 8, "value", 5), KilledByFault(), "");
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user