1# 2# Copyright (C) 2017 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 ProcVmallocInfoTest(KernelProcFileTestBase.KernelProcFileTestBase): 22 '''/proc/vmallocinfo provides info on vmalloc'd ranges.''' 23 24 start = 'lines' 25 26 t_STRING = r'[^ ^\t^\n^-^=]+' 27 28 t_PAGES = literal_token('pages') 29 t_IOREMAP = literal_token('ioremap') 30 t_MODULE = literal_token('\[[^\n^\0]*\]') 31 t_VMALLOC = literal_token('vmalloc') 32 t_VMAP = literal_token('vmap') 33 t_USER = literal_token('user') 34 t_VPAGES = literal_token('vpages') 35 36 def t_PHYS(self, t): 37 r'phys=[a-f0-9]+' 38 t.value = [t.value[:4], int(t.value[5:], 16)] 39 return t 40 41 t_ignore = ' ' 42 43 p_lines = repeat_rule('line') 44 45 def p_line(self, p): 46 'line : addr_range NUMBER caller module pages phys ioremap vmalloc vmap user vpages NEWLINE' 47 p[0] = p[1:] 48 49 def p_addr_range(self, p): 50 'addr_range : HEX_LITERAL DASH HEX_LITERAL' 51 p[0] = [p[1], p[3]] 52 53 def p_caller(self, p): 54 '''caller : STRING 55 | empty''' 56 p[0] = p[1:] 57 58 def p_module(self, p): 59 '''module : MODULE 60 | empty''' 61 p[0] = p[1:] 62 63 def p_pages(self, p): 64 '''pages : PAGES EQUALS NUMBER 65 | empty''' 66 p[0] = [] if len(p) == 2 else [p[1], p[3]] 67 68 def p_phys(self, p): 69 '''phys : PHYS 70 | empty''' 71 p[0] = p[1] 72 73 def p_ioremap(self, p): 74 '''ioremap : IOREMAP 75 | empty''' 76 p[0] = p[1:] 77 78 def p_vmalloc(self, p): 79 '''vmalloc : VMALLOC 80 | empty''' 81 p[0] = p[1:] 82 83 def p_vmap(self, p): 84 '''vmap : VMAP 85 | empty''' 86 p[0] = p[1:] 87 88 def p_user(self, p): 89 '''user : USER 90 | empty''' 91 p[0] = p[1:] 92 93 def p_vpages(self, p): 94 '''vpages : VPAGES 95 | empty''' 96 p[0] = p[1:] 97 98 def get_path(self): 99 return "/proc/vmallocinfo" 100