Add vts_dlkm_partition_test#SystemDlkmPartition
Remove the static partition test; and replace it
with dynamic partition test.
Bug: 211790350
Test: atest vts_dlkm_partition_test
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
Change-Id: Id531235f8b21991def7fae5580bafd4fca5a41e2
diff --git a/gki/Android.bp b/gki/Android.bp
index 62ef849..77c654a 100644
--- a/gki/Android.bp
+++ b/gki/Android.bp
@@ -98,33 +98,3 @@
"libstorage_literals_headers",
],
}
-
-cc_test {
- name: "vts_system_dlkm_partition_test",
- require_root: true,
-
- // GKI modules feautre is only available with Android 13(T) launch kernels
- // Therefore, the test is enforced on device launching with Android 13 (T)
- // and above.
- test_options: {
- min_shipping_api_level: 33,
- },
-
- srcs: [
- "system_dlkm_partition_test.cpp",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- ],
- test_suites: [
- "general-tests",
- "vts",
- ],
- static_libs: [
- "libbase",
- ],
- header_libs: [
- "libstorage_literals_headers",
- ],
-}
diff --git a/gki/system_dlkm_partition_test.cpp b/gki/system_dlkm_partition_test.cpp
deleted file mode 100644
index f3ed2b2..0000000
--- a/gki/system_dlkm_partition_test.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <fcntl.h>
-
-#include <linux/fs.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <android-base/file.h>
-#include <android-base/properties.h>
-#include <gtest/gtest.h>
-#include <storage_literals/storage_literals.h>
-using android::storage_literals::operator""_MiB;
-
-class SystemDlkmPartitionTest : public testing::Test {
- public:
- void SetUp() override {}
-};
-
-TEST_F(SystemDlkmPartitionTest, SystemDlkmPartition) {
- // Only Test for the Android T+ feature launch devices
- if (android::base::GetIntProperty("ro.product.first_api_level", 0) <
- __ANDROID_API_T__) {
- GTEST_SKIP() << "Exempt system_dlkm partition test on product "
- << "first api level < Android T";
- }
-
- const std::string slot_suffix =
- android::base::GetProperty("ro.boot.slot_suffix", "");
- const std::string system_dlkm_path =
- "/dev/block/by-name/system_dlkm" + slot_suffix;
-
- // Verify access to the partition
- ASSERT_EQ(0, access(system_dlkm_path.c_str(), F_OK)) << strerror(errno);
-
- // Open & retrieve partition stats
- auto fd = android::base::unique_fd(open(system_dlkm_path.c_str(), O_RDONLY));
- ASSERT_LE(0, fd) << strerror(errno);
-
- struct stat s;
- ASSERT_EQ(0, fstat(fd, &s)) << strerror(errno);
-
- // Validate partition size as per requirement
- uint64_t size;
- ASSERT_TRUE(S_ISBLK(s.st_mode)) << "Not a block device: " << system_dlkm_path;
- ASSERT_EQ(0, ioctl(fd, BLKGETSIZE64, &size)) << strerror(errno);
- EXPECT_GE(size, 64_MiB) << "Size of system_dlkm partition found to be "
- << size << " bytes must be at least " << 64_MiB
- << " bytes";
-}
diff --git a/gki/vts_dlkm_partition_test.cpp b/gki/vts_dlkm_partition_test.cpp
index 9320f57..f66dcff 100644
--- a/gki/vts_dlkm_partition_test.cpp
+++ b/gki/vts_dlkm_partition_test.cpp
@@ -155,6 +155,20 @@
ASSERT_NO_FATAL_FAILURE(VerifyDlkmPartition("odm"));
}
+TEST_F(DlkmPartitionTest, SystemDlkmPartition) {
+ if (vendor_api_level < __ANDROID_API_T__) {
+ GTEST_SKIP()
+ << "Exempt from system_dlkm partition test. ro.vendor.api_level ("
+ << vendor_api_level << ") < " << __ANDROID_API_T__;
+ }
+ if (runtime_info->kernelVersion().dropMinor() <
+ android::vintf::Version{5, 10}) {
+ GTEST_SKIP() << "Exempt from system_dlkm partition test. kernel: "
+ << runtime_info->kernelVersion();
+ }
+ ASSERT_NO_FATAL_FAILURE(VerifyDlkmPartition("system"));
+}
+
int main(int argc, char *argv[]) {
::testing::InitGoogleTest(&argc, argv);
android::base::InitLogging(argv, android::base::StderrLogger);