xref: /aosp_15_r20/external/autotest/site_utils/suite_preprocessor.py (revision 9c5db1993ded3edbeafc8092d69fe5de2ee02df7)
1*9c5db199SXin Li#!/usr/bin/python3
2*9c5db199SXin Li#
3*9c5db199SXin Li# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
4*9c5db199SXin Li# Use of this source code is governed by a BSD-style license that can be
5*9c5db199SXin Li# found in the LICENSE file.
6*9c5db199SXin Li
7*9c5db199SXin Li"""
8*9c5db199SXin LiDeprecated tool for preprocessing tests to determine their DEPENDENCIES.
9*9c5db199SXin Li"""
10*9c5db199SXin Li
11*9c5db199SXin Lifrom __future__ import absolute_import
12*9c5db199SXin Lifrom __future__ import division
13*9c5db199SXin Lifrom __future__ import print_function
14*9c5db199SXin Liimport optparse, os, sys
15*9c5db199SXin Liimport common
16*9c5db199SXin Li
17*9c5db199SXin Li
18*9c5db199SXin Lidef parse_options():
19*9c5db199SXin Li    """Parse command line arguments."""
20*9c5db199SXin Li    parser = optparse.OptionParser()
21*9c5db199SXin Li    parser.add_option('-a', '--autotest_dir', dest='autotest_dir',
22*9c5db199SXin Li                      default=os.path.abspath(
23*9c5db199SXin Li                          os.path.join(os.path.dirname(__file__), '..')),
24*9c5db199SXin Li                      help="Directory under which to search for tests."\
25*9c5db199SXin Li                           " (e.g. /usr/local/autotest).  Defaults to '..'")
26*9c5db199SXin Li    parser.add_option('-o', '--output_file', dest='output_file',
27*9c5db199SXin Li                      default=None,
28*9c5db199SXin Li                      help='File into which to write collected test info.'\
29*9c5db199SXin Li                           '  Defaults to stdout.')
30*9c5db199SXin Li    parser.add_option('-e', '--extra_autotest_dirs',
31*9c5db199SXin Li                      dest='extra_autotest_dirs', default=None,
32*9c5db199SXin Li                      help="A list of directories under which to search for "
33*9c5db199SXin Li                           "extra Autotest tests. Defaults to None.")
34*9c5db199SXin Li    options, _ = parser.parse_args()
35*9c5db199SXin Li    return options
36*9c5db199SXin Li
37*9c5db199SXin Li
38*9c5db199SXin Lidef main():
39*9c5db199SXin Li    """Main function."""
40*9c5db199SXin Li    options = parse_options()
41*9c5db199SXin Li
42*9c5db199SXin Li    test_deps = {}
43*9c5db199SXin Li
44*9c5db199SXin Li    if options.output_file:
45*9c5db199SXin Li        with open(options.output_file, 'w') as file_obj:
46*9c5db199SXin Li            file_obj.write('%r' % test_deps)
47*9c5db199SXin Li    else:
48*9c5db199SXin Li        print('%r' % test_deps)
49*9c5db199SXin Li
50*9c5db199SXin Li
51*9c5db199SXin Liif __name__ == "__main__":
52*9c5db199SXin Li    sys.exit(main())
53