]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - support/testing/infra/basetest.py
754922692cc2a9627fbd13d0b24ab0330fe12848
[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-2017.05-1078-g95b1dae.tar.bz2"
15     BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=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_CXX=y
20     """
21
22 MINIMAL_CONFIG = \
23     """
24     BR2_INIT_NONE=y
25     BR2_SYSTEM_BIN_SH_NONE=y
26     # BR2_PACKAGE_BUSYBOX is not set
27     # BR2_TARGET_ROOTFS_TAR is not set
28     """
29
30
31 class BRTest(unittest.TestCase):
32     config = None
33     downloaddir = None
34     outputdir = None
35     logtofile = True
36     keepbuilds = False
37     jlevel = 0
38     timeout_multiplier = 1
39
40     def __init__(self, names):
41         super(BRTest, self).__init__(names)
42         self.testname = self.__class__.__name__
43         self.builddir = self.outputdir and os.path.join(self.outputdir, self.testname)
44         self.emulator = None
45         self.config += "\nBR2_JLEVEL={}\n".format(self.jlevel)
46
47     def show_msg(self, msg):
48         print "{} {:40s} {}".format(datetime.datetime.now().strftime("%H:%M:%S"),
49                                     self.testname, msg)
50
51     def setUp(self):
52         self.show_msg("Starting")
53         self.b = Builder(self.config, self.builddir, self.logtofile)
54
55         if not self.keepbuilds:
56             self.b.delete()
57
58         if not self.b.is_finished():
59             self.show_msg("Building")
60             self.b.build()
61             self.show_msg("Building done")
62
63         self.emulator = Emulator(self.builddir, self.downloaddir,
64                                  self.logtofile, self.timeout_multiplier)
65
66     def tearDown(self):
67         self.show_msg("Cleaning up")
68         if self.emulator:
69             self.emulator.stop()
70         if self.b and not self.keepbuilds:
71             self.b.delete()