forked from LLNL/Caliper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_log.py
95 lines (71 loc) · 2.5 KB
/
test_log.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
90
91
92
93
94
95
# Logging tests
import unittest
import calipertest as cat
class CaliperLogTest(unittest.TestCase):
""" Caliper Log test cases """
def test_log_verbose(self):
target_cmd = [ './ci_test_basic' ]
env = { 'CALI_LOG_VERBOSITY' : '3',
'CALI_LOG_LOGFILE' : 'stdout'
}
log_targets = [
'== CALIPER: Releasing Caliper thread data',
'Process blackboard',
'Thread blackboard',
'Metadata tree',
'Metadata memory pool'
]
report_out,_ = cat.run_test(target_cmd, env)
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_cali_config_error_msg(self):
target_cmd = [ './ci_test_basic' ]
env = {
'CALI_LOG_VERBOSITY' : '0',
'CALI_LOG_LOGFILE' : 'stdout',
'CALI_CONFIG' : 'blagarbl'
}
log_targets = [
'== CALIPER: CALI_CONFIG: error: Unknown config or parameter: blagarbl'
]
report_out,_ = cat.run_test(target_cmd, env)
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_scope_parse_error_msgs(self):
target_cmd = [ './ci_test_basic' ]
env = {
'CALI_LOG_VERBOSITY' : '0',
'CALI_LOG_LOGFILE' : 'stdout',
'CALI_CALIPER_ATTRIBUTE_DEFAULT_SCOPE' : 'bar'
}
log_targets = [
'Invalid value "bar" for CALI_CALIPER_ATTRIBUTE_DEFAULT_SCOPE'
]
report_out,_ = cat.run_test(target_cmd, env)
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_log_silent(self):
target_cmd = [ './ci_test_basic' ]
env = { 'CALI_LOG_VERBOSITY' : '0',
'CALI_LOG_LOGFILE' : 'stdout'
}
report_out,_ = cat.run_test(target_cmd, env)
lines = report_out.decode().splitlines()
self.assertTrue(len(lines) == 0)
if __name__ == "__main__":
unittest.main()