Merge "snapuserd: Use GTEST_SKIP in snapuserd_test." into main am: a7ce1a5975
Original change: https://android-review.googlesource.com/c/platform/system/core/+/3363449 Change-Id: I7c269dfac4307039e51ecb59280dc6d8616d80e1 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
6e61d69779
1 changed files with 34 additions and 8 deletions
|
|
@ -82,6 +82,8 @@ class SnapuserdTestBase : public ::testing::TestWithParam<TestParam> {
|
|||
|
||||
unique_fd GetCowFd() { return unique_fd{dup(cow_system_->fd)}; }
|
||||
|
||||
bool ShouldSkipSetUp();
|
||||
|
||||
std::unique_ptr<ITestHarness> harness_;
|
||||
size_t size_ = 10_MiB;
|
||||
int total_base_size_ = 0;
|
||||
|
|
@ -97,6 +99,10 @@ class SnapuserdTestBase : public ::testing::TestWithParam<TestParam> {
|
|||
};
|
||||
|
||||
void SnapuserdTestBase::SetUp() {
|
||||
if (ShouldSkipSetUp()) {
|
||||
GTEST_SKIP() << "snapuserd not supported on this device";
|
||||
}
|
||||
|
||||
#if __ANDROID__
|
||||
harness_ = std::make_unique<DmUserTestHarness>();
|
||||
#else
|
||||
|
|
@ -104,6 +110,16 @@ void SnapuserdTestBase::SetUp() {
|
|||
#endif
|
||||
}
|
||||
|
||||
bool SnapuserdTestBase::ShouldSkipSetUp() {
|
||||
#ifdef __ANDROID__
|
||||
if (!android::snapshot::CanUseUserspaceSnapshots() ||
|
||||
android::snapshot::IsVendorFromAndroid12()) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void SnapuserdTestBase::TearDown() {
|
||||
cow_system_ = nullptr;
|
||||
}
|
||||
|
|
@ -302,6 +318,9 @@ class SnapuserdTest : public SnapuserdTestBase {
|
|||
};
|
||||
|
||||
void SnapuserdTest::SetUp() {
|
||||
if (ShouldSkipSetUp()) {
|
||||
GTEST_SKIP() << "snapuserd not supported on this device";
|
||||
}
|
||||
ASSERT_NO_FATAL_FAILURE(SnapuserdTestBase::SetUp());
|
||||
handlers_ = std::make_unique<SnapshotHandlerManager>();
|
||||
}
|
||||
|
|
@ -312,6 +331,9 @@ void SnapuserdTest::TearDown() {
|
|||
}
|
||||
|
||||
void SnapuserdTest::Shutdown() {
|
||||
if (!handlers_) {
|
||||
return;
|
||||
}
|
||||
if (dmuser_dev_) {
|
||||
ASSERT_TRUE(dmuser_dev_->Destroy());
|
||||
}
|
||||
|
|
@ -1181,6 +1203,9 @@ void SnapuserdVariableBlockSizeTest::ReadSnapshotWithVariableBlockSize() {
|
|||
}
|
||||
|
||||
void SnapuserdVariableBlockSizeTest::SetUp() {
|
||||
if (ShouldSkipSetUp()) {
|
||||
GTEST_SKIP() << "snapuserd not supported on this device";
|
||||
}
|
||||
ASSERT_NO_FATAL_FAILURE(SnapuserdTest::SetUp());
|
||||
}
|
||||
|
||||
|
|
@ -1244,6 +1269,9 @@ void HandlerTest::InitializeDevice() {
|
|||
}
|
||||
|
||||
void HandlerTest::SetUp() {
|
||||
if (ShouldSkipSetUp()) {
|
||||
GTEST_SKIP() << "snapuserd not supported on this device";
|
||||
}
|
||||
ASSERT_NO_FATAL_FAILURE(SnapuserdTestBase::SetUp());
|
||||
ASSERT_NO_FATAL_FAILURE(CreateBaseDevice());
|
||||
ASSERT_NO_FATAL_FAILURE(SetUpV2Cow());
|
||||
|
|
@ -1251,6 +1279,9 @@ void HandlerTest::SetUp() {
|
|||
}
|
||||
|
||||
void HandlerTest::TearDown() {
|
||||
if (ShouldSkipSetUp()) {
|
||||
return;
|
||||
}
|
||||
ASSERT_TRUE(factory_.DeleteQueue(system_device_ctrl_name_));
|
||||
ASSERT_TRUE(handler_thread_.get());
|
||||
SnapuserdTestBase::TearDown();
|
||||
|
|
@ -1326,6 +1357,9 @@ class HandlerTestV3 : public HandlerTest {
|
|||
};
|
||||
|
||||
void HandlerTestV3::SetUp() {
|
||||
if (ShouldSkipSetUp()) {
|
||||
GTEST_SKIP() << "snapuserd not supported on this device";
|
||||
}
|
||||
ASSERT_NO_FATAL_FAILURE(SnapuserdTestBase::SetUp());
|
||||
ASSERT_NO_FATAL_FAILURE(CreateBaseDevice());
|
||||
ASSERT_NO_FATAL_FAILURE(SetUpV3Cow());
|
||||
|
|
@ -1530,14 +1564,6 @@ INSTANTIATE_TEST_SUITE_P(Io, HandlerTest, ::testing::ValuesIn(GetTestConfigs()))
|
|||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
if (!android::snapshot::CanUseUserspaceSnapshots() ||
|
||||
android::snapshot::IsVendorFromAndroid12()) {
|
||||
std::cerr << "snapuserd_test not supported on this device\n";
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, false);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue