diff options
author | Samip Garg <samgarg@google.com> | 2023-01-11 15:14:42 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-01-11 15:14:42 +0000 |
commit | 8db32c19ad1c69fa9969a300df8351f3264368e2 (patch) | |
tree | 6c836afde11cf68af8e67f35712a12e597fd649f | |
parent | 3faa5e73198743703a2f1023d0df78f1a786f72a (diff) | |
parent | 28e71b61c60e69efbc6331690f007f5351b9422d (diff) | |
download | bionic-8db32c19ad1c69fa9969a300df8351f3264368e2.tar.gz |
Snap tm-dev to android13-tests-dev am: 28e71b61c6
Original change: https://googleplex-android-review.googlesource.com/c/platform/bionic/+/20514346
Change-Id: I5219b49e6c948cb816092bc09bb3dda7a2df2ac3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | tests/grp_pwd_test.cpp | 11 | ||||
-rw-r--r-- | tests/heap_tagging_level_test.cpp | 1 | ||||
-rw-r--r-- | tests/mntent_test.cpp | 30 | ||||
-rw-r--r-- | tests/stack_protector_test_helper.cpp | 7 |
4 files changed, 39 insertions, 10 deletions
diff --git a/tests/grp_pwd_test.cpp b/tests/grp_pwd_test.cpp index bf65720f9..65a54a659 100644 --- a/tests/grp_pwd_test.cpp +++ b/tests/grp_pwd_test.cpp @@ -441,6 +441,17 @@ static void expect_ids(T ids, bool is_group) { } return result; }; + + // AID_PRNG_SEEDER (1092) was added in TM-QPR2, but CTS is shared + // across Android 13 versions so we may or may not find it in this + // test (b/253185870). + if (android::base::GetIntProperty("ro.build.version.sdk", 0) == __ANDROID_API_T__) { +#ifndef AID_PRNG_SEEDER +#define AID_PRNG_SEEDER 1092 +#endif + ids.erase(AID_PRNG_SEEDER); + expected_ids.erase(AID_PRNG_SEEDER); + } EXPECT_EQ(expected_ids, ids) << return_differences(); } #endif diff --git a/tests/heap_tagging_level_test.cpp b/tests/heap_tagging_level_test.cpp index 96c2ffd0b..ae678b7b5 100644 --- a/tests/heap_tagging_level_test.cpp +++ b/tests/heap_tagging_level_test.cpp @@ -222,6 +222,7 @@ class MemtagNoteTest : public testing::TestWithParam<std::tuple<MemtagNote, bool TEST_P(MemtagNoteTest, SEGV) { #if defined(__BIONIC__) && defined(__aarch64__) + SKIP_WITH_NATIVE_BRIDGE; // http://b/242170715 // Note that we do not check running_with_hwasan() - what matters here is whether the test binary // itself is built with HWASan. bool withHWASAN = __has_feature(hwaddress_sanitizer); diff --git a/tests/mntent_test.cpp b/tests/mntent_test.cpp index b86af9fb6..4b8fc9a80 100644 --- a/tests/mntent_test.cpp +++ b/tests/mntent_test.cpp @@ -19,24 +19,40 @@ #include <mntent.h> TEST(mntent, mntent_smoke) { + // Read all the entries with getmntent(). FILE* fp = setmntent("/proc/mounts", "r"); ASSERT_TRUE(fp != nullptr); - ASSERT_TRUE(getmntent(fp) != nullptr); + std::vector<std::string> fsnames; + std::vector<std::string> dirs; + mntent* me; + while ((me = getmntent(fp)) != nullptr) { + fsnames.push_back(me->mnt_fsname); + dirs.push_back(me->mnt_dir); + } + + ASSERT_EQ(1, endmntent(fp)); - bool saw_proc = false; + // Then again with getmntent_r(), checking they match. + fp = setmntent("/proc/mounts", "r"); + ASSERT_TRUE(fp != nullptr); struct mntent entry; char buf[BUFSIZ]; + size_t i = 0; while (getmntent_r(fp, &entry, buf, sizeof(buf)) != nullptr) { - if (strcmp(entry.mnt_fsname, "proc") == 0 && strcmp(entry.mnt_dir, "/proc") == 0) { - saw_proc = true; - } + ASSERT_EQ(fsnames[i], entry.mnt_fsname); + ASSERT_EQ(dirs[i], entry.mnt_dir); + i++; } - ASSERT_TRUE(saw_proc); - ASSERT_EQ(1, endmntent(fp)); + + // And just for good measure: we did see a /proc entry, right? + auto it = std::find(fsnames.begin(), fsnames.end(), "proc"); + ASSERT_TRUE(it != fsnames.end()); + size_t proc_index = it - fsnames.begin(); + ASSERT_EQ("/proc", dirs[proc_index]); } TEST(mntent, hasmntopt) { diff --git a/tests/stack_protector_test_helper.cpp b/tests/stack_protector_test_helper.cpp index fd90b939b..eddd94074 100644 --- a/tests/stack_protector_test_helper.cpp +++ b/tests/stack_protector_test_helper.cpp @@ -19,7 +19,8 @@ __attribute__((noinline)) void modify_stack_protector_test() { // We can't use memset here because it's fortified, and we want to test // the line of defense *after* that. // Without volatile, the generic x86/x86-64 targets don't write to the stack. - volatile char* p; - p = reinterpret_cast<volatile char*>(&p + 1); - *p = '\0'; + // We can't make a constant change, since the existing byte might already have + // had that value. + volatile char* p = reinterpret_cast<volatile char*>(&p + 1); + *p = ~*p; } |