backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / tests / integrated / run_test.py
1 # Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2016 Fumihiko Kakuma <kakuma at valinux co jp>
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 from __future__ import absolute_import
18
19 import logging
20 import os
21 import sys
22 import unittest
23
24 from ryu import log
25
26
27 def load_tests(loader, tests, pattern):
28     dirname = os.path.dirname(os.path.abspath(__file__))
29     base_path = os.path.abspath(dirname + '/../../..')
30     suite = unittest.TestSuite()
31     for test_dir in ['ryu/tests/integrated/bgp']:
32         if not pattern:
33             suite.addTests(loader.discover(test_dir,
34                                            top_level_dir=base_path))
35         else:
36             suite.addTests(loader.discover(test_dir, pattern=pattern,
37                                            top_level_dir=base_path))
38     return suite
39
40
41 if __name__ == '__main__':
42     log.early_init_log(logging.DEBUG)
43     log.init_log()
44     LOG = logging.getLogger(__name__)
45     pattern = None
46     if len(sys.argv) == 2:
47         pattern = sys.argv[1]
48     loader = unittest.defaultTestLoader
49     suite = load_tests(loader, None, pattern)
50     res = unittest.TextTestRunner(verbosity=2).run(suite)
51     ret = 0
52     if res.errors or res.failures:
53         ret = 1
54     sys.exit(ret)