]> git.proxmox.com Git - ceph.git/blame - ceph/src/seastar/test.py
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / test.py
CommitLineData
11fdf7f2
TL
1#!/usr/bin/env python3
2#
3# This file is open source software, licensed to you under the terms
4# of the Apache License, Version 2.0 (the "License"). See the NOTICE file
5# distributed with this work for additional information regarding copyright
6# ownership. You may not use this file except in compliance with the License.
7#
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
20import argparse
21import subprocess
22import seastar_cmake
23
24if __name__ == "__main__":
25
26 parser = argparse.ArgumentParser(description="Seastar test runner")
27 parser.add_argument('--fast', action="store_true", help="Run only fast tests")
28 parser.add_argument('--name', action="store", help="Run only test whose name contains given string")
29 parser.add_argument('--mode', choices=seastar_cmake.SUPPORTED_MODES, help="Run only tests for given build mode")
30 parser.add_argument('--timeout', action="store",default="300",type=int, help="timeout value for test execution")
31 parser.add_argument('--jenkins', action="store",help="jenkins output file prefix")
9f95a23c 32 parser.add_argument('--smp', '-c', action="store",default='2',type=int,help="Number of threads for multi-core tests")
11fdf7f2
TL
33 parser.add_argument('--verbose', '-v', action = 'store_true', default = False,
34 help = 'Verbose reporting')
35 args = parser.parse_args()
36
37 MODES = [args.mode] if args.mode else seastar_cmake.SUPPORTED_MODES
38
39 def run_tests(mode):
40 BUILD_PATH = seastar_cmake.BUILD_PATHS[mode]
41
42 # For convenience.
43 tr = seastar_cmake.translate_arg
44
45 TRANSLATED_CMAKE_ARGS = [
46 tr(args.timeout, 'TEST_TIMEOUT'),
47 tr(args.fast, 'EXECUTE_ONLY_FAST_TESTS'),
9f95a23c 48 tr(args.smp, 'UNIT_TEST_SMP'),
11fdf7f2
TL
49 tr(args.jenkins, 'JENKINS', value_when_none=''),
50 ]
51
52 # Modify the existing build by pointing to the build directory.
53 CMAKE_ARGS = ['cmake', BUILD_PATH] + TRANSLATED_CMAKE_ARGS
54 print(CMAKE_ARGS)
55 subprocess.check_call(CMAKE_ARGS, shell=False, cwd=seastar_cmake.ROOT_PATH)
56
9f95a23c 57 TRANSLATED_CTEST_ARGS = ['--output-on-failure']
11fdf7f2
TL
58 if args.verbose:
59 TRANSLATED_CTEST_ARGS += ['--verbose']
60 if args.name:
61 TRANSLATED_CTEST_ARGS += ['-R', args.name]
62
63 CTEST_ARGS = ['ctest', BUILD_PATH] + TRANSLATED_CTEST_ARGS
64 print(CTEST_ARGS)
65 subprocess.check_call(CTEST_ARGS, shell=False, cwd=BUILD_PATH)
66
67 for mode in MODES:
68 run_tests(mode)