testing/infra: Add BRConfigTest as superclass of BRTest
The git tests don't need to do a full build, they only need to do a configure and download and/or legal-info. More tests of that type will be added in the future. Therefore, we want to have a test base class that doesn't automatically do a full build in the setUp(). Add this new class as a superclass of the existing BRTest class, so we don't need to update existing tests. Only the code in run-tests that iterates over all subclasses of BRTest has to be adapted to use BRConfigTest instead. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@datacom.ind.br> Cc: Arnout Vandecappelle <arnout@mind.be> Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This commit is contained in:
parent
e0d540bdda
commit
0461ef4dea
|
@ -28,7 +28,7 @@ MINIMAL_CONFIG = \
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class BRTest(unittest.TestCase):
|
class BRConfigTest(unittest.TestCase):
|
||||||
config = None
|
config = None
|
||||||
br2_external = list()
|
br2_external = list()
|
||||||
downloaddir = None
|
downloaddir = None
|
||||||
|
@ -39,10 +39,9 @@ class BRTest(unittest.TestCase):
|
||||||
timeout_multiplier = 1
|
timeout_multiplier = 1
|
||||||
|
|
||||||
def __init__(self, names):
|
def __init__(self, names):
|
||||||
super(BRTest, self).__init__(names)
|
super(BRConfigTest, self).__init__(names)
|
||||||
self.testname = self.__class__.__name__
|
self.testname = self.__class__.__name__
|
||||||
self.builddir = self.outputdir and os.path.join(self.outputdir, self.testname)
|
self.builddir = self.outputdir and os.path.join(self.outputdir, self.testname)
|
||||||
self.emulator = None
|
|
||||||
self.config += '\nBR2_DL_DIR="{}"\n'.format(self.downloaddir)
|
self.config += '\nBR2_DL_DIR="{}"\n'.format(self.downloaddir)
|
||||||
self.config += "\nBR2_JLEVEL={}\n".format(self.jlevel)
|
self.config += "\nBR2_JLEVEL={}\n".format(self.jlevel)
|
||||||
|
|
||||||
|
@ -58,8 +57,23 @@ class BRTest(unittest.TestCase):
|
||||||
self.b.delete()
|
self.b.delete()
|
||||||
|
|
||||||
if not self.b.is_finished():
|
if not self.b.is_finished():
|
||||||
self.show_msg("Building")
|
|
||||||
self.b.configure(make_extra_opts=["BR2_EXTERNAL={}".format(":".join(self.br2_external))])
|
self.b.configure(make_extra_opts=["BR2_EXTERNAL={}".format(":".join(self.br2_external))])
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.show_msg("Cleaning up")
|
||||||
|
if self.b and not self.keepbuilds:
|
||||||
|
self.b.delete()
|
||||||
|
|
||||||
|
|
||||||
|
class BRTest(BRConfigTest):
|
||||||
|
def __init__(self, names):
|
||||||
|
super(BRTest, self).__init__(names)
|
||||||
|
self.emulator = None
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(BRTest, self).setUp()
|
||||||
|
if not self.b.is_finished():
|
||||||
|
self.show_msg("Building")
|
||||||
self.b.build()
|
self.b.build()
|
||||||
self.show_msg("Building done")
|
self.show_msg("Building done")
|
||||||
|
|
||||||
|
@ -67,8 +81,6 @@ class BRTest(unittest.TestCase):
|
||||||
self.logtofile, self.timeout_multiplier)
|
self.logtofile, self.timeout_multiplier)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.show_msg("Cleaning up")
|
|
||||||
if self.emulator:
|
if self.emulator:
|
||||||
self.emulator.stop()
|
self.emulator.stop()
|
||||||
if self.b and not self.keepbuilds:
|
super(BRTest, self).tearDown()
|
||||||
self.b.delete()
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import os
|
||||||
import nose2
|
import nose2
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
from infra.basetest import BRTest
|
from infra.basetest import BRConfigTest
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -38,7 +38,7 @@ def main():
|
||||||
test_dir = os.path.dirname(script_path)
|
test_dir = os.path.dirname(script_path)
|
||||||
|
|
||||||
if args.stdout:
|
if args.stdout:
|
||||||
BRTest.logtofile = False
|
BRConfigTest.logtofile = False
|
||||||
|
|
||||||
if args.list:
|
if args.list:
|
||||||
print("List of tests")
|
print("List of tests")
|
||||||
|
@ -57,7 +57,7 @@ def main():
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
BRTest.downloaddir = os.path.abspath(args.download)
|
BRConfigTest.downloaddir = os.path.abspath(args.download)
|
||||||
|
|
||||||
if args.output is None:
|
if args.output is None:
|
||||||
print("Missing output directory, please use -o/--output")
|
print("Missing output directory, please use -o/--output")
|
||||||
|
@ -68,7 +68,7 @@ def main():
|
||||||
if not os.path.exists(args.output):
|
if not os.path.exists(args.output):
|
||||||
os.mkdir(args.output)
|
os.mkdir(args.output)
|
||||||
|
|
||||||
BRTest.outputdir = os.path.abspath(args.output)
|
BRConfigTest.outputdir = os.path.abspath(args.output)
|
||||||
|
|
||||||
if args.all is False and len(args.testname) == 0:
|
if args.all is False and len(args.testname) == 0:
|
||||||
print("No test selected")
|
print("No test selected")
|
||||||
|
@ -76,7 +76,7 @@ def main():
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
BRTest.keepbuilds = args.keep
|
BRConfigTest.keepbuilds = args.keep
|
||||||
|
|
||||||
if args.testcases != 1:
|
if args.testcases != 1:
|
||||||
if args.testcases < 1:
|
if args.testcases < 1:
|
||||||
|
@ -89,7 +89,7 @@ def main():
|
||||||
each_testcase = br2_jlevel / args.testcases
|
each_testcase = br2_jlevel / args.testcases
|
||||||
if each_testcase < 1:
|
if each_testcase < 1:
|
||||||
each_testcase = 1
|
each_testcase = 1
|
||||||
BRTest.jlevel = each_testcase
|
BRConfigTest.jlevel = each_testcase
|
||||||
|
|
||||||
if args.jlevel:
|
if args.jlevel:
|
||||||
if args.jlevel < 0:
|
if args.jlevel < 0:
|
||||||
|
@ -98,14 +98,14 @@ def main():
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
# the user can override the auto calculated value
|
# the user can override the auto calculated value
|
||||||
BRTest.jlevel = args.jlevel
|
BRConfigTest.jlevel = args.jlevel
|
||||||
|
|
||||||
if args.timeout_multiplier < 1:
|
if args.timeout_multiplier < 1:
|
||||||
print("Invalid multiplier for timeout values")
|
print("Invalid multiplier for timeout values")
|
||||||
print("")
|
print("")
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
BRTest.timeout_multiplier = args.timeout_multiplier
|
BRConfigTest.timeout_multiplier = args.timeout_multiplier
|
||||||
|
|
||||||
nose2_args = ["-v",
|
nose2_args = ["-v",
|
||||||
"-N", str(args.testcases),
|
"-N", str(args.testcases),
|
||||||
|
|
Loading…
Reference in a new issue