]>
git.proxmox.com Git - ceph.git/blob - ceph/src/zstd/build/meson/tests/valgrindTest.py
2 # #############################################################################
3 # Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
6 # This source code is licensed under both the BSD-style license (found in the
7 # LICENSE file in the root directory of this source tree) and the GPLv2 (found
8 # in the COPYING file in the root directory of this source tree).
9 # #############################################################################
15 def valgrindTest(valgrind
, datagen
, fuzzer
, zstd
, fullbench
):
16 VALGRIND_ARGS
= [valgrind
, '--leak-check=full', '--show-leak-kinds=all', '--error-exitcode=1']
18 print('\n ---- valgrind tests : memory analyzer ----')
20 subprocess
.check_call([*VALGRIND_ARGS
, datagen
, '-g50M'], stdout
=subprocess
.DEVNULL
)
22 if subprocess
.call([*VALGRIND_ARGS
, zstd
],
23 stdout
=subprocess
.DEVNULL
) == 0:
24 raise subprocess
.CalledProcessError('zstd without argument should have failed')
26 with subprocess
.Popen([datagen
, '-g80'], stdout
=subprocess
.PIPE
) as p1
, \
27 subprocess
.Popen([*VALGRIND_ARGS
, zstd
, '-', '-c'],
29 stdout
=subprocess
.DEVNULL
) as p2
:
30 p1
.stdout
.close() # Allow p1 to receive a SIGPIPE if p2 exits.
32 if p2
.returncode
!= 0:
33 raise subprocess
.CalledProcessError()
35 with subprocess
.Popen([datagen
, '-g16KB'], stdout
=subprocess
.PIPE
) as p1
, \
36 subprocess
.Popen([*VALGRIND_ARGS
, zstd
, '-vf', '-', '-c'],
38 stdout
=subprocess
.DEVNULL
) as p2
:
41 if p2
.returncode
!= 0:
42 raise subprocess
.CalledProcessError()
44 with tempfile
.NamedTemporaryFile() as tmp_fd
:
45 with subprocess
.Popen([datagen
, '-g2930KB'], stdout
=subprocess
.PIPE
) as p1
, \
46 subprocess
.Popen([*VALGRIND_ARGS
, zstd
, '-5', '-vf', '-', '-o', tmp_fd
.name
],
47 stdin
=p1
.stdout
) as p2
:
50 if p2
.returncode
!= 0:
51 raise subprocess
.CalledProcessError()
53 subprocess
.check_call([*VALGRIND_ARGS
, zstd
, '-vdf', tmp_fd
.name
, '-c'],
54 stdout
=subprocess
.DEVNULL
)
56 with subprocess
.Popen([datagen
, '-g64MB'], stdout
=subprocess
.PIPE
) as p1
, \
57 subprocess
.Popen([*VALGRIND_ARGS
, zstd
, '-vf', '-', '-c'],
59 stdout
=subprocess
.DEVNULL
) as p2
:
62 if p2
.returncode
!= 0:
63 raise subprocess
.CalledProcessError()
65 subprocess
.check_call([*VALGRIND_ARGS
, fuzzer
, '-T1mn', '-t1'])
66 subprocess
.check_call([*VALGRIND_ARGS
, fullbench
, '-i1'])
71 parser
= argparse
.ArgumentParser(description
='Valgrind tests : memory analyzer')
72 parser
.add_argument('valgrind', help='valgrind path')
73 parser
.add_argument('zstd', help='zstd path')
74 parser
.add_argument('datagen', help='datagen path')
75 parser
.add_argument('fuzzer', help='fuzzer path')
76 parser
.add_argument('fullbench', help='fullbench path')
78 args
= parser
.parse_args()
80 valgrind
= args
.valgrind
82 datagen
= args
.datagen
84 fullbench
= args
.fullbench
86 valgrindTest(valgrind
, datagen
, fuzzer
, zstd
, fullbench
)
89 if __name__
== '__main__':