Merge tag 'android-13.0.0_r52' into int/13/fp3

Android 13.0.0 Release 52 (TQ3A.230605.012)

* tag 'android-13.0.0_r52': (36 commits)
  kselftests: Stop Android framework when running kselftests
  kselftests: Stop Android framework when running kselftests
  kselftests: Stop Android framework when running kselftests
  vts: kernel: Fix loop device configuration test
  kernel-tests: update owners
  vts: KernelApiSysfsTest com.android.tests.sysfs.KernelApiSysfsTest#testKfenceSampleRate fail on 32bit kernel [1/1]
  ltp: clock_gettime04 skippable
  Disable testRaceWithoutBarrier
  Fix metadata_test to conform with VTS requirements.
  vts_dlkm_partition_test: Skip VendorDlkmPartition on pre-T products
  Skip GenericBootImageTest on TV devices.
  Skip GenericBootImageTest on 32-bit ARM devices.
  vts: kernel: toolchain: prefer ro.vendor.api_level over ro.product.first_api_level
  Increase timeout for bpftest
  KernelApiSysfsTest: only enforce testRtcHctosys if RTC is present
  Fix "adb root" race condition in vts_kernel_checkpoint_test
  VTS: Disable syscalls.sched_{get,set}attr01_32bit LTP tests
  Change timeouts for VtsKernelNetBpfTest#BpfRaceTest
  sysfs.KernelApiSysfsTest#testAndroidUSB: enforce only if file present
  VtsKernelCheckpointTest: add ro.boot.fstab_suffix support
  ...

Change-Id: I410f45be7f24c57b9390b0b5fdc67d3c71ab96e3
diff --git a/api/sysfs/OWNERS b/api/sysfs/OWNERS
index e4b9e91..85b9a12 100644
--- a/api/sysfs/OWNERS
+++ b/api/sysfs/OWNERS
@@ -1,2 +1,3 @@
 # Bug component: 391836
-smuckle@google.com
+vmartensson@google.com
+edliaw@google.com
diff --git a/api/sysfs/src/com/android/tests/sysfs/KernelApiSysfsTest.java b/api/sysfs/src/com/android/tests/sysfs/KernelApiSysfsTest.java
index 105560a..35de7b3 100644
--- a/api/sysfs/src/com/android/tests/sysfs/KernelApiSysfsTest.java
+++ b/api/sysfs/src/com/android/tests/sysfs/KernelApiSysfsTest.java
@@ -27,6 +27,7 @@
 import com.android.tradefed.util.FileUtil;
 import com.android.tradefed.util.TargetFileUtils;
 import com.android.tradefed.util.TargetFileUtils.FilePermission;
+import com.android.tradefed.log.LogUtil.CLog;
 import com.google.common.base.Strings;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -282,6 +283,17 @@
         if ((kernel_major < 5) || ((kernel_major == 5) && (kernel_minor < 10)))
             return;
 
+        String executeShellKernelARM64 =
+            "cat /proc/config.gz | gzip -d | grep CONFIG_ARM64=y";
+
+        boolean isKernelARM64 = getDevice().executeShellCommand(executeShellKernelARM64)
+                                           .contains("CONFIG_ARM64");
+
+        if (!isKernelARM64) {
+            CLog.d("Kernel not 64bit skip");
+            return;
+        }
+
         String filePath = "/sys/module/kfence/parameters/sample_interval";
         assertTrue("Failed readwrite check of " + filePath,
                 TargetFileUtils.isReadWriteOnly(filePath, getDevice()));
diff --git a/linux_kselftest/OWNERS b/linux_kselftest/OWNERS
index e4b9e91..85b9a12 100644
--- a/linux_kselftest/OWNERS
+++ b/linux_kselftest/OWNERS
@@ -1,2 +1,3 @@
 # Bug component: 391836
-smuckle@google.com
+vmartensson@google.com
+edliaw@google.com
diff --git a/linux_kselftest/testcases/OWNERS b/linux_kselftest/testcases/OWNERS
index f21a028..1f6a131 100644
--- a/linux_kselftest/testcases/OWNERS
+++ b/linux_kselftest/testcases/OWNERS
@@ -1,4 +1,5 @@
 # Bug component: 391836
-smuckle@google.com
+vmartensson@google.com
+edliaw@google.com
 henneman@google.com
 
diff --git a/linux_kselftest/testcases/vts_linux_kselftest_arm_32.xml b/linux_kselftest/testcases/vts_linux_kselftest_arm_32.xml
index 4574054..7542660 100644
--- a/linux_kselftest/testcases/vts_linux_kselftest_arm_32.xml
+++ b/linux_kselftest/testcases/vts_linux_kselftest_arm_32.xml
@@ -14,8 +14,8 @@
     <!ENTITY ktest_dir "/data/local/tmp/vts_kernel_tests/DATA/nativetest/linux-kselftest">
 ]>
 <configuration description="Runs vts_linux_kselftest.">
-    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
-    </target_preparer>
+    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
+    <target_preparer class="com.android.tradefed.targetprep.StopServicesSetup" />
 
     <object type="module_controller" class="com.android.tradefed.testtype.suite.module.KernelTestModuleController" >
         <option name="arch" value="arm"/>
diff --git a/linux_kselftest/testcases/vts_linux_kselftest_arm_64.xml b/linux_kselftest/testcases/vts_linux_kselftest_arm_64.xml
index fa5237b..2a33f2c 100644
--- a/linux_kselftest/testcases/vts_linux_kselftest_arm_64.xml
+++ b/linux_kselftest/testcases/vts_linux_kselftest_arm_64.xml
@@ -14,8 +14,8 @@
     <!ENTITY ktest_dir "/data/local/tmp/vts_kernel_tests/DATA/nativetest64/linux-kselftest">
 ]>
 <configuration description="Runs vts_linux_kselftest.">
-    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
-    </target_preparer>
+    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
+    <target_preparer class="com.android.tradefed.targetprep.StopServicesSetup" />
 
     <object type="module_controller" class="com.android.tradefed.testtype.suite.module.KernelTestModuleController" >
         <option name="arch" value="arm64"/>
diff --git a/linux_kselftest/testcases/vts_linux_kselftest_x86_32.xml b/linux_kselftest/testcases/vts_linux_kselftest_x86_32.xml
index 65ffc65..0137590 100644
--- a/linux_kselftest/testcases/vts_linux_kselftest_x86_32.xml
+++ b/linux_kselftest/testcases/vts_linux_kselftest_x86_32.xml
@@ -14,8 +14,8 @@
     <!ENTITY ktest_dir "/data/local/tmp/vts_kernel_tests/DATA/nativetest/linux-kselftest">
 ]>
 <configuration description="Runs vts_linux_kselftest.">
-    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
-    </target_preparer>
+    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
+    <target_preparer class="com.android.tradefed.targetprep.StopServicesSetup" />
 
     <object type="module_controller" class="com.android.tradefed.testtype.suite.module.KernelTestModuleController" >
         <option name="arch" value="x86"/>
diff --git a/linux_kselftest/testcases/vts_linux_kselftest_x86_64.xml b/linux_kselftest/testcases/vts_linux_kselftest_x86_64.xml
index 2cadfbe..2022e27 100644
--- a/linux_kselftest/testcases/vts_linux_kselftest_x86_64.xml
+++ b/linux_kselftest/testcases/vts_linux_kselftest_x86_64.xml
@@ -14,8 +14,8 @@
     <!ENTITY ktest_dir "/data/local/tmp/vts_kernel_tests/DATA/nativetest64/linux-kselftest">
 ]>
 <configuration description="Runs vts_linux_kselftest.">
-    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
-    </target_preparer>
+    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
+    <target_preparer class="com.android.tradefed.targetprep.StopServicesSetup" />
 
     <object type="module_controller" class="com.android.tradefed.testtype.suite.module.KernelTestModuleController" >
         <option name="arch" value="x86_64"/>
diff --git a/loop/Android.bp b/loop/Android.bp
index 48a95ac..35756f2 100644
--- a/loop/Android.bp
+++ b/loop/Android.bp
@@ -18,6 +18,9 @@
 
 cc_test {
     name: "vts_kernel_loopconfig_test",
+    defaults: [
+        "libvintf_static_user_defaults",
+    ],
     srcs: ["vts_kernel_loopconfig_test.cpp"],
     cflags: [
         "-Wall",
@@ -28,6 +31,7 @@
     ],
     static_libs: [
         "libgmock",
+	"libvintf",
     ],
     test_suites: [
         "general-tests",
diff --git a/loop/vts_kernel_loopconfig_test.cpp b/loop/vts_kernel_loopconfig_test.cpp
index 8105a83..1abe17f 100644
--- a/loop/vts_kernel_loopconfig_test.cpp
+++ b/loop/vts_kernel_loopconfig_test.cpp
@@ -19,10 +19,16 @@
 #include <fstream>
 #include <string>
 
+#include <android-base/parseint.h>
 #include <android-base/properties.h>
 #include <android/api-level.h>
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
+#include <vintf/VintfObject.h>
+
+using android::vintf::KernelVersion;
+using android::vintf::VintfObject;
+using android::base::ParseInt;
 
 namespace android {
 namespace kernel {
@@ -39,7 +45,7 @@
   }
 };
 
-TEST_F(KernelLoopConfigTest, ValidLoopConfig) {
+TEST_F(KernelLoopConfigTest, ValidLoopCountConfig) {
   if (!should_run()) return;
 
   static constexpr const char* kCmd =
@@ -60,25 +66,54 @@
 
   int minCountValue = std::stoi(minCountStr.substr(pos + 1));
   ASSERT_GE(minCountValue, 16);
-}
-
-TEST_F(KernelLoopConfigTest, ValidLoopParameters) {
-  if (!should_run()) return;
 
   std::ifstream max_loop("/sys/module/loop/parameters/max_loop");
-  std::ifstream max_part("/sys/module/loop/parameters/max_part");
 
   std::string max_loop_str;
-  std::string max_part_str;
 
   std::getline(max_loop, max_loop_str);
+
+  int max_loop_value;
+
+  ParseInt(max_loop_str, &max_loop_value);
+
+  auto runtime_info = VintfObject::GetRuntimeInfo();
+  ASSERT_NE(nullptr, runtime_info);
+
+  /*
+   * Upstream commit 85c50197716c ("loop: Fix the max_loop commandline argument
+   * treatment when it is set to 0") aligned max_loop to the kernel
+   * documentation, which states that when it is not set, it should be
+   * CONFIG_BLK_DEV_LOOP_MIN_COUNT instead of 0. This commit was applied to
+   * kernels 5.15.86+.
+   *
+   * For kernels older than 5.15.86, ensure that max_loop is not set by ensuring
+   * that it is 0. This ensures that CONFIG_BLK_DEV_LOOP_MIN_COUNT are being
+   * pre-allocated.
+   *
+   * For kernels 5.15.86+ ensure that max_loop is either not set (i.e. it is
+   * CONFIG_BLK_DEV_LOOP_MIN_COUNT), or if it is set, it s greater than
+   * CONFIG_BLK_DEV_LOOP_MIN_COUNT to ensure that at least that many loop
+   * devices are pre-allocated.
+   */
+  if (runtime_info->kernelVersion() < KernelVersion(5, 15, 86)) {
+    EXPECT_EQ(0, max_loop_value);
+  } else {
+    EXPECT_GE(max_loop_value, minCountValue);
+  }
+}
+
+TEST_F(KernelLoopConfigTest, ValidLoopPartParameter) {
+  if (!should_run()) return;
+
+  std::ifstream max_part("/sys/module/loop/parameters/max_part");
+
+  std::string max_part_str;
+
   std::getline(max_part, max_part_str);
 
   int max_part_value = std::stoi(max_part_str);
   EXPECT_LE(max_part_value, 7);
-
-  int max_loop_value = std::stoi(max_loop_str);
-  EXPECT_EQ(0, max_loop_value);
 }
 
 }  // namespace kernel
diff --git a/ltp/OWNERS b/ltp/OWNERS
index 97a9735..4088918 100644
--- a/ltp/OWNERS
+++ b/ltp/OWNERS
@@ -1,3 +1,4 @@
 # Bug component: 391836
+vmartensson@google.com
 balsini@google.com
-smuckle@google.com
+edliaw@google.com
diff --git a/ltp/testcase/OWNERS b/ltp/testcase/OWNERS
index cce5587..4088918 100644
--- a/ltp/testcase/OWNERS
+++ b/ltp/testcase/OWNERS
@@ -1,3 +1,4 @@
 # Bug component: 391836
-smuckle@google.com
+vmartensson@google.com
 balsini@google.com
+edliaw@google.com
diff --git a/ltp/testcase/tools/configs/stable_tests.py b/ltp/testcase/tools/configs/stable_tests.py
index e652471..9bc3f2b 100644
--- a/ltp/testcase/tools/configs/stable_tests.py
+++ b/ltp/testcase/tools/configs/stable_tests.py
@@ -726,7 +726,7 @@
     ('syscalls.clock_gettime02_64bit', True),
     ('syscalls.clock_gettime03_32bit', True),
     ('syscalls.clock_gettime03_64bit', True),
-    ('syscalls.clock_gettime04_32bit', True),
+    ('syscalls.clock_gettime04_32bit', False),
     ('syscalls.clock_gettime04_64bit', True),
     ('syscalls.clock_nanosleep01_32bit', True),
     ('syscalls.clock_nanosleep01_64bit', True),