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