Skip to content

Commit f38c96a

Browse files
committed
check if tsan or asan log is not empty in functional tests
To help find the problems at CI and in general case not to mute them Signed-off-by: roman khapov <[email protected]>
1 parent 5a8d10e commit f38c96a

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

docker/functional/bin/ody-stop

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,51 @@ import time
55
import signal
66
import subprocess
77

8+
ASAN_LOG_PREFIX = '/asan-output.log'
9+
TSAN_LOG_PREFIX = '/tsan-output.log'
10+
11+
12+
def check_sanitizer_log_is_valid(pid, prefix):
13+
filename = f'{prefix}.{pid}'
14+
if not os.path.exists(filename) or os.path.getsize(filename) == 0:
15+
return True
16+
17+
with open(filename, 'r') as asan_log:
18+
print(f'Found non-empty {filename} log:')
19+
print(asan_log.read())
20+
return False
21+
22+
23+
def asan_log_is_valid(pid):
24+
# ASAN_OPITONS was set to this log_prefix in docker-compose.yml
25+
return check_sanitizer_log_is_valid(pid, ASAN_LOG_PREFIX)
26+
27+
28+
def tsan_log_is_valid(pid):
29+
# TSAN_OPITONS was set to this log_prefix in docker-compose.yml
30+
return check_sanitizer_log_is_valid(pid, TSAN_LOG_PREFIX)
31+
832

933
def get_odyssey_pids():
10-
print(subprocess.check_output('ps aux | grep odyssey', shell=True).decode('utf-8'))
34+
print(subprocess.check_output(
35+
'ps aux | grep odyssey', shell=True).decode('utf-8'))
1136

1237
try:
1338
return list(map(int, subprocess.check_output(['pgrep', 'odyssey']).split()))
1439
except subprocess.CalledProcessError:
1540
# non-zero exit code means that there is no odyssey pids
1641
return []
1742

43+
1844
def terminate_gracefully(pid, timeout):
1945
try:
2046
os.kill(pid, signal.SIGTERM)
2147
except ProcessLookupError:
2248
print(f'Process {pid} already finished or doesnt ever existed')
2349
return
2450

25-
print(f'Waiting {timeout} seconds to {pid} finish after SIGTERM...', end='')
51+
print(f'Waiting {timeout} seconds to {
52+
pid} finish after SIGTERM...', end='')
2653

2754
start = time.time()
2855
finished = False
@@ -56,10 +83,15 @@ def main():
5683
for pid in pids:
5784
if not terminate_gracefully(pid, timeout):
5885
print(f'Process {pid} didnt finish within {timeout} seconds')
59-
print(subprocess.check_output(['gdb', '-p', str(pid), '--batch', '-ex', 't a a bt', '-ex', 'source /gdb.py', 'mmcoro all bt']))
86+
print(subprocess.check_output(
87+
['gdb', '-p', str(pid), '--batch', '-ex', 't a a bt', '-ex', 'source /gdb.py', 'mmcoro all bt']))
88+
exit(1)
89+
90+
if not asan_log_is_valid(pid) or not tsan_log_is_valid(pid):
6091
exit(1)
6192

6293
exit(0)
6394

95+
6496
if __name__ == "__main__":
6597
main()

docker/functional/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ services:
1717
command: ["-k", "${ODYSSEY_FUNCTIONAL_TESTS_SELECTOR:-}"]
1818
environment:
1919
CMAKE_BUILD_TYPE: "${CMAKE_BUILD_TYPE:-Debug}"
20+
ASAN_OPTIONS: "log_path=/asan-output.log fast_unwind_on_malloc=0"
21+
TSAN_OPTIONS: "log_path=/tsan-output.log"
2022
volumes:
2123
- /var/run/docker.sock:/var/run/docker.sock
2224
ports:

0 commit comments

Comments
 (0)