-import contextlib
import os
import re
import sys
ARTIFACTS_URL = "http://autobuild.buildroot.net/artefacts/"
+
def open_log_file(builddir, stage, logtofile=True):
"""
Open a file for logging and return its handler.
fhandle = sys.stdout
return fhandle
+
def filepath(relpath):
return os.path.join(os.getcwd(), "support/testing", relpath)
+
def download(dldir, filename):
finalpath = os.path.join(dldir, filename)
if os.path.exists(finalpath):
os.rename(tmpfile, finalpath)
return finalpath
+
def get_elf_arch_tag(builddir, prefix, fpath, tag):
"""
Runs the cross readelf on 'fpath', then extracts the value of tag 'tag'.
return m.group(1)
return None
+
def get_file_arch(builddir, prefix, fpath):
return get_elf_arch_tag(builddir, prefix, fpath, "Tag_CPU_arch")
+
def get_elf_prog_interpreter(builddir, prefix, fpath):
"""
Runs the cross readelf on 'fpath' to extract the program interpreter
# BR2_TARGET_ROOTFS_TAR is not set
"""
+
class BRTest(unittest.TestCase):
config = None
downloaddir = None
def show_msg(self, msg):
print "{} {:40s} {}".format(datetime.datetime.now().strftime("%H:%M:%S"),
self.testname, msg)
+
def setUp(self):
self.show_msg("Starting")
self.b = Builder(self.config, self.builddir, self.logtofile)
import infra
+
class Builder(object):
def __init__(self, config, builddir, logtofile):
self.config = '\n'.join([line.lstrip() for line in
from infra.basetest import BRTest
+
def main():
parser = argparse.ArgumentParser(description='Run Buildroot tests')
parser.add_argument('testname', nargs='*',
nose2.discover(argv=nose2_args)
+
if __name__ == "__main__":
sys.exit(main())
import infra.basetest
+
class TestPostScripts(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
import infra.basetest
+
def compare_file(file1, file2):
return subprocess.call(["cmp", file1, file2])
+
class TestRootfsOverlay(infra.basetest.BRTest):
rootfs_overlay_path = infra.filepath("tests/core/rootfs-overlay")
import infra.basetest
+
def boot_armv5_cpio(emulator, builddir):
img = os.path.join(builddir, "images", "rootfs.cpio")
emulator.boot(arch="armv5", kernel="builtin",
options=["-initrd", img])
emulator.login()
+
class TestNoTimezone(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
tz, _ = self.emulator.run("TZ=America/Los_Angeles date +%Z")
self.assertEqual(tz[0].strip(), "UTC")
+
class TestGlibcAllTimezone(infra.basetest.BRTest):
config = \
"""
tz, _ = self.emulator.run("TZ=Europe/Paris date +%Z")
self.assertEqual(tz[0].strip(), "CET")
+
class TestGlibcNonDefaultLimitedTimezone(infra.basetest.BRTest):
config = \
"""
CHECK_FS_TYPE_CMD = "mount | grep '/dev/root on / type {}'"
+
def dumpe2fs_run(builddir, image):
cmd = ["host/sbin/dumpe2fs", os.path.join("images", image)]
ret = subprocess.check_output(cmd,
env={"LANG": "C"})
return ret.strip().splitlines()
+
def dumpe2fs_getprop(out, prop):
for line in out:
fields = line.split(": ")
if fields[0] == prop:
return fields[1].strip()
+
def boot_img_and_check_fs_type(emulator, builddir, fs_type):
img = os.path.join(builddir, "images", "rootfs.{}".format(fs_type))
emulator.boot(arch="armv7",
_, exit_code = emulator.run(CHECK_FS_TYPE_CMD.format(fs_type))
return exit_code
+
class TestExt2(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
self.builddir, "ext2")
self.assertEqual(exit_code, 0)
+
class TestExt2r1(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
self.builddir, "ext2")
self.assertEqual(exit_code, 0)
+
class TestExt3(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
self.builddir, "ext3")
self.assertEqual(exit_code, 0)
+
class TestExt4(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
exit_code = boot_img_and_check_fs_type(self.emulator,
self.builddir, "ext4")
self.assertEqual(exit_code, 0)
-
-
# BR2_TARGET_ROOTFS_TAR is not set
""".format(infra.filepath("conf/minimal-x86-qemu-kernel.config"))
+
def test_mount_internal_external(emulator, builddir, internal=True):
img = os.path.join(builddir, "images", "rootfs.iso9660")
emulator.boot(arch="i386", options=["-cdrom", img])
_, exit_code = emulator.run(cmd)
return exit_code
+
def test_touch_file(emulator):
_, exit_code = emulator.run("touch test")
return exit_code
#
# Grub 2
-#
+
class TestIso9660Grub2External(infra.basetest.BRTest):
config = BASIC_CONFIG + \
exit_code = test_touch_file(self.emulator)
self.assertEqual(exit_code, 1)
+
class TestIso9660Grub2Internal(infra.basetest.BRTest):
config = BASIC_CONFIG + \
"""
#
# Syslinux
-#
+
class TestIso9660SyslinuxExternal(infra.basetest.BRTest):
config = BASIC_CONFIG + \
exit_code = test_touch_file(self.emulator)
self.assertEqual(exit_code, 1)
+
class TestIso9660SyslinuxInternal(infra.basetest.BRTest):
config = BASIC_CONFIG + \
"""
import infra.basetest
+
def jffs2dump_find_file(files_list, fname):
for file_name in files_list:
file_name = file_name.strip()
return True
return False
+
class TestJffs2(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
import infra.basetest
+
class TestSquashfs(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
import infra.basetest
+
class TestUbi(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
import infra.basetest
+
class TestYaffs2(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
infra.basetest.MINIMAL_CONFIG + \
import subprocess
import infra.basetest
+
class InitSystemBase(infra.basetest.BRTest):
def startEmulator(self, fs_type, kernel=None, dtb=None, init=None):
import infra.basetest
from tests.init.base import InitSystemBase as InitSystemBase
+
class InitSystemBusyboxBase(InitSystemBase):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
super(InitSystemBusyboxBase, self).checkInit("/bin/busybox")
-#-------------------------------------------------------------------------------
class TestInitSystemBusyboxRo(InitSystemBusyboxBase):
config = InitSystemBusyboxBase.config + \
"""
self.checkNetwork("eth0", 1)
-#-------------------------------------------------------------------------------
class TestInitSystemBusyboxRw(InitSystemBusyboxBase):
config = InitSystemBusyboxBase.config + \
"""
self.checkNetwork("eth0", 1)
-#-------------------------------------------------------------------------------
class TestInitSystemBusyboxRoNet(InitSystemBusyboxBase):
config = InitSystemBusyboxBase.config + \
"""
self.checkNetwork("eth0")
-#-------------------------------------------------------------------------------
class TestInitSystemBusyboxRwNet(InitSystemBusyboxBase):
config = InitSystemBusyboxBase.config + \
"""
import infra.basetest
from tests.init.base import InitSystemBase as InitSystemBase
+
class TestInitSystemNone(InitSystemBase):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
import infra.basetest
from tests.init.base import InitSystemBase as InitSystemBase
+
class InitSystemSystemdBase(InitSystemBase):
config = \
"""
super(InitSystemSystemdBase, self).checkInit("/lib/systemd/systemd")
-#-------------------------------------------------------------------------------
class TestInitSystemSystemdRoNetworkd(InitSystemSystemdBase):
config = InitSystemSystemdBase.config + \
"""
self.assertEqual(out[0], "foobar")
-#-------------------------------------------------------------------------------
class TestInitSystemSystemdRwNetworkd(InitSystemSystemdBase):
config = InitSystemSystemdBase.config + \
"""
self.checkNetwork("eth0")
-#-------------------------------------------------------------------------------
class TestInitSystemSystemdRoIfupdown(InitSystemSystemdBase):
config = InitSystemSystemdBase.config + \
"""
self.checkNetwork("eth0")
-#-------------------------------------------------------------------------------
class TestInitSystemSystemdRwIfupdown(InitSystemSystemdBase):
config = InitSystemSystemdBase.config + \
"""
self.checkNetwork("eth0")
-#-------------------------------------------------------------------------------
class TestInitSystemSystemdRoFull(InitSystemSystemdBase):
config = InitSystemSystemdBase.config + \
"""
self.checkNetwork("eth0")
-#-------------------------------------------------------------------------------
class TestInitSystemSystemdRwFull(InitSystemSystemdBase):
config = InitSystemSystemdBase.config + \
"""
import infra.basetest
+
class TestDropbear(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
-import os
-
from tests.package.test_python import TestPythonBase
#
# The following pythong tests are not being used here:
#
# - zlib_test: IPython does not return a non-zero code the way CPython
# does, so this test ends up being a false-negative
-#
+
+
class TestIPythonPy2(TestPythonBase):
config = TestPythonBase.config + \
"""
self.math_floor_test(40)
self.libc_time_test(40)
+
class TestIPythonPy3(TestPythonBase):
config = TestPythonBase.config + \
"""
self.login()
self.math_floor_test(40)
self.libc_time_test(40)
-
-
import infra.basetest
+
class TestPythonBase(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
_, exit_code = self.emulator.run(cmd, timeout)
self.assertEqual(exit_code, 1)
+
class TestPython2(TestPythonBase):
config = TestPythonBase.config + \
"""
BR2_PACKAGE_PYTHON=y
"""
+
def test_run(self):
self.login()
self.version_test("Python 2")
self.libc_time_test()
self.zlib_test()
+
class TestPython3(TestPythonBase):
config = TestPythonBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
"""
+
def test_run(self):
self.login()
self.version_test("Python 3")
# BR2_TARGET_ROOTFS_TAR is not set
"""
+
def has_broken_links(path):
for root, dirs, files in os.walk(path):
for f in files:
return True
return False
+
class TestExternalToolchain(infra.basetest.BRTest):
def common_check(self):
# Check for broken symlinks
interp_path = os.path.join(self.builddir, "target", interp[1:])
self.assertTrue(os.path.exists(interp_path))
+
class TestExternalToolchainSourceryArmv4(TestExternalToolchain):
config = BASIC_CONFIG + \
"""
options=["-initrd", img])
self.emulator.login()
+
class TestExternalToolchainSourceryArmv5(TestExternalToolchain):
config = BASIC_CONFIG + \
"""
options=["-initrd", img])
self.emulator.login()
+
class TestExternalToolchainSourceryArmv7(TestExternalToolchain):
config = BASIC_CONFIG + \
"""
options=["-initrd", img])
self.emulator.login()
+
class TestExternalToolchainLinaroArm(TestExternalToolchain):
config = BASIC_CONFIG + \
"""
options=["-initrd", img])
self.emulator.login()
+
class TestExternalToolchainBuildrootMusl(TestExternalToolchain):
config = BASIC_CONFIG + \
"""
options=["-initrd", img])
self.emulator.login()
+
class TestExternalToolchainCtngMusl(TestExternalToolchain):
config = BASIC_CONFIG + \
"""
options=["-initrd", img])
self.emulator.login()
+
class TestExternalToolchainBuildrootuClibc(TestExternalToolchain):
config = BASIC_CONFIG + \
"""
options=["-initrd", img])
self.emulator.login()
+
class TestExternalToolchainCCache(TestExternalToolchainBuildrootuClibc):
extraconfig = \
"""