forked from LLNL/Caliper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_textlog.py
89 lines (70 loc) · 2.65 KB
/
test_textlog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Tests for the textlog service
import unittest
import calipertest as cat
class CaliperTextlogTest(unittest.TestCase):
""" Caliper textlog test cases """
def test_textlog_with_end_event(self):
target_cmd = [ './ci_test_macros' ]
caliper_config = {
'CALI_SERVICES_ENABLE' : 'event,textlog',
'CALI_TEXTLOG_TRIGGER' : 'iteration#main\\ loop',
'CALI_TEXTLOG_FORMATSTRING' : '%region% iteration: %[2]iteration#main loop%',
'CALI_LOG_VERBOSITY' : '0',
}
log_targets = [
'main iteration: 0',
'main iteration: 1',
'main iteration: 2',
'main iteration: 3'
]
report_out,_ = cat.run_test(target_cmd, caliper_config)
lines = report_out.decode().splitlines()
for target in log_targets:
for line in lines:
if target in line:
break
else:
self.fail('%s not found in log' % target)
def test_textlog_with_iteration_event(self):
target_cmd = [ './ci_test_macros' ]
caliper_config = {
'CALI_SERVICES_ENABLE' : 'loop_monitor,textlog',
'CALI_LOOP_MONITOR_ITERATION_INTERVAL' : '1',
'CALI_TEXTLOG_TRIGGER' : 'loop.start_iteration',
'CALI_TEXTLOG_FORMATSTRING' : '%region% iteration: %[2]loop.start_iteration%',
'CALI_LOG_VERBOSITY' : '0',
}
log_targets = [
'main iteration: 0',
'main iteration: 1',
'main iteration: 2',
'main iteration: 3'
]
report_out,_ = cat.run_test(target_cmd, caliper_config)
lines = report_out.decode().splitlines()
for target in log_targets:
for line in lines:
if target in line:
break
else:
self.fail('%s not found in log' % target)
def test_textlog_autostring(self):
target_cmd = [ './ci_test_macros' ]
caliper_config = {
'CALI_SERVICES_ENABLE' : 'event,textlog,timestamp',
'CALI_TEXTLOG_TRIGGER' : 'loop',
'CALI_LOG_VERBOSITY' : '0',
}
log_targets = [
'loop=main loop/fooloop'
]
report_out,_ = cat.run_test(target_cmd, caliper_config)
lines = report_out.decode().splitlines()
for target in log_targets:
for line in lines:
if target in line:
break
else:
self.fail('%s not found in log' % target)
if __name__ == "__main__":
unittest.main()