blob: a71fd3bc796d54bdf11dcd1cbad4ace7176556ce [file] [log] [blame]
jeraldabraham5d4d7352014-03-28 02:49:04 -07001#!/usr/bin/python2
2import os
3import sys
4import glob
5import inspect
6import unittest
7from sets import Set
8
9def usage(testCases):
10 print "\nUSAGE:"
11 print " ./run_tests.py [OPTIONS]\n"
12 print " Run a subset of NFD integration test cases"
13 print " The test case(s) to be executed should be provided as command line option(s)"
14 print "\nOPTIONS:"
15 for testCase in testCases:
16 print " " + testCase
17 print " test_all - run all the above tests"
18 print " help - print this message and exit\n"
19
20
21def main():
22 cmd_subfolder = os.path.realpath(
23 os.path.abspath(os.path.join(os.path.split(
24 inspect.getfile(inspect.currentframe()))[0], "library_helpers")))
25 if cmd_subfolder not in sys.path:
26 sys.path.insert(0, cmd_subfolder)
27 validOptions = [ "test_all",
28 "help" ]
29 testCases = glob.glob('test_*')
30 validOptions.extend(testCases)
31
32 if len(sys.argv) > 1:
33 actionList = Set(sys.argv[1:])
34 optionStatus = 0
35 for action in actionList:
36 if action not in validOptions:
37 print "Invalid option provided - " + action
38 optionStatus = -1
39 break
40 if optionStatus == 0 and "help" not in actionList:
41 if "test_all" in actionList:
42 actionList.remove("test_all")
43 actionList = Set(testCases)
44 suiteList = []
45 for action in actionList:
46 cmd_subfolder = os.path.realpath(
47 os.path.abspath(os.path.join(os.path.split(
48 inspect.getfile(inspect.currentframe()))[0], action)))
49 if cmd_subfolder not in sys.path:
50 sys.path.insert(0, cmd_subfolder)
51 suiteList.append(
52 unittest.defaultTestLoader.loadTestsFromName(action + "." + action))
53 mainSuite = unittest.TestSuite(suiteList)
54 unittest.TextTestRunner().run(mainSuite)
55 else:
56 usage(testCases)
57 else:
58 usage(testCases)
59
60
61if __name__ == "__main__":
62 main()