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 ProcZoneInfoTest(KernelProcFileTestBase.KernelProcFileTestBase):
     22     '''/proc/zoneinfo displays information about memory zones.'''
     23 
     24     t_APAGES = literal_token(r'pages')
     25     t_PAGESETS = literal_token(r'pagesets')
     26     t_CPU = literal_token(r'cpu')
     27     t_VM = literal_token(r'vm')
     28     t_STATS = literal_token(r'stats')
     29     t_THRESHOLD = literal_token(r'threshold')
     30     t_NODE = literal_token(r'Node')
     31     t_ZONE = literal_token(r'zone')
     32     t_PROTECTION = literal_token(r'protection')
     33     t_PERNODE = literal_token(r'per-node')
     34     t_LPAREN = literal_token(r'\(')
     35     t_RPAREN = literal_token(r'\)')
     36 
     37     t_ignore = ' '
     38 
     39     start = 'nodes'
     40 
     41     p_nodes = repeat_rule('node')
     42     p_lines = repeat_rule('line')
     43     p_cpus = repeat_rule('cpu')
     44     p_colonlines = repeat_rule('colonline')
     45     p_numcommas = repeat_rule('numcomma')
     46 
     47     def p_node(self, p):
     48         'node : heading pernode APAGES lines protection PAGESETS NEWLINE cpus colonlines'
     49         p[0] = [p[1], p[3], p[4], p[7], p[8]]
     50 
     51     def p_pernode(self, p):
     52         '''pernode : PERNODE STATS NEWLINE lines
     53                    | empty'''
     54         p[0] = [] if len(p) == 2 else [p[1], p[4]]
     55 
     56     def p_protection(self, p):
     57         'protection : PROTECTION COLON LPAREN numcommas NUMBER RPAREN NEWLINE'
     58         p[0] = p[4] + [p[5]]
     59 
     60     def p_numcomma(self, p):
     61         'numcomma : NUMBER COMMA'
     62         p[0] = p[1]
     63 
     64     def p_line(self, p):
     65         'line : STRING NUMBER NEWLINE'
     66         p[0] = p[1:3]
     67 
     68     def p_cpu(self, p):
     69         'cpu : CPU COLON NUMBER NEWLINE colonline colonline colonline \
     70                 VM STATS THRESHOLD COLON NUMBER NEWLINE'
     71 
     72         p[0] = [p[3], p[5], p[6], p[7], [p[10], p[12]]]
     73 
     74     def p_colonline(self, p):
     75         'colonline : STRING COLON NUMBER NEWLINE'
     76         p[0] = [p[1], p[3]]
     77 
     78     def p_heading(self, p):
     79         'heading : NODE NUMBER COMMA ZONE STRING NEWLINE'
     80         p[0] = [p[2], p[5]]
     81 
     82     def get_path(self):
     83         return "/proc/zoneinfo"
     84