1# 2# Copyright (C) 2018 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 ProcUidTimeInStateTest(KernelProcFileTestBase.KernelProcFileTestBase): 22 '''/proc/uid_time_in_state provides the time each UID's processes spend 23 executing at each available frequency. 24 25 This is an Android specific file. 26 ''' 27 28 start = 'uid_time_table' 29 30 t_UID = literal_token(r'uid') 31 32 p_uid_times = repeat_rule('uid_time') 33 p_numbers = repeat_rule('NUMBER') 34 35 t_ignore = ' ' 36 37 def p_uid_time_table(self, p): 38 'uid_time_table : freqs uid_times' 39 p[0] = p[1:] 40 41 def p_freqs(self, p): 42 'freqs : UID COLON NUMBERs NEWLINE' 43 p[0] = p[3] 44 45 def p_uid_time(self, p): 46 'uid_time : NUMBER COLON NUMBERs NEWLINE' 47 p[0] = [p[1], p[3]] 48 49 def get_path(self): 50 return "/proc/uid_time_in_state" 51 52 def file_optional(self, shell=None, dut=None): 53 return True 54 55 def result_correct(self, result): 56 freqs, times = result 57 return all(len(time[1]) == len(freqs) for time in times) 58