diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-05-24 20:45:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-05-24 20:45:24 +0000 |
commit | f336bcd4cff6be87ba79eac1055c1956307c122e (patch) | |
tree | b2ae86431a3449876a4c4b35aad5e846cfed540f | |
parent | e7dbaabb699a3dfad1dea5a5ce5d0c4d3eb54864 (diff) | |
parent | 457f5fedfa0711328ed177a093d58e3c9ca2f059 (diff) | |
download | kernel-f336bcd4cff6be87ba79eac1055c1956307c122e.tar.gz |
Merge "Fix proc test failures on 4.4 and 4.9." into oc-dev
-rw-r--r-- | api/proc/KernelProcFileApiTest.py | 2 | ||||
-rw-r--r-- | api/proc/ProcCpuInfoTest.py | 5 | ||||
-rw-r--r-- | api/proc/ProcMemInfoTest.py | 8 | ||||
-rw-r--r-- | api/proc/ProcShowUidStatTest.py | 8 | ||||
-rw-r--r-- | api/proc/ProcVmallocInfoTest.py | 17 | ||||
-rw-r--r-- | api/proc/ProcZoneInfoTest.py | 8 |
6 files changed, 32 insertions, 16 deletions
diff --git a/api/proc/KernelProcFileApiTest.py b/api/proc/KernelProcFileApiTest.py index c62cecdd..d5d1cd3f 100644 --- a/api/proc/KernelProcFileApiTest.py +++ b/api/proc/KernelProcFileApiTest.py @@ -95,7 +95,7 @@ class KernelProcFileApiTest(base_test.BaseTestClass): file_content = self.ReadFileContent(filepath) try: parse_result = test_object.parse_contents(file_content) - except SyntaxError as e: + except (SyntaxError, ValueError, IndexError) as e: asserts.fail("Failed to parse! " + str(e)) asserts.assertTrue( test_object.result_correct(parse_result), "Results not valid!") diff --git a/api/proc/ProcCpuInfoTest.py b/api/proc/ProcCpuInfoTest.py index eb3b50bc..959770bd 100644 --- a/api/proc/ProcCpuInfoTest.py +++ b/api/proc/ProcCpuInfoTest.py @@ -39,8 +39,9 @@ class ProcCpuInfoTest(KernelProcFileTestBase.KernelProcFileTestBase): t_STRING = r'[^:^ ^\t^\n]+' # Numbers and literals are tokenized as strings instead - t_NUMBER = r'[0-9]+' - t_HEX_LITERAL = r'[0-9a-f]+' + t_NUMBER = r'x' + t_HEX_LITERAL = r'x' + t_FLOAT = r'x' p_lines = repeat_rule('line') p_string_spaces = repeat_rule('string_space', zero_ok=True) diff --git a/api/proc/ProcMemInfoTest.py b/api/proc/ProcMemInfoTest.py index 9182d939..1b4652f9 100644 --- a/api/proc/ProcMemInfoTest.py +++ b/api/proc/ProcMemInfoTest.py @@ -28,6 +28,10 @@ def token_name(text): def token_lu(text): return int(text) +@with_pattern(r'(kB)?') +def token_kb(text): + return text + class ProcMemInfoTest(KernelProcFileTestBase.KernelProcFileTestBase): '''/proc/meminfo reports statistics about memory usage on the system. @@ -75,8 +79,8 @@ class ProcMemInfoTest(KernelProcFileTestBase.KernelProcFileTestBase): lines = contents.split('\n') if lines[-1] != '': raise SyntaxError("missing final newline") - return [self.parse_line("{:name}: {:lu} kB", line, dict(name=token_name, lu=token_lu)) - for line in lines[:-1]] + return [self.parse_line("{:name}: {:lu}{:^kb}", line, + dict(name=token_name, lu=token_lu, kb=token_kb)) for line in lines[:-1]] def result_correct(self, parse_result): required_fields = self.REQUIRED_FIELDS.copy() diff --git a/api/proc/ProcShowUidStatTest.py b/api/proc/ProcShowUidStatTest.py index aa132c96..6d008aa2 100644 --- a/api/proc/ProcShowUidStatTest.py +++ b/api/proc/ProcShowUidStatTest.py @@ -28,8 +28,12 @@ class ProcShowUidStatTest(KernelProcFileTestBase.KernelProcFileTestBase): p_lines = KernelProcFileTestBase.repeat_rule('line') def p_line(self, p): - 'line : NUMBER COLON SPACE NUMBER SPACE NUMBER SPACE NUMBER NEWLINE' - p[0] = [p[1], p[4], p[6], p[8]] + '''line : NUMBER COLON SPACE NUMBER SPACE NUMBER SPACE NUMBER NEWLINE + | NUMBER COLON SPACE NUMBER SPACE NUMBER NEWLINE''' + if len(p) == 10: + p[0] = [p[1], p[4], p[6], p[8]] + else: + p[0] = [p[1], p[4], p[6]] def get_path(self): return "/proc/uid_cputime/show_uid_stat" diff --git a/api/proc/ProcVmallocInfoTest.py b/api/proc/ProcVmallocInfoTest.py index c60fa93d..83865f3a 100644 --- a/api/proc/ProcVmallocInfoTest.py +++ b/api/proc/ProcVmallocInfoTest.py @@ -26,13 +26,17 @@ class ProcVmallocInfoTest(KernelProcFileTestBase.KernelProcFileTestBase): t_STRING = r'[^ ^\t^\n^-^=]+' t_PAGES = literal_token('pages') - t_PHYS = literal_token('phys') t_IOREMAP = literal_token('ioremap') t_VMALLOC = literal_token('vmalloc') t_VMAP = literal_token('vmap') t_USER = literal_token('user') t_VPAGES = literal_token('vpages') + def t_PHYS(self, t): + r'phys=[a-f0-9]+' + t.value = [t.value[:4], int(t.value[5:], 16)] + return t + t_ignore = ' ' p_lines = repeat_rule('line') @@ -53,15 +57,12 @@ class ProcVmallocInfoTest(KernelProcFileTestBase.KernelProcFileTestBase): def p_pages(self, p): '''pages : PAGES EQUALS NUMBER | empty''' - if len(p) > 2: - p[0] = [p[1], p[3]] - else: - p[0] = [] + p[0] = [] if len(p) == 2 else [p[1], p[3]] def p_phys(self, p): - '''phys : PHYS EQUALS STRING - | empty''' - p[0] = p[1:] + '''phys : PHYS + | empty''' + p[0] = p[1] def p_ioremap(self, p): '''ioremap : IOREMAP diff --git a/api/proc/ProcZoneInfoTest.py b/api/proc/ProcZoneInfoTest.py index 867ad96c..b8b7cbae 100644 --- a/api/proc/ProcZoneInfoTest.py +++ b/api/proc/ProcZoneInfoTest.py @@ -30,6 +30,7 @@ class ProcZoneInfoTest(KernelProcFileTestBase.KernelProcFileTestBase): t_NODE = literal_token(r'Node') t_ZONE = literal_token(r'zone') t_PROTECTION = literal_token(r'protection') + t_PERNODE = literal_token(r'per-node') t_LPAREN = literal_token(r'\(') t_RPAREN = literal_token(r'\)') @@ -44,9 +45,14 @@ class ProcZoneInfoTest(KernelProcFileTestBase.KernelProcFileTestBase): p_numcommas = repeat_rule('numcomma') def p_node(self, p): - 'node : heading APAGES lines protection PAGESETS NEWLINE cpus colonlines' + 'node : heading pernode APAGES lines protection PAGESETS NEWLINE cpus colonlines' p[0] = [p[1], p[3], p[4], p[7], p[8]] + def p_pernode(self, p): + '''pernode : PERNODE STATS NEWLINE lines + | empty''' + p[0] = [] if len(p) == 2 else [p[1], p[4]] + def p_protection(self, p): 'protection : PROTECTION COLON LPAREN numcommas NUMBER RPAREN NEWLINE' p[0] = p[4] + [p[5]] |