1#!/usr/bin/env python
2#
3# Copyright (C) 2020 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17import argparse
18import os
19import sys
20
21import ltp_test_cases
22from common import filter_utils
23
24def run(arch: str, n_bit: int, is_low_mem: bool, is_hwasan: bool, run_staging: bool, output_file: str):
25
26    ltp_tests = ltp_test_cases.LtpTestCases(None)
27
28    test_filter = filter_utils.Filter()
29    ltp_tests.GenConfig(
30        arch,
31        n_bit,
32        test_filter,
33        output_file=output_file,
34        run_staging=run_staging,
35        is_low_mem=is_low_mem,
36        is_hwasan=is_hwasan)
37
38if __name__ == '__main__':
39    arg_parser = argparse.ArgumentParser(
40        description='Generate LTP configuration files for VTS')
41    arg_parser.add_argument('--arch',
42                            dest='arch',
43                            type=str,
44                            choices=['arm', 'riscv', 'x86'],
45                            required=True,
46                            help="Target device architecture")
47    arg_parser.add_argument('--bitness',
48                            dest='bitness',
49                            type=int,
50                            choices=[32, 64],
51                            required=True,
52                            help="Target device architecture bitness")
53    arg_parser.add_argument('--low-mem',
54                            dest='is_low_mem',
55                            type=str,
56                            choices=['True', 'False'],
57                            default='False',
58                            help="Target device is low memory device")
59    arg_parser.add_argument('--hwasan',
60                            dest='is_hwasan',
61                            type=str,
62                            choices=['True', 'False'],
63                            default='False',
64                            help="Target device is hwasan")
65    arg_parser.add_argument('--staging',
66                            dest='run_staging',
67                            type=str,
68                            choices=['True', 'False'],
69                            default='False',
70                            help="Run all the tests, except from the disabled ones")
71    arg_parser.add_argument('output_file_path',
72                            help="Path for the output file")
73    args = arg_parser.parse_args()
74
75    run(arch=args.arch,
76        n_bit=str(args.bitness),
77        is_low_mem=args.is_low_mem == 'True',
78        is_hwasan=args.is_hwasan == 'True',
79        run_staging=args.run_staging == 'True',
80        output_file=args.output_file_path)
81