Debian Codegraph @

rpython/tool/test/test_logparser.py

raw symbols SCIP
1 from rpython.tool.udir import udir
2 from rpython.tool.logparser import *
3
4
5 globalpath = udir.join('test_logparser.log')
6 globalpath.write("""\
7 test1
8 [12a0] {foo
9 test2a
10 test2b
11 [12b0] {bar
12 test3
13 [12e0] bar}
14 test4
15 [12e5] {bar
16 test5a
17 test5b
18 [12e6] bar}
19 test6
20 [12f0] foo}
21 test7
22 """)
23
24
25 def test_parse_log_file():
26 log = parse_log_file(str(globalpath))
27 assert log == [
28 ('debug_print', 'test1'),
29 ('foo', 0x12a0, 0x12f0, [
30 ('debug_print', 'test2a'),
31 ('debug_print', 'test2b'),
32 ('bar', 0x12b0, 0x12e0, [
33 ('debug_print', 'test3')]),
34 ('debug_print', 'test4'),
35 ('bar', 0x12e5, 0x12e6, [
36 ('debug_print', 'test5a'),
37 ('debug_print', 'test5b')]),
38 ('debug_print', 'test6')]),
39 ('debug_print', 'test7')]
40
41 def test_extract_category():
42 log = parse_log_file(str(globalpath))
43 catbar = list(extract_category(log, 'bar'))
44 assert catbar == ["test3\n", "test5a\ntest5b\n"]
45 assert catbar == list(extract_category(log, 'ba'))
46 catfoo = list(extract_category(log, 'foo'))
47 assert catfoo == ["test2a\ntest2b\ntest4\ntest6\n"]
48 assert catfoo == list(extract_category(log, 'f'))
49 catall = list(extract_category(log, ''))
50 assert catall == catfoo + catbar
51
52 def test_gettotaltimes():
53 result = gettotaltimes([
54 ('foo', 2, 17, [
55 ('bar', 4, 5, []),
56 ('bar', 7, 9, []),
57 ]),
58 ('bar', 20, 30, []),
59 ])
60 assert result == {None: 3, # the hole between 17 and 20
61 'foo': 15 - 1 - 2,
62 'bar': 1 + 2 + 10}