]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - support/testing/infra/basetest.py
support/testing: fix code style
[coffee/buildroot.git] / support / testing / infra / basetest.py
1 import unittest
2 import os
3 import datetime
4
5 from infra.builder import Builder
6 from infra.emulator import Emulator
7
8 BASIC_TOOLCHAIN_CONFIG = \
9     """
10     BR2_arm=y
11     BR2_TOOLCHAIN_EXTERNAL=y
12     BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
13     BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
14     BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2015.05-1190-g4a48479.tar.bz2"
15     BR2_TOOLCHAIN_EXTERNAL_GCC_4_7=y
16     BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
17     BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
18     # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
19     BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
20     BR2_TOOLCHAIN_EXTERNAL_CXX=y
21     """
22
23 MINIMAL_CONFIG = \
24     """
25     BR2_INIT_NONE=y
26     BR2_SYSTEM_BIN_SH_NONE=y
27     # BR2_PACKAGE_BUSYBOX is not set
28     # BR2_TARGET_ROOTFS_TAR is not set
29     """
30
31
32 class BRTest(unittest.TestCase):
33     config = None
34     downloaddir = None
35     outputdir = None
36     logtofile = True
37     keepbuilds = False
38     jlevel = 0
39     timeout_multiplier = 1
40
41     def __init__(self, names):
42         super(BRTest, self).__init__(names)
43         self.testname = self.__class__.__name__
44         self.builddir = self.outputdir and os.path.join(self.outputdir, self.testname)
45         self.emulator = None
46         self.config += "\nBR2_JLEVEL={}\n".format(self.jlevel)
47
48     def show_msg(self, msg):
49         print "{} {:40s} {}".format(datetime.datetime.now().strftime("%H:%M:%S"),
50                                     self.testname, msg)
51
52     def setUp(self):
53         self.show_msg("Starting")
54         self.b = Builder(self.config, self.builddir, self.logtofile)
55
56         if not self.keepbuilds:
57             self.b.delete()
58
59         if not self.b.is_finished():
60             self.show_msg("Building")
61             self.b.build()
62             self.show_msg("Building done")
63
64         self.emulator = Emulator(self.builddir, self.downloaddir,
65                                  self.logtofile, self.timeout_multiplier)
66
67     def tearDown(self):
68         self.show_msg("Cleaning up")
69         if self.emulator:
70             self.emulator.stop()
71         if self.b and not self.keepbuilds:
72             self.b.delete()