1# 2# Copyright (C) 2019 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17from vts.testcases.kernel.api.proc import KernelProcFileTestBase 18from vts.testcases.kernel.api.proc.KernelProcFileTestBase import repeat_rule, literal_token 19 20 21class ProcUidConcurrentActiveTimeTest(KernelProcFileTestBase.KernelProcFileTestBase): 22 '''/proc/uid_concurrent_active_time provides the time each UID's processes spend 23 executing concurrently with processes on other CPUs. 24 25 This is an Android specific file. 26 ''' 27 28 start = 'uid_active_time_table' 29 30 t_CPU = literal_token(r'cpus') 31 32 p_uid_active_times = repeat_rule('uid_active_time') 33 p_numbers = repeat_rule('NUMBER') 34 35 t_ignore = ' ' 36 37 def p_uid_active_time_table(self, p): 38 'uid_active_time_table : cpus uid_active_times' 39 p[0] = p[1:] 40 41 def p_cpus(self, p): 42 'cpus : CPU COLON NUMBER NEWLINE' 43 p[0] = p[3] 44 45 def p_uid_active_time(self, p): 46 'uid_active_time : NUMBER COLON NUMBERs NEWLINE' 47 p[0] = [p[1], p[3]] 48 49 def get_path(self): 50 return "/proc/uid_concurrent_active_time" 51 52 def result_correct(self, result): 53 cpus, times = result 54 no_repeated_uids = len(set(x[0] for x in times)) == len(times) 55 row_lengths_match = all(len(time[1]) == int(cpus) for time in times) 56 return no_repeated_uids and row_lengths_match 57 58class ProcUidConcurrentPolicyTimeTest(KernelProcFileTestBase.KernelProcFileTestBase): 59 '''/proc/uid_concurrent_policy_time provides the time each UID's processes spend 60 executing concurrently with processes on the same cluster. 61 62 This is an Android specific file. 63 ''' 64 65 start = 'uid_policy_time_table' 66 67 t_POLICY = literal_token(r'policy') 68 69 p_policy_infos = repeat_rule('policy_info') 70 p_uid_policy_times = repeat_rule('uid_policy_time') 71 p_numbers = repeat_rule('NUMBER') 72 73 t_ignore = ' ' 74 75 def p_uid_policy_time_table(self, p): 76 'uid_policy_time_table : header_row uid_policy_times' 77 p[0] = p[1:] 78 79 def p_header_row(self, p): 80 'header_row : policy_infos NEWLINE' 81 p[0] = sum(int(x) for x in p[1]) 82 83 def p_policy_info(self, p): 84 'policy_info : POLICY NUMBER COLON NUMBER' 85 p[0] = p[4] 86 87 def p_uid_policy_time(self, p): 88 'uid_policy_time : NUMBER COLON NUMBERs NEWLINE' 89 p[0] = [p[1], p[3]] 90 91 def get_path(self): 92 return "/proc/uid_concurrent_policy_time" 93 94 def result_correct(self, result): 95 cpus, times = result 96 no_repeated_uids = len(set(x[0] for x in times)) == len(times) 97 row_lengths_match = all(len(time[1]) == int(cpus) for time in times) 98 return no_repeated_uids and row_lengths_match 99