1#!/router/bin/python
2
3__copyright__ = "Copyright 2014"
4
5
6
7import os
8import sys
9import nose_outer_packages
10import nose
11from nose.plugins import Plugin
12from rednose import RedNose
13import termstyle
14import control_plane_general_test
15
16class TRexCPConfiguringPlugin(Plugin):
17    def options(self, parser, env = os.environ):
18        super(TRexCPConfiguringPlugin, self).options(parser, env)
19        parser.add_option('-t', '--trex-server', action='store',
20                            dest='trex_server', default='trex-dan',
21                            help='Specify TRex server hostname. This server will be used to test control-plane functionality.')
22
23    def configure(self, options, conf):
24        if options.trex_server:
25        	self.trex_server = options.trex_server
26
27    def begin (self):
28        # initialize CTRexCP global testing class, to be used by and accessible all tests
29        print "assigned trex_server name"
30        control_plane_general_test.CTRexCP.trex_server = self.trex_server
31
32    def finalize(self, result):
33        pass
34
35
36
37if __name__ == "__main__":
38
39    # setting defaults. By default we run all the test suite
40    specific_tests    = False
41    disableLogCapture = False
42    long_test         = False
43    report_dir        = "reports"
44
45    nose_argv= sys.argv + ['-s', '-v', '--exe', '--rednose', '--detailed-errors']
46
47    try:
48        result = nose.run(argv = nose_argv, addplugins = [RedNose(), TRexCPConfiguringPlugin()])
49        if (result == True):
50            print termstyle.green("""
51                     ..::''''::..
52                   .;''        ``;.
53                  ::    ::  ::    ::
54                 ::     ::  ::     ::
55                 ::     ::  ::     ::
56                 :: .:' ::  :: `:. ::
57                 ::  :          :  ::
58                  :: `:.      .:' ::
59                   `;..``::::''..;'
60                     ``::,,,,::''
61
62                   ___  ___   __________
63                  / _ \/ _ | / __/ __/ /
64                 / ___/ __ |_\ \_\ \/_/
65                /_/  /_/ |_/___/___(_)
66
67            """)
68            sys.exit(0)
69        else:
70            sys.exit(-1)
71
72    finally:
73        pass