Chris Masone | d6f38c8 | 2012-02-22 14:53:42 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # |
| 3 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | """Tool for enumerating the tests in a given suite. |
| 8 | |
| 9 | Given an autotest root directory and a suite name (e.g., bvt, regression), this |
| 10 | tool will print out the name of each test in that suite, one per line. |
| 11 | |
| 12 | Example: |
| 13 | $ ./site_utils/suite_enumerator.py -a /usr/local/autotest bvt 2>/dev/null |
| 14 | login_LoginSuccess |
| 15 | logging_CrashSender |
| 16 | login_BadAuthentication |
| 17 | |
| 18 | This is intended for use only with Chrome OS test suits that leverage the |
| 19 | dynamic suite infrastructure in server/cros/dynamic_suite.py. |
| 20 | """ |
| 21 | |
| 22 | import optparse, os, sys, time |
| 23 | import common |
| 24 | from autotest_lib.server.cros import control_file_getter, dynamic_suite |
| 25 | |
| 26 | def parse_options(): |
| 27 | usage = "usage: %prog [options] suite_name" |
| 28 | parser = optparse.OptionParser(usage=usage) |
| 29 | parser.add_option('-a', '--autotest_dir', dest='autotest_dir', |
| 30 | default=os.path.abspath( |
| 31 | os.path.join('..', os.path.dirname(__file__))), |
| 32 | help='Directory under which to search for tests.'\ |
| 33 | ' (e.g. /usr/local/autotest)') |
| 34 | parser.add_option('-s', '--stable_only', dest='add_experimental', |
| 35 | action='store_false', default=True, |
| 36 | help='List only tests that are not labeled experimental.') |
| 37 | options, args = parser.parse_args() |
| 38 | return parser, options, args |
| 39 | |
| 40 | |
| 41 | def main(): |
| 42 | parser, options, args = parse_options() |
| 43 | if not args or len(args) != 1: |
| 44 | parser.print_help() |
| 45 | return |
| 46 | |
| 47 | fs_getter = dynamic_suite.Suite.create_fs_getter(options.autotest_dir) |
| 48 | suite = dynamic_suite.Suite.create_from_name(args[0], '', fs_getter) |
| 49 | for test in suite.tests: |
Chris Masone | e8a4eff | 2012-02-28 16:33:43 -0800 | [diff] [blame] | 50 | print test.path |
Chris Masone | d6f38c8 | 2012-02-22 14:53:42 -0800 | [diff] [blame] | 51 | |
| 52 | |
| 53 | if __name__ == "__main__": |
| 54 | sys.exit(main()) |