-
Notifications
You must be signed in to change notification settings - Fork 3
/
basetest.py
63 lines (58 loc) · 2.03 KB
/
basetest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import unittest
import os
import subprocess
import configtest
import datetime
from builder import Builder
from system import System
basic_toolchain_config = """
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2015.05.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_0=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
"""
minimal_config = """
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
# BR2_TARGET_ROOTFS_TAR is not set
"""
class BRTest(unittest.TestCase):
def showMsg(self, msg):
print "[%s/%s/%s] %s" % (self.testname, self.testinstance,
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
msg)
def setUp(self):
if os.getenv("REUSE_BUILD"):
self.builddir = os.getenv("REUSE_BUILD").rstrip("/")
skip_build = True
else:
skip_build = False
b = subprocess.check_output(["mktemp", "-d", "buildroot.XXXXX"],
cwd=configtest.builddir)
b = b.strip()
self.builddir = os.path.join(configtest.builddir, b)
self.testname = self.__class__.__name__
self.testinstance = os.path.basename(self.builddir)
self.buildlog = self.builddir + "-build.log"
self.runlog = self.builddir + "-run.log"
self.s = None
self.showMsg("Starting")
self.b = Builder(self.__class__.config, self.builddir, self.buildlog)
if not skip_build:
self.showMsg("Building")
self.b.build()
self.showMsg("Building done")
self.s = System(self.runlog)
def tearDown(self):
self.showMsg("Cleaning up")
if self.s:
self.s.stop()
if self.b and os.getenv("KEEP_BUILD"):
self.b.delete()