Merge "Add memunreachable_binder_test to VTS binder tests"
diff --git a/api/proc/KernelProcFileApiTest.py b/api/proc/KernelProcFileApiTest.py
index d62c74f..fe7b75e 100644
--- a/api/proc/KernelProcFileApiTest.py
+++ b/api/proc/KernelProcFileApiTest.py
@@ -210,5 +210,63 @@
         self.dut.waitForBootCompletion()
         self.dut.rootAdb()
 
+    def testProcUidProcstatSet(self):
+        def UidIOStats(uid):
+            """Returns I/O stats for a given uid.
+
+            Args:
+                uid, uid number.
+
+            Returns:
+                list of I/O numbers.
+            """
+            stats_path = "/proc/uid_io/stats"
+            result = self.dut.adb.shell(
+                    "\"cat %s | grep '^%d'\"" % (stats_path, uid),
+                    no_except=True)
+            return result[const.STDOUT].split()
+
+        def CheckStatsInState(state):
+            """Sets VTS (root uid) into a given state and checks the stats.
+
+            Args:
+                state, boolean. Use False for foreground,
+                and True for background.
+            """
+            state = 1 if state else 0
+            filepath = "/proc/uid_procstat/set"
+            root_uid = 0
+
+            # fg write chars are at index 2, and bg write chars are at 6.
+            wchar_index = 6 if state else 2
+            old_wchar = UidIOStats(root_uid)[wchar_index]
+            self.dut.adb.shell("\"echo %d %s > %s\"" % (root_uid, state, filepath))
+            # This should increase the number of write syscalls.
+            self.dut.adb.shell("\"echo foo\"")
+            asserts.assertLess(
+                old_wchar,
+                UidIOStats(root_uid)[wchar_index],
+                "Number of write syscalls has not increased.")
+
+        CheckStatsInState(False)
+        CheckStatsInState(True)
+
+    def testProcPerUidTimes(self):
+        # TODO: make these files mandatory once they're in AOSP
+        try:
+            filepaths = self.dut.adb.shell("find /proc/uid -name time_in_state")
+        except:
+            asserts.skip("/proc/uid/ directory does not exist and is optional")
+
+        asserts.skipIf(not filepaths,
+                       "per-UID time_in_state files do not exist and are optional")
+
+        filepaths = filepaths.splitlines()
+        for filepath in filepaths:
+            target_file_utils.assertPermissionsAndExistence(
+                self.shell, filepath, target_file_utils.IsReadOnly
+            )
+            file_content = self.ReadFileContent(filepath)
+
 if __name__ == "__main__":
     test_runner.main()
diff --git a/api/sysfs/KernelApiSysfsTest.py b/api/sysfs/KernelApiSysfsTest.py
index c704702..2a876fd 100644
--- a/api/sysfs/KernelApiSysfsTest.py
+++ b/api/sysfs/KernelApiSysfsTest.py
@@ -144,6 +144,45 @@
                     asserts.assertTrue(v == "N/A",
                             'all_time_in_state malformatted value')
 
+    def testPerCpuCpufreq(self):
+        '''Check each cpu's scaling_cur_freq, scaling_min_freq, scaling_max_freq,
+        and scaling_available_frequencies.
+        '''
+        f = '/sys/devices/system/cpu/online'
+        self.IsReadOnly(f)
+        online_cpus = target_file_utils.ReadFileContent(f, self.shell)
+        cpu_ranges = online_cpus.split(',')
+        cpu_list = []
+        for r in cpu_ranges:
+            m = re.match(r'(\d+)(-\d+)?', r)
+            asserts.assertTrue(m is not None,
+                    'malformatted range in /sys/devices/system/cpu/online')
+            start_cpu = int(m.group(1))
+            if m.group(2) is None:
+                end_cpu = start_cpu
+            else:
+                end_cpu = int(m.group(2))
+            cpu_list += range(start_cpu, end_cpu+1)
+        for cpu in cpu_list:
+            f = '/sys/devices/system/cpu/cpu%s/cpufreq/scaling_cur_freq' % cpu
+            self.IsReadOnly(f)
+            content = target_file_utils.ReadFileContent(f, self.shell)
+            self.ConvertToInteger(content)
+            f = '/sys/devices/system/cpu/cpu%s/cpufreq/scaling_min_freq' % cpu
+            self.IsReadWrite(f)
+            content = target.file_utils.ReadFileContent(f, self.shell)
+            self.ConvertToInteger(content)
+            f = '/sys/devices/system/cpu/cpu%s/cpufreq/scaling_max_freq' % cpu
+            self.IsReadWrite(f)
+            content = target.file_utils.ReadFileContent(f, self.shell)
+            self.ConvertToInteger(content)
+            f = '/sys/devices/system/cpu/cpu%s/cpufreq/scaling_available_frequencies' % cpu
+            self.IsReadOnly(f)
+            content = target.file_utils.ReadFileContent(f, self.shell)
+            avail_freqs = content.split(' ')
+            for x in avail_freqs:
+                self.ConvertToInteger(x)
+
     def testIpv4(self):
         '''Check /sys/kernel/ipv4/*.'''
         files = ['tcp_rmem_def', 'tcp_rmem_max', 'tcp_rmem_min',
diff --git a/ltp/configs/disabled_tests.py b/ltp/configs/disabled_tests.py
index 75832cd..b5c01d3 100644
--- a/ltp/configs/disabled_tests.py
+++ b/ltp/configs/disabled_tests.py
@@ -42,7 +42,6 @@
     'syscalls.pathconf01',
     'syscalls.preadv02',
     'syscalls.pwritev02',
-    'syscalls.rename11',
     'syscalls.rt_sigprocmask01',
     'syscalls.setfsgid01_16',
     'syscalls.setfsgid02_16',
@@ -122,7 +121,6 @@
     'fs.rwtest04',
     'fs.rwtest05',
     'fs.iogen01',
-    'fs.ftest06',
     'fs.isofs',
     'fsx.fsx-linux',
     'mm.mtest06',
@@ -294,32 +292,6 @@
     'syscalls.fcntl36',
     # b/71416822: fails in VTS
     'tracing.dynamic_debug01',
-    # failing and need triage
-    'fs.fs_fill',
-    'syscalls.fallocate05',
-    'syscalls.fchmod06',
-    'syscalls.fsync01',
-    'syscalls.ftruncate04_64',
-    'syscalls.ftruncate04',
-    'syscalls.link08',
-    'syscalls.linkat02',
-    'syscalls.mkdirat02',
-    'syscalls.mknod07',
-    'syscalls.mknodat02',
-    'syscalls.mount01',
-    'syscalls.mount02',
+    # (TODO): b/73784987
     'syscalls.mount03',
-    'syscalls.mount04',
-    'syscalls.mount06',
-    'syscalls.msync04',
-    'syscalls.renameat01',
-    'syscalls.rmdir02',
-    'syscalls.umount01',
-    'syscalls.umount02',
-    'syscalls.umount03',
-    'syscalls.umount2_01',
-    'syscalls.umount2_02',
-    'syscalls.umount2_03',
-    'syscalls.utime06',
-    'syscalls.utimes01',
 ]