Merge "snapuserd: Use GTEST_SKIP in snapuserd_test." into android15-tests-dev
This commit is contained in:
commit
a8537415c1
1 changed files with 34 additions and 8 deletions
|
|
@ -81,6 +81,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;
|
||||
|
|
@ -96,6 +98,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
|
||||
|
|
@ -103,6 +109,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;
|
||||
}
|
||||
|
|
@ -301,6 +317,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>();
|
||||
}
|
||||
|
|
@ -311,6 +330,9 @@ void SnapuserdTest::TearDown() {
|
|||
}
|
||||
|
||||
void SnapuserdTest::Shutdown() {
|
||||
if (!handlers_) {
|
||||
return;
|
||||
}
|
||||
if (dmuser_dev_) {
|
||||
ASSERT_TRUE(dmuser_dev_->Destroy());
|
||||
}
|
||||
|
|
@ -1180,6 +1202,9 @@ void SnapuserdVariableBlockSizeTest::ReadSnapshotWithVariableBlockSize() {
|
|||
}
|
||||
|
||||
void SnapuserdVariableBlockSizeTest::SetUp() {
|
||||
if (ShouldSkipSetUp()) {
|
||||
GTEST_SKIP() << "snapuserd not supported on this device";
|
||||
}
|
||||
ASSERT_NO_FATAL_FAILURE(SnapuserdTest::SetUp());
|
||||
}
|
||||
|
||||
|
|
@ -1243,6 +1268,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());
|
||||
|
|
@ -1250,6 +1278,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();
|
||||
|
|
@ -1325,6 +1356,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());
|
||||
|
|
@ -1528,14 +1562,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