Initial Commit
- initial default booting image
This commit is contained in:
1
support/testing/conf/busybox-for-old-toolchains.cfg
Normal file
1
support/testing/conf/busybox-for-old-toolchains.cfg
Normal file
@@ -0,0 +1 @@
|
||||
# CONFIG_USE_BB_CRYPT_YES is not set
|
||||
96
support/testing/conf/docker-compose-kernel.config
Normal file
96
support/testing/conf/docker-compose-kernel.config
Normal file
@@ -0,0 +1,96 @@
|
||||
CONFIG_SYSVIPC=y
|
||||
CONFIG_POSIX_MQUEUE=y
|
||||
# CONFIG_CROSS_MEMORY_ATTACH is not set
|
||||
CONFIG_HIGH_RES_TIMERS=y
|
||||
CONFIG_BPF_SYSCALL=y
|
||||
CONFIG_IKCONFIG=y
|
||||
CONFIG_IKCONFIG_PROC=y
|
||||
CONFIG_CGROUPS=y
|
||||
CONFIG_MEMCG=y
|
||||
CONFIG_BLK_CGROUP=y
|
||||
CONFIG_CGROUP_SCHED=y
|
||||
CONFIG_CGROUP_PIDS=y
|
||||
CONFIG_CGROUP_FREEZER=y
|
||||
CONFIG_CPUSETS=y
|
||||
CONFIG_CGROUP_DEVICE=y
|
||||
CONFIG_CGROUP_CPUACCT=y
|
||||
CONFIG_CGROUP_BPF=y
|
||||
CONFIG_NAMESPACES=y
|
||||
CONFIG_USER_NS=y
|
||||
CONFIG_SMP=y
|
||||
# CONFIG_X86_EXTENDED_PLATFORM is not set
|
||||
# CONFIG_X86_MCE is not set
|
||||
# CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS is not set
|
||||
CONFIG_LEGACY_VSYSCALL_NONE=y
|
||||
# CONFIG_SUSPEND is not set
|
||||
# CONFIG_ACPI is not set
|
||||
CONFIG_CPU_IDLE=y
|
||||
# CONFIG_VIRTUALIZATION is not set
|
||||
# CONFIG_GCC_PLUGINS is not set
|
||||
CONFIG_BLK_DEV_THROTTLING=y
|
||||
# CONFIG_MQ_IOSCHED_DEADLINE is not set
|
||||
# CONFIG_MQ_IOSCHED_KYBER is not set
|
||||
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
|
||||
# CONFIG_SWAP is not set
|
||||
# CONFIG_COMPAT_BRK is not set
|
||||
CONFIG_TRANSPARENT_HUGEPAGE=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_PACKET=y
|
||||
CONFIG_UNIX=y
|
||||
CONFIG_INET=y
|
||||
CONFIG_IP_MULTICAST=y
|
||||
CONFIG_IP_ADVANCED_ROUTER=y
|
||||
# CONFIG_IPV6_SIT is not set
|
||||
CONFIG_NETFILTER=y
|
||||
CONFIG_BRIDGE_NETFILTER=y
|
||||
CONFIG_NF_CONNTRACK=y
|
||||
CONFIG_NETFILTER_XTABLES_LEGACY=y
|
||||
CONFIG_NETFILTER_XT_MARK=y
|
||||
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
|
||||
CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
|
||||
CONFIG_NETFILTER_XT_MATCH_IPVS=y
|
||||
CONFIG_IP_VS=y
|
||||
CONFIG_IP_VS_RR=y
|
||||
CONFIG_IP_VS_NFCT=y
|
||||
CONFIG_IP_NF_IPTABLES=y
|
||||
CONFIG_IP_NF_NAT=y
|
||||
CONFIG_IP_NF_TARGET_MASQUERADE=y
|
||||
CONFIG_IP_NF_RAW=y
|
||||
CONFIG_BRIDGE=y
|
||||
# CONFIG_WIRELESS is not set
|
||||
CONFIG_PCI=y
|
||||
CONFIG_DEVTMPFS=y
|
||||
CONFIG_DEVTMPFS_MOUNT=y
|
||||
CONFIG_VIRTIO_BLK=y
|
||||
CONFIG_NETDEVICES=y
|
||||
CONFIG_TUN=y
|
||||
CONFIG_VETH=y
|
||||
CONFIG_VIRTIO_NET=y
|
||||
# CONFIG_ETHERNET is not set
|
||||
# CONFIG_WLAN is not set
|
||||
# CONFIG_INPUT_KEYBOARD is not set
|
||||
# CONFIG_INPUT_MOUSE is not set
|
||||
# CONFIG_SERIO is not set
|
||||
CONFIG_VT_HW_CONSOLE_BINDING=y
|
||||
CONFIG_SERIAL_8250=y
|
||||
CONFIG_SERIAL_8250_CONSOLE=y
|
||||
# CONFIG_HW_RANDOM_INTEL is not set
|
||||
# CONFIG_HW_RANDOM_AMD is not set
|
||||
# CONFIG_HW_RANDOM_VIA is not set
|
||||
CONFIG_HW_RANDOM_VIRTIO=y
|
||||
# CONFIG_DEVMEM is not set
|
||||
# CONFIG_HWMON is not set
|
||||
# CONFIG_USB_SUPPORT is not set
|
||||
CONFIG_RTC_CLASS=y
|
||||
CONFIG_VIRTIO_PCI=y
|
||||
CONFIG_VIRTIO_MMIO=y
|
||||
# CONFIG_X86_PLATFORM_DEVICES is not set
|
||||
# CONFIG_IOMMU_SUPPORT is not set
|
||||
CONFIG_EXT4_FS=y
|
||||
CONFIG_OVERLAY_FS=y
|
||||
CONFIG_TMPFS=y
|
||||
# CONFIG_MISC_FILESYSTEMS is not set
|
||||
# CONFIG_NETWORK_FILESYSTEMS is not set
|
||||
CONFIG_KEYS=y
|
||||
CONFIG_SECURITYFS=y
|
||||
CONFIG_UNWINDER_FRAME_POINTER=y
|
||||
9
support/testing/conf/docker-compose.yml
Normal file
9
support/testing/conf/docker-compose.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
version: '3'
|
||||
services:
|
||||
busybox:
|
||||
image: "busybox:latest"
|
||||
command: httpd -f -h /www/
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- "/bin:/www"
|
||||
5
support/testing/conf/f2fs-kernel-fragment.config
Normal file
5
support/testing/conf/f2fs-kernel-fragment.config
Normal file
@@ -0,0 +1,5 @@
|
||||
CONFIG_F2FS_FS=y
|
||||
CONFIG_F2FS_STAT_FS=y
|
||||
CONFIG_F2FS_FS_XATTR=y
|
||||
CONFIG_F2FS_FS_POSIX_ACL=y
|
||||
CONFIG_F2FS_FS_SECURITY=y
|
||||
2
support/testing/conf/grub2-efi.cfg
Normal file
2
support/testing/conf/grub2-efi.cfg
Normal file
@@ -0,0 +1,2 @@
|
||||
set root=(cd0)
|
||||
set prefix=/boot/grub
|
||||
7
support/testing/conf/grub2.cfg
Normal file
7
support/testing/conf/grub2.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
set default="0"
|
||||
set timeout="1"
|
||||
|
||||
menuentry "Buildroot" {
|
||||
linux __KERNEL_PATH__ root=/dev/sr0 console=ttyS0,115200
|
||||
initrd __INITRD_PATH__
|
||||
}
|
||||
13
support/testing/conf/haproxy.cfg
Normal file
13
support/testing/conf/haproxy.cfg
Normal file
@@ -0,0 +1,13 @@
|
||||
defaults
|
||||
timeout connect 10s
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
|
||||
frontend myfrontend
|
||||
mode http
|
||||
bind :81
|
||||
default_backend web_servers
|
||||
|
||||
backend web_servers
|
||||
mode http
|
||||
server s1 localhost:80 check
|
||||
5
support/testing/conf/isolinux.cfg
Normal file
5
support/testing/conf/isolinux.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
default 1
|
||||
label 1
|
||||
kernel __KERNEL_PATH__
|
||||
initrd __INITRD_PATH__
|
||||
append root=/dev/sr0 console=ttyS0,115200
|
||||
54
support/testing/conf/minimal-x86-qemu-kernel.config
Normal file
54
support/testing/conf/minimal-x86-qemu-kernel.config
Normal file
@@ -0,0 +1,54 @@
|
||||
CONFIG_SYSVIPC=y
|
||||
CONFIG_MODULES=y
|
||||
CONFIG_MODULE_UNLOAD=y
|
||||
CONFIG_SMP=y
|
||||
# CONFIG_RETPOLINE is not set
|
||||
CONFIG_HYPERVISOR_GUEST=y
|
||||
CONFIG_PARAVIRT=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_PACKET=y
|
||||
CONFIG_UNIX=y
|
||||
CONFIG_INET=y
|
||||
CONFIG_VIRTIO_BLK=y
|
||||
CONFIG_BLK_DEV_SD=y
|
||||
CONFIG_BLK_DEV_SR=y
|
||||
CONFIG_BLK_DEV_SR_VENDOR=y
|
||||
CONFIG_SCSI=y
|
||||
CONFIG_SCSI_VIRTIO=y
|
||||
CONFIG_ATA=y
|
||||
CONFIG_ATA_PIIX=y
|
||||
CONFIG_PATA_AMD=y
|
||||
CONFIG_PCI=y
|
||||
CONFIG_NETDEVICES=y
|
||||
CONFIG_VIRTIO_NET=y
|
||||
CONFIG_NE2K_PCI=y
|
||||
CONFIG_8139CP=y
|
||||
CONFIG_INPUT_EVDEV=y
|
||||
CONFIG_SERIAL_8250=y
|
||||
CONFIG_SERIAL_8250_CONSOLE=y
|
||||
CONFIG_VIRTIO_CONSOLE=y
|
||||
CONFIG_HW_RANDOM_VIRTIO=m
|
||||
CONFIG_DRM=y
|
||||
CONFIG_DRM_BOCHS=y
|
||||
CONFIG_DRM_QXL=y
|
||||
CONFIG_DRM_VIRTIO_GPU=y
|
||||
CONFIG_SOUND=y
|
||||
CONFIG_SND=y
|
||||
CONFIG_SND_HDA_INTEL=y
|
||||
CONFIG_SND_HDA_GENERIC=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_XHCI_HCD=y
|
||||
CONFIG_USB_EHCI_HCD=y
|
||||
CONFIG_USB_UHCI_HCD=y
|
||||
CONFIG_USB_STORAGE=y
|
||||
CONFIG_VIRTIO_PCI=y
|
||||
CONFIG_VIRTIO_BALLOON=y
|
||||
CONFIG_VIRTIO_INPUT=y
|
||||
CONFIG_VIRTIO_MMIO=y
|
||||
CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
|
||||
CONFIG_EXT4_FS=y
|
||||
CONFIG_ISO9660_FS=y
|
||||
CONFIG_ZISOFS=y
|
||||
CONFIG_JOLIET=y
|
||||
CONFIG_TMPFS=y
|
||||
CONFIG_TMPFS_POSIX_ACL=y
|
||||
1
support/testing/conf/overlayfs-kernel-fragment.config
Normal file
1
support/testing/conf/overlayfs-kernel-fragment.config
Normal file
@@ -0,0 +1 @@
|
||||
CONFIG_OVERLAY_FS=y
|
||||
5
support/testing/conf/unittest.cfg
Normal file
5
support/testing/conf/unittest.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[unittest]
|
||||
plugins = nose2.plugins.mp
|
||||
|
||||
[multiprocess]
|
||||
always-on = True
|
||||
141
support/testing/infra/__init__.py
Normal file
141
support/testing/infra/__init__.py
Normal file
@@ -0,0 +1,141 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import subprocess
|
||||
from urllib.request import urlopen
|
||||
from urllib.error import HTTPError, URLError
|
||||
|
||||
ARTIFACTS_URL = "https://autobuild.buildroot.org/artefacts/"
|
||||
BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), "../../.."))
|
||||
|
||||
|
||||
def log_file_path(builddir, stage, logtofile=True):
|
||||
"""Return path to log file"""
|
||||
return "{}-{}.log".format(builddir, stage) if logtofile else None
|
||||
|
||||
|
||||
def open_log_file(builddir, stage, logtofile=True):
|
||||
"""
|
||||
Open a file for logging and return its handler.
|
||||
If logtofile is True, returns sys.stdout. Otherwise opens a file
|
||||
with a suitable name in the build directory.
|
||||
"""
|
||||
return open(log_file_path(builddir, stage, logtofile), 'a+') if logtofile else sys.stdout
|
||||
|
||||
|
||||
def basepath(relpath=""):
|
||||
"""Return the absolute path for a file or directory relative to the Buildroot top directory."""
|
||||
return os.path.join(BASE_DIR, relpath)
|
||||
|
||||
|
||||
def filepath(relpath):
|
||||
return os.path.join(BASE_DIR, "support/testing", relpath)
|
||||
|
||||
|
||||
def download(dldir, filename):
|
||||
finalpath = os.path.join(dldir, filename)
|
||||
if os.path.exists(finalpath):
|
||||
return finalpath
|
||||
|
||||
if not os.path.exists(dldir):
|
||||
os.makedirs(dldir)
|
||||
|
||||
tmpfile = tempfile.mktemp(dir=dldir)
|
||||
print("Downloading to {}".format(tmpfile))
|
||||
|
||||
try:
|
||||
url_fh = urlopen(os.path.join(ARTIFACTS_URL, filename))
|
||||
with open(tmpfile, "w+b") as tmpfile_fh:
|
||||
tmpfile_fh.write(url_fh.read())
|
||||
except (HTTPError, URLError) as err:
|
||||
os.unlink(tmpfile)
|
||||
raise err
|
||||
|
||||
print("Renaming from {} to {}".format(tmpfile, finalpath))
|
||||
os.rename(tmpfile, finalpath)
|
||||
return finalpath
|
||||
|
||||
|
||||
def run_cmd_on_host(builddir, cmd):
|
||||
"""Call subprocess.check_output and return the text output."""
|
||||
try:
|
||||
host_bin = os.path.join(builddir, "host", "bin")
|
||||
br_path = host_bin + os.pathsep + os.environ["PATH"]
|
||||
out = subprocess.check_output(cmd,
|
||||
cwd=builddir,
|
||||
env={
|
||||
"LANG": "C",
|
||||
"PATH": br_path
|
||||
},
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
universal_newlines=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Command failed with return code {e.returncode}")
|
||||
print("=== STDOUT/STDERR ===")
|
||||
print(e.output)
|
||||
print("=====================")
|
||||
raise
|
||||
|
||||
return out
|
||||
|
||||
|
||||
def get_elf_arch_tag(builddir, prefix, fpath, tag):
|
||||
"""
|
||||
Runs the cross readelf on 'fpath', then extracts the value of tag 'tag'.
|
||||
Example:
|
||||
>>> get_elf_arch_tag('output', 'arm-none-linux-gnueabi-',
|
||||
'bin/busybox', 'Tag_CPU_arch')
|
||||
v5TEJ
|
||||
>>>
|
||||
"""
|
||||
cmd = ["host/bin/{}-readelf".format(prefix),
|
||||
"-A", os.path.join("target", fpath)]
|
||||
out = run_cmd_on_host(builddir, cmd)
|
||||
regexp = re.compile(r"^ {}: (.*)$".format(tag))
|
||||
for line in out.splitlines():
|
||||
m = regexp.match(line)
|
||||
if not m:
|
||||
continue
|
||||
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
|
||||
name and returns it.
|
||||
Example:
|
||||
>>> get_elf_prog_interpreter('br-tests/TestExternalToolchainLinaroArm',
|
||||
'arm-linux-gnueabihf',
|
||||
'bin/busybox')
|
||||
/lib/ld-linux-armhf.so.3
|
||||
>>>
|
||||
"""
|
||||
cmd = ["host/bin/{}-readelf".format(prefix),
|
||||
"-l", os.path.join("target", fpath)]
|
||||
out = run_cmd_on_host(builddir, cmd)
|
||||
regexp = re.compile(r"^ *\[Requesting program interpreter: (.*)\]$")
|
||||
for line in out.splitlines():
|
||||
m = regexp.match(line)
|
||||
if not m:
|
||||
continue
|
||||
return m.group(1)
|
||||
return None
|
||||
|
||||
|
||||
def img_round_power2(img):
|
||||
"""
|
||||
Rounds up the size of an image file to the next power of 2
|
||||
"""
|
||||
sz = os.stat(img).st_size
|
||||
pow2 = 1
|
||||
while pow2 < sz:
|
||||
pow2 = pow2 << 1
|
||||
with open(img, 'ab') as f:
|
||||
f.truncate(pow2)
|
||||
163
support/testing/infra/basetest.py
Normal file
163
support/testing/infra/basetest.py
Normal file
@@ -0,0 +1,163 @@
|
||||
import unittest
|
||||
import os
|
||||
import dataclasses
|
||||
import datetime
|
||||
import json
|
||||
from typing import ClassVar
|
||||
|
||||
from infra.builder import Builder
|
||||
from infra.emulator import Emulator
|
||||
|
||||
BASIC_TOOLCHAIN_CONFIG = \
|
||||
"""
|
||||
BR2_arm=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_GLIBC_STABLE=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
|
||||
"""
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class BRTestSettings:
|
||||
"""support/testing/run-tests stores runtime settings in this
|
||||
object, and serializes it into the environment variable named in
|
||||
CONF_ENV. On instantiation, BRConfigTest loads this
|
||||
configuration. That way configuration can be transferred into
|
||||
multiprocessing worker processes without requiring the "fork"
|
||||
start method.
|
||||
|
||||
"""
|
||||
CONF_ENV: ClassVar[str] = 'BR_TEST_CONFIG_JSON'
|
||||
|
||||
downloaddir: str
|
||||
outputdir: str
|
||||
logtofile: bool = True
|
||||
keepbuilds: bool = False
|
||||
jlevel: int = 0
|
||||
timeout_multiplier: int = 1
|
||||
|
||||
def to_env(self) -> None:
|
||||
os.environ[self.CONF_ENV] = json.dumps(dataclasses.asdict(self))
|
||||
|
||||
@classmethod
|
||||
def from_env(cls) -> 'BRTestSettings':
|
||||
return cls(**json.loads(os.environ[cls.CONF_ENV]))
|
||||
|
||||
|
||||
class BRConfigTest(unittest.TestCase):
|
||||
"""Test up to the configure stage."""
|
||||
config: str
|
||||
br2_external: list[str] = list()
|
||||
downloaddir = None
|
||||
outputdir = None
|
||||
logtofile = True
|
||||
keepbuilds = False
|
||||
jlevel = 0
|
||||
timeout_multiplier = 1
|
||||
|
||||
def __init__(self, names):
|
||||
super(BRConfigTest, self).__init__(names)
|
||||
if BRTestSettings.CONF_ENV in os.environ:
|
||||
self.conf_from_env()
|
||||
self.testname = self.__class__.__name__
|
||||
self.builddir = self.outputdir and os.path.join(self.outputdir, self.testname)
|
||||
self.config += '\nBR2_DL_DIR="{}"\n'.format(self.downloaddir)
|
||||
self.config += "\nBR2_JLEVEL={}\n".format(self.jlevel)
|
||||
|
||||
def show_msg(self, msg):
|
||||
print("{} {:40s} {}".format(datetime.datetime.now().strftime("%H:%M:%S"),
|
||||
self.testname, msg))
|
||||
|
||||
def conf_from_env(self) -> None:
|
||||
conf = BRTestSettings.from_env()
|
||||
for f in dataclasses.fields(conf):
|
||||
setattr(self, f.name, getattr(conf, f.name))
|
||||
|
||||
def setUp(self):
|
||||
self.show_msg("Starting")
|
||||
self.b = Builder(self.config, self.builddir, self.logtofile, self.jlevel)
|
||||
|
||||
if not self.keepbuilds:
|
||||
self.b.delete()
|
||||
|
||||
if not self.b.is_finished():
|
||||
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 BRHostPkgTest(BRConfigTest):
|
||||
"""Test up to the build stage of a host package. Define hostpkgs in
|
||||
the class to the list of host packages that should be built."""
|
||||
config = \
|
||||
BASIC_TOOLCHAIN_CONFIG + \
|
||||
MINIMAL_CONFIG
|
||||
hostpkgs = None
|
||||
|
||||
def __init__(self, names):
|
||||
super(BRHostPkgTest, self).__init__(names)
|
||||
|
||||
def setUp(self):
|
||||
super(BRHostPkgTest, self).setUp()
|
||||
if not self.b.is_finished():
|
||||
self.show_msg("Building")
|
||||
self.b.build(make_extra_opts=self.hostpkgs)
|
||||
self.show_msg("Building done")
|
||||
|
||||
def tearDown(self):
|
||||
super(BRHostPkgTest, self).tearDown()
|
||||
|
||||
|
||||
class BRTest(BRConfigTest):
|
||||
"""Test up to the build stage and instantiate an emulator."""
|
||||
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.show_msg("Building done")
|
||||
|
||||
self.emulator = Emulator(self.builddir, self.downloaddir,
|
||||
self.logtofile, self.timeout_multiplier)
|
||||
|
||||
def tearDown(self):
|
||||
if self.emulator:
|
||||
self.emulator.stop()
|
||||
super(BRTest, self).tearDown()
|
||||
|
||||
# Run the given 'cmd' with a 'timeout' on the target and
|
||||
# assert that the command succeeded; on error, print the
|
||||
# faulty command and its output
|
||||
def assertRunOk(self, cmd, timeout=-1):
|
||||
out, exit_code = self.emulator.run(cmd, timeout)
|
||||
self.assertEqual(
|
||||
exit_code,
|
||||
0,
|
||||
"\nFailed to run: {}\noutput was:\n{}".format(cmd, ' '+'\n '.join(out))
|
||||
)
|
||||
|
||||
# Run the given 'cmd' with a 'timeout' on the target and
|
||||
# assert that the command fails; on success, print the
|
||||
# faulty command and its output
|
||||
def assertRunNotOk(self, cmd, timeout=-1):
|
||||
out, exit_code = self.emulator.run(cmd, timeout)
|
||||
self.assertNotEqual(
|
||||
exit_code,
|
||||
0,
|
||||
"\nUnexpected success: {}\noutput was:\n{}".format(cmd, ' '+'\n '.join(out))
|
||||
)
|
||||
117
support/testing/infra/builder.py
Normal file
117
support/testing/infra/builder.py
Normal file
@@ -0,0 +1,117 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import infra
|
||||
|
||||
|
||||
class Builder(object):
|
||||
def __init__(self, config, builddir, logtofile, jlevel=None):
|
||||
self.config = '\n'.join([line.lstrip() for line in
|
||||
config.splitlines()]) + '\n'
|
||||
self.builddir = builddir
|
||||
self.logfile = infra.open_log_file(builddir, "build", logtofile)
|
||||
self.jlevel = jlevel
|
||||
|
||||
def is_defconfig_valid(self, configfile, defconfig):
|
||||
"""Check if the .config is contains all lines present in the defconfig."""
|
||||
with open(configfile) as configf:
|
||||
configlines = configf.readlines()
|
||||
|
||||
defconfiglines = defconfig.split("\n")
|
||||
|
||||
# Check that all the defconfig lines are still present
|
||||
for defconfigline in defconfiglines:
|
||||
if defconfigline + "\n" not in configlines:
|
||||
self.logfile.write("WARN: defconfig can't be used\n")
|
||||
self.logfile.write(" Missing: %s\n" % defconfigline.strip())
|
||||
self.logfile.flush()
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def configure(self, make_extra_opts=[], make_extra_env={}):
|
||||
"""Configure the build.
|
||||
|
||||
make_extra_opts: a list of arguments to be passed to the make
|
||||
command.
|
||||
e.g. make_extra_opts=["BR2_EXTERNAL=/path"]
|
||||
|
||||
make_extra_env: a dict of variables to be appended (or replaced)
|
||||
in the environment that calls make.
|
||||
e.g. make_extra_env={"BR2_DL_DIR": "/path"}
|
||||
"""
|
||||
if not os.path.isdir(self.builddir):
|
||||
os.makedirs(self.builddir)
|
||||
|
||||
config_file = os.path.join(self.builddir, ".config")
|
||||
with open(config_file, "w+") as cf:
|
||||
cf.write(self.config)
|
||||
# dump the defconfig to the logfile for easy debugging
|
||||
self.logfile.write("> start defconfig\n" + self.config +
|
||||
"> end defconfig\n")
|
||||
self.logfile.flush()
|
||||
|
||||
env = {
|
||||
"PATH": os.environ["PATH"],
|
||||
"HOME": os.environ["HOME"]
|
||||
}
|
||||
env.update(make_extra_env)
|
||||
|
||||
cmd = ["make",
|
||||
"O={}".format(self.builddir)]
|
||||
cmd += make_extra_opts
|
||||
cmd += ["olddefconfig"]
|
||||
|
||||
ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile,
|
||||
cwd=infra.basepath(), env=env)
|
||||
if ret != 0:
|
||||
raise SystemError("Cannot olddefconfig")
|
||||
|
||||
if not self.is_defconfig_valid(config_file, self.config):
|
||||
raise SystemError("The defconfig is not valid")
|
||||
|
||||
def build(self, make_extra_opts=[], make_extra_env={}):
|
||||
"""Perform the build.
|
||||
|
||||
make_extra_opts: a list of arguments to be passed to the make
|
||||
command. It can include a make target.
|
||||
e.g. make_extra_opts=["foo-source"]
|
||||
|
||||
make_extra_env: a dict of variables to be appended (or replaced)
|
||||
in the environment that calls make.
|
||||
e.g. make_extra_env={"BR2_DL_DIR": "/path"}
|
||||
"""
|
||||
env = {
|
||||
"PATH": os.environ["PATH"],
|
||||
"HOME": os.environ["HOME"]
|
||||
}
|
||||
|
||||
if "http_proxy" in os.environ:
|
||||
self.logfile.write("Using system proxy: " +
|
||||
os.environ["http_proxy"] + "\n")
|
||||
env['http_proxy'] = os.environ["http_proxy"]
|
||||
env['https_proxy'] = os.environ["http_proxy"]
|
||||
env.update(make_extra_env)
|
||||
|
||||
cmd = ["make", "-C", self.builddir]
|
||||
if "BR2_PER_PACKAGE_DIRECTORIES=y" in self.config.splitlines() and self.jlevel:
|
||||
cmd.append(f"-j{self.jlevel}")
|
||||
cmd += make_extra_opts
|
||||
|
||||
ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile,
|
||||
env=env)
|
||||
if ret != 0:
|
||||
raise SystemError("Build failed")
|
||||
|
||||
open(self.stamp_path(), 'a').close()
|
||||
|
||||
def stamp_path(self):
|
||||
return os.path.join(self.builddir, "build-done")
|
||||
|
||||
def is_finished(self):
|
||||
return os.path.exists(self.stamp_path())
|
||||
|
||||
def delete(self):
|
||||
if os.path.exists(self.builddir):
|
||||
shutil.rmtree(self.builddir)
|
||||
192
support/testing/infra/emulator.py
Normal file
192
support/testing/infra/emulator.py
Normal file
@@ -0,0 +1,192 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# SPDX-License-Identifier: ISC
|
||||
|
||||
import os
|
||||
|
||||
import pexpect
|
||||
import pexpect.replwrap
|
||||
import time
|
||||
|
||||
import infra
|
||||
|
||||
BR_PROMPT = '[BRTEST# '
|
||||
BR_CONTINUATION_PROMPT = '[BRTEST+ '
|
||||
|
||||
|
||||
def _repl_sh_child(child, orig_prompt, extra_init_cmd):
|
||||
"""Wrap the shell prompt to handle command output
|
||||
Based on pexpect.replwrap._repl_sh() (ISC licensed)
|
||||
https://github.com/pexpect/pexpect/blob/aa989594e1e413f45c18b26ded1783f7d5990fe5/pexpect/replwrap.py#L115
|
||||
"""
|
||||
|
||||
# If the user runs 'env', the value of PS1 will be in the output. To avoid
|
||||
# replwrap seeing that as the next prompt, we'll embed the marker characters
|
||||
# for invisible characters in the prompt; these show up when inspecting the
|
||||
# environment variable, but not when bash displays the prompt.
|
||||
non_printable_insert = '\\[\\]'
|
||||
ps1 = BR_PROMPT[:5] + non_printable_insert + BR_PROMPT[5:]
|
||||
ps2 = (BR_CONTINUATION_PROMPT[:5] + non_printable_insert +
|
||||
BR_CONTINUATION_PROMPT[5:])
|
||||
prompt_change = "PS1='{0}' PS2='{1}' PROMPT_COMMAND=''".format(ps1, ps2)
|
||||
# Note: this will run various commands, each with the default timeout defined
|
||||
# when qemu was spawned.
|
||||
return pexpect.replwrap.REPLWrapper(
|
||||
child,
|
||||
orig_prompt,
|
||||
prompt_change,
|
||||
new_prompt=BR_PROMPT,
|
||||
continuation_prompt=BR_CONTINUATION_PROMPT,
|
||||
extra_init_cmd=extra_init_cmd
|
||||
)
|
||||
|
||||
|
||||
class Emulator(object):
|
||||
|
||||
def __init__(self, builddir, downloaddir, logtofile, timeout_multiplier):
|
||||
self.qemu = None
|
||||
self.repl = None
|
||||
self.builddir = builddir
|
||||
self.downloaddir = downloaddir
|
||||
self.logfile = infra.open_log_file(builddir, "run", logtofile)
|
||||
# We use elastic runners on the cloud to runs our tests. Those runners
|
||||
# can take a long time to run the emulator. Use a timeout multiplier
|
||||
# when running the tests to avoid sporadic failures.
|
||||
self.timeout_multiplier = timeout_multiplier
|
||||
|
||||
# Start Qemu to boot the system
|
||||
#
|
||||
# arch: Qemu architecture to use
|
||||
#
|
||||
# kernel: path to the kernel image, or the special string
|
||||
# 'builtin'. 'builtin' means a pre-built kernel image will be
|
||||
# downloaded from ARTIFACTS_URL and suitable options are
|
||||
# automatically passed to qemu and added to the kernel cmdline. So
|
||||
# far only armv5, armv7 and i386 builtin kernels are available.
|
||||
# If None, then no kernel is used, and we assume a bootable device
|
||||
# will be specified.
|
||||
#
|
||||
# kernel_cmdline: array of kernel arguments to pass to Qemu -append option
|
||||
#
|
||||
# options: array of command line options to pass to Qemu
|
||||
#
|
||||
def boot(self, arch, kernel=None, kernel_cmdline=None, options=None):
|
||||
if arch in ["armv7", "armv5"]:
|
||||
qemu_arch = "arm"
|
||||
else:
|
||||
qemu_arch = arch
|
||||
|
||||
qemu_cmd = ["qemu-system-{}".format(qemu_arch),
|
||||
"-serial", "stdio",
|
||||
"-display", "none",
|
||||
"-m", "256"]
|
||||
|
||||
if options:
|
||||
qemu_cmd += options
|
||||
|
||||
if kernel_cmdline is None:
|
||||
kernel_cmdline = []
|
||||
|
||||
if kernel:
|
||||
if kernel == "builtin":
|
||||
if arch in ["armv7", "armv5"]:
|
||||
kernel_cmdline.append("console=ttyAMA0")
|
||||
|
||||
if arch == "armv7":
|
||||
kernel = infra.download(self.downloaddir,
|
||||
"kernel-vexpress-5.10.202")
|
||||
dtb = infra.download(self.downloaddir,
|
||||
"vexpress-v2p-ca9-5.10.202.dtb")
|
||||
qemu_cmd += ["-dtb", dtb]
|
||||
qemu_cmd += ["-M", "vexpress-a9"]
|
||||
elif arch == "armv5":
|
||||
kernel = infra.download(self.downloaddir,
|
||||
"kernel-versatile-5.10.202")
|
||||
dtb = infra.download(self.downloaddir,
|
||||
"versatile-pb-5.10.202.dtb")
|
||||
qemu_cmd += ["-dtb", dtb]
|
||||
qemu_cmd += ["-M", "versatilepb"]
|
||||
qemu_cmd += ["-device", "virtio-rng-pci"]
|
||||
|
||||
qemu_cmd += ["-kernel", kernel]
|
||||
|
||||
if kernel_cmdline:
|
||||
qemu_cmd += ["-append", " ".join(kernel_cmdline)]
|
||||
|
||||
self.logfile.write(f"> host cpu count: {os.cpu_count()}\n")
|
||||
ldavg = os.getloadavg()
|
||||
ldavg_str = f"{ldavg[0]:.2f}, {ldavg[1]:.2f}, {ldavg[2]:.2f}"
|
||||
self.logfile.write(f"> host loadavg: {ldavg_str}\n")
|
||||
self.logfile.write(f"> timeout multiplier: {self.timeout_multiplier}\n")
|
||||
self.logfile.write(f"> emulator using {qemu_cmd[0]} version:\n")
|
||||
host_bin = os.path.join(self.builddir, "host", "bin")
|
||||
br_path = host_bin + os.pathsep + os.environ["PATH"]
|
||||
qemu_env = {"QEMU_AUDIO_DRV": "none",
|
||||
"PATH": br_path}
|
||||
pexpect.run(f"{qemu_cmd[0]} --version",
|
||||
encoding='utf-8',
|
||||
logfile=self.logfile,
|
||||
env=qemu_env)
|
||||
self.logfile.write("> starting qemu with '%s'\n" % " ".join(qemu_cmd))
|
||||
self.qemu = pexpect.spawn(qemu_cmd[0], qemu_cmd[1:],
|
||||
timeout=5 * self.timeout_multiplier,
|
||||
encoding='utf-8',
|
||||
codec_errors='replace',
|
||||
env=qemu_env)
|
||||
# We want only stdout into the log to avoid double echo
|
||||
self.qemu.logfile_read = self.logfile
|
||||
|
||||
# Wait for the login prompt to appear, and then login as root with
|
||||
# the provided password, or no password if not specified.
|
||||
def login(self, password=None, timeout=60):
|
||||
# The login prompt can take some time to appear when running multiple
|
||||
# instances in parallel, so set the timeout to a large value
|
||||
index = self.qemu.expect(["buildroot login:", pexpect.TIMEOUT],
|
||||
timeout=timeout * self.timeout_multiplier)
|
||||
if index != 0:
|
||||
self.logfile.write("==> System does not boot")
|
||||
raise SystemError("System does not boot")
|
||||
|
||||
self.qemu.sendline("root")
|
||||
if password:
|
||||
self.qemu.expect("Password:")
|
||||
self.qemu.sendline(password)
|
||||
|
||||
self.connect_shell()
|
||||
|
||||
output, exit_code = self.run(f"date -s @{int(time.time())}")
|
||||
if exit_code:
|
||||
raise SystemError("Cannot set date in virtual machine")
|
||||
|
||||
def connect_shell(self):
|
||||
extra_init_cmd = " && ".join([
|
||||
'export PAGER=cat',
|
||||
'dmesg -n 1',
|
||||
# Prevent the shell from wrapping the commands at 80 columns.
|
||||
'stty columns 29999',
|
||||
# Fix the prompt of any subshells that get run
|
||||
'printf "%s\n" "PS1=\'$PS1\'" "PS2=\'$PS2\'" "PROMPT_COMMAND=\'\'" >>/etc/profile'
|
||||
])
|
||||
self.repl = _repl_sh_child(self.qemu, '# ', extra_init_cmd)
|
||||
if not self.repl:
|
||||
raise SystemError("Cannot initialize REPL prompt")
|
||||
|
||||
# Run the given 'cmd' with a 'timeout' on the target
|
||||
# return a tuple (output, exit_code)
|
||||
def run(self, cmd, timeout=-1):
|
||||
if timeout != -1:
|
||||
timeout *= self.timeout_multiplier
|
||||
output = self.repl.run_command(cmd, timeout=timeout)
|
||||
# Remove double carriage return from qemu stdout so str.splitlines()
|
||||
# works as expected.
|
||||
output = output.replace("\r\r", "\r").splitlines()[1:]
|
||||
|
||||
exit_code = self.repl.run_command("echo $?")
|
||||
exit_code = self.qemu.before.splitlines()[2]
|
||||
exit_code = int(exit_code)
|
||||
|
||||
return output, exit_code
|
||||
|
||||
def stop(self):
|
||||
if self.qemu is None:
|
||||
return
|
||||
self.qemu.terminate(force=True)
|
||||
148
support/testing/run-tests
Executable file
148
support/testing/run-tests
Executable file
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import multiprocessing
|
||||
import os
|
||||
import sys
|
||||
|
||||
import nose2
|
||||
|
||||
from infra.basetest import BRTestSettings
|
||||
|
||||
import infra
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Run Buildroot tests')
|
||||
parser.add_argument('testname', nargs='*',
|
||||
help='list of test cases to execute')
|
||||
parser.add_argument('-l', '--list', action='store_true',
|
||||
help='list of available test cases')
|
||||
parser.add_argument('-a', '--all', action='store_true',
|
||||
help='execute all test cases')
|
||||
parser.add_argument('-s', '--stdout', action='store_true',
|
||||
help='log everything to stdout')
|
||||
parser.add_argument('-o', '--output',
|
||||
help='output directory')
|
||||
parser.add_argument('-d', '--download',
|
||||
help='download directory')
|
||||
parser.add_argument('-p', '--prepare-only', action='store_true',
|
||||
help='download emulator builtin binaries')
|
||||
parser.add_argument('-k', '--keep',
|
||||
help='keep build directories',
|
||||
action='store_true')
|
||||
parser.add_argument('-t', '--testcases', type=int, default=1,
|
||||
help='number of testcases to run simultaneously')
|
||||
parser.add_argument('-j', '--jlevel', type=int,
|
||||
help='BR2_JLEVEL to use for each testcase')
|
||||
parser.add_argument('--timeout-multiplier', type=int, default=1,
|
||||
help='increase timeouts (useful for slow machines)')
|
||||
parser.add_argument('-D', '--debug', action='store_true',
|
||||
help='enable debug log')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
script_path = os.path.realpath(__file__)
|
||||
test_dir = os.path.dirname(script_path)
|
||||
|
||||
if args.list:
|
||||
print("List of tests")
|
||||
nose2_args = [
|
||||
script_path,
|
||||
"-s", test_dir,
|
||||
"-v",
|
||||
"--collect-only"
|
||||
]
|
||||
if args.debug:
|
||||
nose2_args += ["--log-level", "debug"]
|
||||
nose2.discover(argv=nose2_args,
|
||||
plugins=["nose2.plugins.collect"])
|
||||
return 0
|
||||
|
||||
if args.download is None:
|
||||
args.download = os.getenv("BR2_DL_DIR")
|
||||
if args.download is None:
|
||||
print("Missing download directory, please use -d/--download")
|
||||
print("")
|
||||
parser.print_help()
|
||||
return 1
|
||||
|
||||
args.download = os.path.abspath(args.download)
|
||||
|
||||
if args.prepare_only:
|
||||
emulator_builtin_binaries = ["kernel-vexpress-5.10.202",
|
||||
"vexpress-v2p-ca9-5.10.202.dtb",
|
||||
"kernel-versatile-5.10.202",
|
||||
"versatile-pb-5.10.202.dtb"]
|
||||
print("Downloading emulator builtin binaries")
|
||||
for binary in emulator_builtin_binaries:
|
||||
infra.download(args.download, binary)
|
||||
return 0
|
||||
|
||||
if args.output is None:
|
||||
print("Missing output directory, please use -o/--output")
|
||||
print("")
|
||||
parser.print_help()
|
||||
return 1
|
||||
|
||||
if not os.path.exists(args.output):
|
||||
os.mkdir(args.output)
|
||||
|
||||
if args.all is False and not args.testname:
|
||||
print("No test selected")
|
||||
print("")
|
||||
parser.print_help()
|
||||
return 1
|
||||
|
||||
jlevel = 0
|
||||
|
||||
if args.testcases != 1:
|
||||
if args.testcases < 1:
|
||||
print("Invalid number of testcases to run simultaneously")
|
||||
print("")
|
||||
parser.print_help()
|
||||
return 1
|
||||
# same default BR2_JLEVEL as package/Makefile.in
|
||||
br2_jlevel = 1 + multiprocessing.cpu_count()
|
||||
each_testcase = int((br2_jlevel + args.testcases) / args.testcases)
|
||||
jlevel = each_testcase
|
||||
|
||||
if args.jlevel:
|
||||
if args.jlevel < 0:
|
||||
print("Invalid BR2_JLEVEL to use for each testcase")
|
||||
print("")
|
||||
parser.print_help()
|
||||
return 1
|
||||
# the user can override the auto calculated value
|
||||
jlevel = args.jlevel
|
||||
|
||||
if args.timeout_multiplier < 1:
|
||||
print("Invalid multiplier for timeout values")
|
||||
print("")
|
||||
parser.print_help()
|
||||
return 1
|
||||
|
||||
BRTestSettings(
|
||||
logtofile=not args.stdout,
|
||||
downloaddir=args.download,
|
||||
outputdir=os.path.abspath(args.output),
|
||||
keepbuilds=args.keep,
|
||||
jlevel=jlevel,
|
||||
timeout_multiplier=args.timeout_multiplier
|
||||
).to_env()
|
||||
|
||||
nose2_args = ["-v",
|
||||
"-N", str(args.testcases),
|
||||
"-s", test_dir,
|
||||
"-c", os.path.join(test_dir, "conf/unittest.cfg")]
|
||||
|
||||
if args.debug:
|
||||
nose2_args += ["--log-level", "debug"]
|
||||
|
||||
if args.testname:
|
||||
nose2_args += args.testname
|
||||
|
||||
nose2.discover(argv=nose2_args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
0
support/testing/tests/__init__.py
Normal file
0
support/testing/tests/__init__.py
Normal file
0
support/testing/tests/boot/__init__.py
Normal file
0
support/testing/tests/boot/__init__.py
Normal file
33
support/testing/tests/boot/test_atf.py
Normal file
33
support/testing/tests/boot/test_atf.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestATFAllwinner(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_ARM_AARCH64=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE="v2.11"
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="sun50i_a64"
|
||||
# BR2_TARGET_ARM_TRUSTED_FIRMWARE_SSP is not set
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL31=y
|
||||
BR2_TARGET_UBOOT=y
|
||||
BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
|
||||
BR2_TARGET_UBOOT_CUSTOM_VERSION=y
|
||||
BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2026.01"
|
||||
BR2_TARGET_UBOOT_BOARD_DEFCONFIG="orangepi_zero_plus2"
|
||||
BR2_TARGET_UBOOT_NEEDS_DTC=y
|
||||
BR2_TARGET_UBOOT_NEEDS_OPENSSL=y
|
||||
BR2_TARGET_UBOOT_NEEDS_PYTHON3=y
|
||||
BR2_TARGET_UBOOT_NEEDS_PYLIBFDT=y
|
||||
BR2_TARGET_UBOOT_NEEDS_ATF_BL31=y
|
||||
BR2_TARGET_UBOOT_NEEDS_GNUTLS=y
|
||||
BR2_TARGET_UBOOT_SPL=y
|
||||
BR2_TARGET_UBOOT_SPL_NAME="u-boot-sunxi-with-spl.bin"
|
||||
BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS="SCP=/dev/null"
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
pass
|
||||
155
support/testing/tests/boot/test_edk2.py
Normal file
155
support/testing/tests/boot/test_edk2.py
Normal file
@@ -0,0 +1,155 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
# gitlab-runner: large
|
||||
class TestEdk2(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_neoverse_n2=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_ROOTFS_EXT2_4=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/aarch64-sbsa/assemble-flash-images support/scripts/genimage.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/qemu/aarch64-sbsa/genimage.cfg"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.18.21"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="support/testing/tests/boot/test_edk2/linux.config"
|
||||
BR2_TARGET_EDK2=y
|
||||
BR2_TARGET_EDK2_PLATFORM_QEMU_SBSA=y
|
||||
BR2_TARGET_GRUB2=y
|
||||
BR2_TARGET_GRUB2_ARM64_EFI=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE="v2.12"
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="qemu_sbsa"
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_FIP=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||
BR2_PACKAGE_HOST_MTOOLS=y
|
||||
BR2_PACKAGE_HOST_QEMU=y
|
||||
BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
hda = os.path.join(self.builddir, "images", "disk.img")
|
||||
flash0 = os.path.join(self.builddir, "images", "SBSA_FLASH0.fd")
|
||||
flash1 = os.path.join(self.builddir, "images", "SBSA_FLASH1.fd")
|
||||
self.emulator.boot(arch="aarch64",
|
||||
options=["-M", "sbsa-ref",
|
||||
"-cpu", "neoverse-n2",
|
||||
"-m", "512M",
|
||||
"-pflash", flash0,
|
||||
"-pflash", flash1,
|
||||
"-hda", hda])
|
||||
self.emulator.login()
|
||||
|
||||
|
||||
class TestEdk2BuildBase(infra.basetest.BRTest):
|
||||
"""A class to test the build of various edk2 platforms."""
|
||||
base_config = \
|
||||
"""
|
||||
# BR2_PACKAGE_BUSYBOX is not set
|
||||
# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
BR2_INIT_NONE=y
|
||||
BR2_SYSTEM_BIN_SH_NONE=y
|
||||
BR2_TARGET_EDK2=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
"""
|
||||
|
||||
def assertBinariesExist(self, *binaries: str) -> None:
|
||||
"""Assert that the binaries passed as argument exist
|
||||
under the images folder.
|
||||
We print a message to the emulator logfile for each binary found.
|
||||
"""
|
||||
for binary in binaries:
|
||||
binpath = os.path.join(self.builddir, "images", binary)
|
||||
self.assertTrue(os.path.exists(binpath), f"Missing {binpath}!")
|
||||
print(f"{binary} exists: {binpath}", file=self.emulator.logfile,
|
||||
flush=True)
|
||||
|
||||
|
||||
class TestEdk2BuildArmVirtQemu(TestEdk2BuildBase):
|
||||
config = TestEdk2BuildBase.base_config + \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU=y
|
||||
"""
|
||||
|
||||
def test_run(self) -> None:
|
||||
self.assertBinariesExist("QEMU_EFI.fd", "QEMU_VARS.fd")
|
||||
|
||||
|
||||
class TestEdk2BuildArmVirtQemuKernel(TestEdk2BuildBase):
|
||||
config = TestEdk2BuildBase.base_config + \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL=y
|
||||
"""
|
||||
|
||||
def test_run(self) -> None:
|
||||
self.assertBinariesExist("QEMU_EFI.fd", "QEMU_VARS.fd")
|
||||
|
||||
|
||||
class TestEdk2BuildArmSgi575(TestEdk2BuildBase):
|
||||
config = TestEdk2BuildBase.base_config + \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_TARGET_EDK2_PLATFORM_ARM_SGI575=y
|
||||
"""
|
||||
|
||||
def test_run(self) -> None:
|
||||
self.assertBinariesExist("BL33_AP_UEFI.fd")
|
||||
|
||||
|
||||
class TestEdk2BuildArmVexpressFvpAarch64(TestEdk2BuildBase):
|
||||
config = TestEdk2BuildBase.base_config + \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_TARGET_EDK2_PLATFORM_ARM_VEXPRESS_FVP_AARCH64=y
|
||||
"""
|
||||
|
||||
def test_run(self) -> None:
|
||||
self.assertBinariesExist("FVP_AARCH64_EFI.fd")
|
||||
|
||||
|
||||
class TestEdk2BuildQemuSbsa(TestEdk2BuildBase):
|
||||
# This configuration is not exactly identical to the configuration built
|
||||
# during TestEdk2, as we use the latest arm-trusted-firmware version, among
|
||||
# other things.
|
||||
config = TestEdk2BuildBase.base_config + \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_TARGET_EDK2_PLATFORM_QEMU_SBSA=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="qemu_sbsa"
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_FIP=y
|
||||
"""
|
||||
|
||||
def test_run(self) -> None:
|
||||
self.assertBinariesExist("SBSA_FLASH0.fd", "SBSA_FLASH1.fd", "fip.bin")
|
||||
|
||||
|
||||
class TestEdk2BuildSolidrunArmada80x0mcbin(TestEdk2BuildBase):
|
||||
config = TestEdk2BuildBase.base_config + \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_cortex_a72=y
|
||||
BR2_TARGET_EDK2_PLATFORM_SOLIDRUN_ARMADA80X0MCBIN=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="a80x0_mcbin"
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33=y
|
||||
BR2_TARGET_BINARIES_MARVELL=y
|
||||
BR2_TARGET_MV_DDR_MARVELL=y
|
||||
"""
|
||||
|
||||
def test_run(self) -> None:
|
||||
self.assertBinariesExist("ARMADA_EFI.fd", "fip.bin", "ble.bin",
|
||||
"scp-fw.bin")
|
||||
68
support/testing/tests/boot/test_edk2/linux.config
Normal file
68
support/testing/tests/boot/test_edk2/linux.config
Normal file
@@ -0,0 +1,68 @@
|
||||
CONFIG_SYSVIPC=y
|
||||
CONFIG_POSIX_MQUEUE=y
|
||||
CONFIG_NO_HZ_IDLE=y
|
||||
CONFIG_HIGH_RES_TIMERS=y
|
||||
CONFIG_TASKSTATS=y
|
||||
CONFIG_SCHED_AUTOGROUP=y
|
||||
CONFIG_PROFILING=y
|
||||
CONFIG_ARCH_VEXPRESS=y
|
||||
CONFIG_COMPAT=y
|
||||
CONFIG_FW_CFG_SYSFS=y
|
||||
CONFIG_FW_CFG_SYSFS_CMDLINE=y
|
||||
CONFIG_ACPI=y
|
||||
CONFIG_MODULES=y
|
||||
CONFIG_MODULE_UNLOAD=y
|
||||
CONFIG_BLK_DEV_BSGLIB=y
|
||||
CONFIG_BINFMT_MISC=y
|
||||
CONFIG_TRANSPARENT_HUGEPAGE=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_PACKET=y
|
||||
CONFIG_PACKET_DIAG=y
|
||||
CONFIG_UNIX=y
|
||||
CONFIG_NET_KEY=y
|
||||
CONFIG_INET=y
|
||||
CONFIG_IP_MULTICAST=y
|
||||
CONFIG_IP_ADVANCED_ROUTER=y
|
||||
CONFIG_BRIDGE=m
|
||||
CONFIG_NET_SCHED=y
|
||||
CONFIG_VSOCKETS=y
|
||||
CONFIG_PCI=y
|
||||
CONFIG_PCI_HOST_GENERIC=y
|
||||
CONFIG_DEVTMPFS=y
|
||||
CONFIG_DEVTMPFS_MOUNT=y
|
||||
CONFIG_VIRTIO_BLK=y
|
||||
CONFIG_BLK_DEV_SD=y
|
||||
CONFIG_CHR_DEV_SG=y
|
||||
CONFIG_SCSI_CONSTANTS=y
|
||||
CONFIG_SCSI_LOGGING=y
|
||||
CONFIG_SCSI_SCAN_ASYNC=y
|
||||
CONFIG_SCSI_VIRTIO=y
|
||||
CONFIG_ATA=y
|
||||
CONFIG_SATA_AHCI_PLATFORM=y
|
||||
CONFIG_NETDEVICES=y
|
||||
CONFIG_DUMMY=y
|
||||
CONFIG_MACVLAN=y
|
||||
CONFIG_VIRTIO_NET=y
|
||||
CONFIG_NLMON=y
|
||||
CONFIG_SERIAL_AMBA_PL011=y
|
||||
CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
|
||||
CONFIG_VIRTIO_CONSOLE=y
|
||||
CONFIG_HW_RANDOM=y
|
||||
CONFIG_HW_RANDOM_VIRTIO=y
|
||||
CONFIG_TCG_TPM=y
|
||||
CONFIG_TCG_TIS=y
|
||||
CONFIG_DRM=y
|
||||
CONFIG_DRM_VIRTIO_GPU=y
|
||||
CONFIG_RTC_CLASS=y
|
||||
CONFIG_RTC_DRV_PL031=y
|
||||
CONFIG_VIRTIO_PCI=y
|
||||
CONFIG_VIRTIO_MMIO=y
|
||||
CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
|
||||
CONFIG_MAILBOX=y
|
||||
CONFIG_PL320_MBOX=y
|
||||
CONFIG_ARM_SMMU_V3=y
|
||||
CONFIG_EXT4_FS=y
|
||||
CONFIG_FUSE_FS=y
|
||||
CONFIG_VIRTIO_FS=y
|
||||
CONFIG_TMPFS=y
|
||||
CONFIG_TMPFS_POSIX_ACL=y
|
||||
178
support/testing/tests/boot/test_grub.py
Normal file
178
support/testing/tests/boot/test_grub.py
Normal file
@@ -0,0 +1,178 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestGrubi386BIOS(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_x86_core2=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_CORE2_GLIBC_STABLE=y
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="board/pc/post-build.sh {}"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/pc/genimage-bios.cfg"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.18.21"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/pc/linux.config"
|
||||
BR2_LINUX_KERNEL_INSTALL_TARGET=y
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_GRUB2=y
|
||||
BR2_TARGET_GRUB2_I386_PC=y
|
||||
BR2_TARGET_GRUB2_INSTALL_TOOLS=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
""".format(infra.filepath("tests/boot/test_grub/post-build.sh"))
|
||||
|
||||
def test_run(self):
|
||||
hda = os.path.join(self.builddir, "images", "disk.img")
|
||||
self.emulator.boot(arch="i386", options=["-hda", hda])
|
||||
self.emulator.login()
|
||||
|
||||
|
||||
# gitlab-runner: large
|
||||
class TestGrubX8664EFI(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_x86_64=y
|
||||
BR2_x86_corei7=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_GLIBC_STABLE=y
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="board/pc/post-build.sh {}"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image-efi.sh"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.18.21"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/pc/linux.config"
|
||||
BR2_LINUX_KERNEL_INSTALL_TARGET=y
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
|
||||
BR2_PACKAGE_EFIVAR=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_EDK2=y
|
||||
BR2_TARGET_GRUB2=y
|
||||
BR2_TARGET_GRUB2_X86_64_EFI=y
|
||||
BR2_TARGET_GRUB2_INSTALL_TOOLS=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
BR2_PACKAGE_HOST_MTOOLS=y
|
||||
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||
""".format(infra.filepath("tests/boot/test_grub/post-build.sh"))
|
||||
|
||||
def test_run(self):
|
||||
hda = os.path.join(self.builddir, "images", "disk.img")
|
||||
bios = os.path.join(self.builddir, "images", "OVMF.fd")
|
||||
# In QEMU v5.1.0 up to v7.2.0, the CPU hotplug register block misbehaves.
|
||||
# EDK2 hang if the bug is detected in Qemu after printing errors to IO port 0x402
|
||||
# (requires BR2_TARGET_EDK2_OVMF_DEBUG_ON_SERIAL to see them)
|
||||
# The Docker image used by the Buildroot gitlab-ci uses Qemu 5.2.0, the workaround
|
||||
# can be removed as soon as the Docker image is updated to provided Qemu >= 8.0.0.
|
||||
# https://github.com/tianocore/edk2/commit/bf5678b5802685e07583e3c7ec56d883cbdd5da3
|
||||
# http://lists.busybox.net/pipermail/buildroot/2023-July/670825.html
|
||||
qemu_fw_cfg = "name=opt/org.tianocore/X-Cpuhp-Bugcheck-Override,string=yes"
|
||||
self.emulator.boot(arch="x86_64", options=["-bios", bios, "-cpu", "Nehalem", "-hda", hda, "-fw_cfg", qemu_fw_cfg])
|
||||
self.emulator.login()
|
||||
|
||||
cmd = "modprobe efivarfs"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "mount -t efivarfs none /sys/firmware/efi/efivars"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "efivar -l"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
|
||||
# gitlab-runner: large
|
||||
class TestGrubAArch64EFI(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="{post_image}"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.18.21"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
|
||||
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{linux_fragment}"
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
|
||||
BR2_PACKAGE_EFIVAR=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_EDK2=y
|
||||
BR2_TARGET_GRUB2=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
BR2_PACKAGE_HOST_MTOOLS=y
|
||||
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||
BR2_PACKAGE_HOST_QEMU=y
|
||||
BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
|
||||
""".format(post_image=infra.filepath("tests/boot/test_grub/post-image-aarch64-efi.sh"),
|
||||
linux_fragment=infra.filepath("tests/boot/test_grub/linux-aarch64-efi.config"))
|
||||
|
||||
def test_run(self):
|
||||
hda = os.path.join(self.builddir, "images", "disk.img")
|
||||
bios = os.path.join(self.builddir, "images", "QEMU_EFI.fd")
|
||||
self.emulator.boot(arch="aarch64", options=["-M", "virt", "-cpu", "cortex-a53", "-bios", bios, "-hda", hda])
|
||||
self.emulator.login()
|
||||
|
||||
cmd = "modprobe efivarfs"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "mount -t efivarfs none /sys/firmware/efi/efivars"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "efivar -l"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
|
||||
# gitlab-runner: large
|
||||
class TestGrubRiscV64EFI(infra.basetest.BRTest):
|
||||
scripts = [
|
||||
"board/qemu/post-image.sh",
|
||||
"board/qemu/riscv64-virt-efi/assemble-flash-images",
|
||||
"support/scripts/genimage.sh"
|
||||
]
|
||||
post_image_script = " ".join(scripts)
|
||||
config = \
|
||||
f"""
|
||||
BR2_riscv=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="{post_image_script}"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/qemu/riscv64-virt-efi/genimage.cfg"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.18.21"
|
||||
BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
|
||||
BR2_PACKAGE_EFIVAR=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
BR2_TARGET_EDK2=y
|
||||
BR2_TARGET_GRUB2=y
|
||||
BR2_TARGET_GRUB2_RISCV64_EFI=y
|
||||
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
BR2_PACKAGE_HOST_MTOOLS=y
|
||||
BR2_PACKAGE_HOST_QEMU=y
|
||||
BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
disk = os.path.join(self.builddir, "images", "disk.img")
|
||||
flash0 = os.path.join(self.builddir, "images", "RISCV_VIRT_CODE.fd")
|
||||
flash1 = os.path.join(self.builddir, "images", "RISCV_VIRT_VARS.fd")
|
||||
qemu_opts = [
|
||||
"-M", "virt,pflash0=pflash0,pflash1=pflash1,acpi=off",
|
||||
"-blockdev", f"node-name=pflash0,driver=file,read-only=on,filename={flash0}",
|
||||
"-blockdev", f"node-name=pflash1,driver=file,filename={flash1}",
|
||||
"-drive", f"file={disk},format=raw,if=virtio"
|
||||
]
|
||||
self.emulator.boot(arch="riscv64", options=qemu_opts)
|
||||
self.emulator.login()
|
||||
|
||||
cmd = "mount -t efivarfs none /sys/firmware/efi/efivars"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
cmd = "efivar -l"
|
||||
self.assertRunOk(cmd)
|
||||
@@ -0,0 +1,32 @@
|
||||
image efi-part.vfat {
|
||||
vfat {
|
||||
file EFI {
|
||||
image = "efi-part/EFI"
|
||||
}
|
||||
|
||||
file Image {
|
||||
image = "Image"
|
||||
}
|
||||
}
|
||||
|
||||
size = 16352K # 16MB - 32KB
|
||||
}
|
||||
|
||||
image disk.img {
|
||||
hdimage {
|
||||
partition-table-type = "gpt"
|
||||
}
|
||||
|
||||
partition boot {
|
||||
image = "efi-part.vfat"
|
||||
partition-type-uuid = c12a7328-f81f-11d2-ba4b-00a0c93ec93b
|
||||
offset = 32K
|
||||
bootable = true
|
||||
}
|
||||
|
||||
partition root {
|
||||
partition-type-uuid = 44479540-f297-41b2-9af7-d131d5f0458a
|
||||
partition-uuid = UUID_TMP
|
||||
image = "rootfs.ext2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
set default="0"
|
||||
set timeout="5"
|
||||
|
||||
menuentry "Buildroot" {
|
||||
linux /Image root=PARTUUID=UUID_TMP rootwait console=ttyAMA0
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
CONFIG_ACPI=y
|
||||
7
support/testing/tests/boot/test_grub/post-build.sh
Executable file
7
support/testing/tests/boot/test_grub/post-build.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -d "$BINARIES_DIR/efi-part/" ]; then
|
||||
sed -i 's%tty1%ttyS0,115200%' "$BINARIES_DIR/efi-part/EFI/BOOT/grub.cfg"
|
||||
else
|
||||
sed -i 's%tty1%ttyS0,115200%' "$TARGET_DIR/boot/grub/grub.cfg"
|
||||
fi
|
||||
8
support/testing/tests/boot/test_grub/post-image-aarch64-efi.sh
Executable file
8
support/testing/tests/boot/test_grub/post-image-aarch64-efi.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
UUID=$(dumpe2fs "$BINARIES_DIR/rootfs.ext2" 2>/dev/null | sed -n 's/^Filesystem UUID: *\(.*\)/\1/p')
|
||||
sed "s/UUID_TMP/$UUID/g" support/testing/tests/boot/test_grub/grub-aarch64-efi.cfg > "$BINARIES_DIR/efi-part/EFI/BOOT/grub.cfg"
|
||||
sed "s/UUID_TMP/$UUID/g" support/testing/tests/boot/test_grub/genimage-aarch64-efi.cfg > "$BINARIES_DIR/genimage-aarch64-efi.cfg"
|
||||
support/scripts/genimage.sh -c "$BINARIES_DIR/genimage-aarch64-efi.cfg"
|
||||
74
support/testing/tests/boot/test_optee_os.py
Normal file
74
support/testing/tests/boot/test_optee_os.py
Normal file
@@ -0,0 +1,74 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestOptee(infra.basetest.BRTest):
|
||||
# A custom configuration is needed to enable OP-TEE support in the
|
||||
# Kernel. This config is inspired from:
|
||||
# configs/qemu_arm_vexpress_tz_defconfig
|
||||
uboot_fragment = \
|
||||
infra.filepath("tests/boot/test_optee_os/u-boot.fragment")
|
||||
config = \
|
||||
f"""
|
||||
BR2_arm=y
|
||||
BR2_cortex_a15=y
|
||||
BR2_ARM_FPU_VFPV3D16=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="board/qemu/arm-vexpress-tz/post-build.sh"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.73"
|
||||
BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
|
||||
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/qemu/arm-vexpress-tz/linux.fragment"
|
||||
BR2_PACKAGE_OPTEE_EXAMPLES=y
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
BR2_TARGET_ROOTFS_CPIO_GZIP=y
|
||||
BR2_TARGET_ROOTFS_CPIO_UIMAGE=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE="v2.9"
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="qemu"
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_FIP=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL32_OPTEE=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_UBOOT_AS_BL33=y
|
||||
BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="BL32_RAM_LOCATION=tdram"
|
||||
BR2_TARGET_OPTEE_OS=y
|
||||
BR2_TARGET_OPTEE_OS_NEEDS_DTC=y
|
||||
BR2_TARGET_OPTEE_OS_PLATFORM="vexpress-qemu_virt"
|
||||
BR2_TARGET_UBOOT=y
|
||||
BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
|
||||
BR2_TARGET_UBOOT_CUSTOM_VERSION=y
|
||||
BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2022.04"
|
||||
BR2_TARGET_UBOOT_BOARD_DEFCONFIG="qemu_arm"
|
||||
BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="{uboot_fragment}"
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
# There is no Kernel nor rootfs image here. They will be
|
||||
# loaded by TFTP through the emulated network interface in
|
||||
# u-boot.
|
||||
bios = os.path.join(self.builddir, "images", "flash.bin")
|
||||
tftp_dir = os.path.join(self.builddir, "images")
|
||||
self.emulator.boot(arch="arm",
|
||||
options=["-M", "virt,secure=on",
|
||||
"-d", "unimp",
|
||||
"-cpu", "cortex-a15",
|
||||
"-m", "1024M",
|
||||
"-netdev", f"user,id=vmnic,tftp={tftp_dir}",
|
||||
"-device", "virtio-net-device,netdev=vmnic",
|
||||
"-bios", bios])
|
||||
self.emulator.login()
|
||||
|
||||
# Check the Kernel has OP-TEE messages
|
||||
self.assertRunOk("dmesg | grep -F optee:")
|
||||
|
||||
# Check we have OP-TEE devices
|
||||
self.assertRunOk("ls -al /dev/tee*")
|
||||
|
||||
# Run some OP-TEE examples
|
||||
examples = ["aes", "hello_world", "hotp", "random", "secure_storage"]
|
||||
for ex in examples:
|
||||
self.assertRunOk(f"optee_example_{ex}")
|
||||
8
support/testing/tests/boot/test_optee_os/u-boot.fragment
Normal file
8
support/testing/tests/boot/test_optee_os/u-boot.fragment
Normal file
@@ -0,0 +1,8 @@
|
||||
CONFIG_SYS_TEXT_BASE=0x60000000
|
||||
CONFIG_BOOTCOMMAND="setenv ipaddr 10.0.2.15 && setenv serverip 10.0.2.2 && tftp ${kernel_addr_r} zImage && tftp ${ramdisk_addr_r} rootfs.cpio.uboot && setenv bootargs console=ttyAMA0,115200 earlyprintk=serial,ttyAMA0,115200 && bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr}"
|
||||
CONFIG_SEMIHOSTING=y
|
||||
# Drop flash accesses
|
||||
CONFIG_ENV_IS_IN_FLASH=n
|
||||
CONFIG_MTD=n
|
||||
CONFIG_MTD_NOR_FLASH=n
|
||||
CONFIG_ENV_IS_NOWHERE=y
|
||||
73
support/testing/tests/boot/test_syslinux.py
Normal file
73
support/testing/tests/boot/test_syslinux.py
Normal file
@@ -0,0 +1,73 @@
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestSysLinuxBase(infra.basetest.BRTest):
|
||||
x86_toolchain_config = \
|
||||
"""
|
||||
BR2_x86_i686=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_I686_GLIBC_BLEEDING_EDGE=y
|
||||
"""
|
||||
|
||||
x86_64_toolchain_config = \
|
||||
"""
|
||||
BR2_x86_64=y
|
||||
BR2_x86_corei7=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_CORE_I7_GLIBC_BLEEDING_EDGE=y
|
||||
"""
|
||||
|
||||
syslinux_legacy_config = \
|
||||
"""
|
||||
BR2_TARGET_SYSLINUX=y
|
||||
BR2_TARGET_SYSLINUX_ISOLINUX=y
|
||||
BR2_TARGET_SYSLINUX_LPXELINUX=y
|
||||
BR2_TARGET_SYSLINUX_PXELINUX=y
|
||||
BR2_TARGET_SYSLINUX_MBR=y
|
||||
"""
|
||||
|
||||
syslinux_efi_config = \
|
||||
"""
|
||||
BR2_TARGET_SYSLINUX=y
|
||||
BR2_TARGET_SYSLINUX_EFI=y
|
||||
"""
|
||||
|
||||
|
||||
class TestSysLinuxX86LegacyBios(TestSysLinuxBase):
|
||||
config = \
|
||||
TestSysLinuxBase.x86_toolchain_config + \
|
||||
infra.basetest.MINIMAL_CONFIG + \
|
||||
TestSysLinuxBase.syslinux_legacy_config
|
||||
|
||||
def test_run(self):
|
||||
pass
|
||||
|
||||
|
||||
class TestSysLinuxX86EFI(TestSysLinuxBase):
|
||||
config = \
|
||||
TestSysLinuxBase.x86_toolchain_config + \
|
||||
infra.basetest.MINIMAL_CONFIG + \
|
||||
TestSysLinuxBase.syslinux_efi_config
|
||||
|
||||
def test_run(self):
|
||||
pass
|
||||
|
||||
|
||||
class TestSysLinuxX86_64LegacyBios(TestSysLinuxBase):
|
||||
config = \
|
||||
TestSysLinuxBase.x86_64_toolchain_config + \
|
||||
infra.basetest.MINIMAL_CONFIG + \
|
||||
TestSysLinuxBase.syslinux_legacy_config
|
||||
|
||||
def test_run(self):
|
||||
pass
|
||||
|
||||
|
||||
class TestSysLinuxX86_64EFI(TestSysLinuxBase):
|
||||
config = \
|
||||
TestSysLinuxBase.x86_64_toolchain_config + \
|
||||
infra.basetest.MINIMAL_CONFIG + \
|
||||
TestSysLinuxBase.syslinux_efi_config
|
||||
|
||||
def test_run(self):
|
||||
pass
|
||||
0
support/testing/tests/core/__init__.py
Normal file
0
support/testing/tests/core/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
source "$BR2_EXTERNAL_DETECT_BAD_ARCH_PATH/package/detect-bad-arch/Config.in"
|
||||
@@ -0,0 +1 @@
|
||||
name: DETECT_BAD_ARCH
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_DETECT_BAD_ARCH_PATH)/package/*/*.mk))
|
||||
@@ -0,0 +1,4 @@
|
||||
config BR2_PACKAGE_DETECT_BAD_ARCH
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
################################################################################
|
||||
#
|
||||
# detect-bad-arch
|
||||
#
|
||||
################################################################################
|
||||
|
||||
define DETECT_BAD_ARCH_BUILD_CMDS
|
||||
echo "int main(void) { return 0; }" | $(HOSTCC) -x c -o $(@D)/foo -
|
||||
endef
|
||||
|
||||
define DETECT_BAD_ARCH_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 0755 $(@D)/foo $(TARGET_DIR)/usr/bin/foo
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1 @@
|
||||
name: CPE_ID
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_CPE_ID_PATH)/package/*/*.mk))
|
||||
@@ -0,0 +1,4 @@
|
||||
CPE_ID_PKG1_VERSION = 42
|
||||
|
||||
$(eval $(generic-package))
|
||||
$(eval $(host-generic-package))
|
||||
@@ -0,0 +1,3 @@
|
||||
CPE_ID_PKG2_VERSION = 67
|
||||
|
||||
$(eval $(host-generic-package))
|
||||
@@ -0,0 +1,5 @@
|
||||
CPE_ID_PKG3_VERSION = 67
|
||||
CPE_ID_PKG3_CPE_ID_VENDOR = cpe-id-pkg3_project
|
||||
|
||||
$(eval $(generic-package))
|
||||
$(eval $(host-generic-package))
|
||||
@@ -0,0 +1,9 @@
|
||||
CPE_ID_PKG4_VERSION = 67
|
||||
CPE_ID_PKG4_CPE_ID_VENDOR = foo
|
||||
CPE_ID_PKG4_CPE_ID_PRODUCT = bar
|
||||
CPE_ID_PKG4_CPE_ID_VERSION = 42
|
||||
CPE_ID_PKG4_CPE_ID_UPDATE = b2
|
||||
CPE_ID_PKG4_CPE_ID_PREFIX = cpe:2.4:a
|
||||
|
||||
$(eval $(generic-package))
|
||||
$(eval $(host-generic-package))
|
||||
@@ -0,0 +1,16 @@
|
||||
CPE_ID_PKG5_VERSION = 57
|
||||
|
||||
CPE_ID_PKG5_CPE_ID_VENDOR = foo
|
||||
CPE_ID_PKG5_CPE_ID_PRODUCT = bar
|
||||
CPE_ID_PKG5_CPE_ID_VERSION = 42
|
||||
CPE_ID_PKG5_CPE_ID_UPDATE = b2
|
||||
CPE_ID_PKG5_CPE_ID_PREFIX = cpe:2.4:a
|
||||
|
||||
HOST_CPE_ID_PKG5_CPE_ID_VENDOR = baz
|
||||
HOST_CPE_ID_PKG5_CPE_ID_PRODUCT = fuz
|
||||
HOST_CPE_ID_PKG5_CPE_ID_VERSION = 43
|
||||
HOST_CPE_ID_PKG5_CPE_ID_UPDATE = b3
|
||||
HOST_CPE_ID_PKG5_CPE_ID_PREFIX = cpe:2.5:a
|
||||
|
||||
$(eval $(generic-package))
|
||||
$(eval $(host-generic-package))
|
||||
7
support/testing/tests/core/device_table2.txt
Normal file
7
support/testing/tests/core/device_table2.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
# <name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>
|
||||
/usr/sbin/getcap f 755 0 0 - - - - -
|
||||
|xattr cap_sys_nice+eip
|
||||
# leading spaces are ignored for xattr
|
||||
|xattr cap_kill+eip
|
||||
# leading tabs are ignored for xattr
|
||||
|xattr cap_sys_time+eip
|
||||
12
support/testing/tests/core/post-build.sh
Executable file
12
support/testing/tests/core/post-build.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
(
|
||||
printf "arg1,%s\n" "${1}"
|
||||
printf "arg2,%s\n" "${2}"
|
||||
printf "arg3,%s\n" "${3}"
|
||||
printf "TARGET_DIR,%s\n" "${TARGET_DIR}"
|
||||
printf "BUILD_DIR,%s\n" "${BUILD_DIR}"
|
||||
printf "HOST_DIR,%s\n" "${HOST_DIR}"
|
||||
printf "STAGING_DIR,%s\n" "${STAGING_DIR}"
|
||||
printf "BINARIES_DIR,%s\n" "${BINARIES_DIR}"
|
||||
printf "BR2_CONFIG,%s\n" "${BR2_CONFIG}"
|
||||
) > ${BUILD_DIR}/$(basename "${0}" .sh).log
|
||||
1
support/testing/tests/core/post-fakeroot.sh
Symbolic link
1
support/testing/tests/core/post-fakeroot.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
post-build.sh
|
||||
1
support/testing/tests/core/post-image.sh
Symbolic link
1
support/testing/tests/core/post-image.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
post-build.sh
|
||||
1
support/testing/tests/core/rootfs-overlay1/test-file1
Normal file
1
support/testing/tests/core/rootfs-overlay1/test-file1
Normal file
@@ -0,0 +1 @@
|
||||
foobar
|
||||
@@ -0,0 +1 @@
|
||||
barfoo
|
||||
1
support/testing/tests/core/squashfs-xattr-kernel.config
Normal file
1
support/testing/tests/core/squashfs-xattr-kernel.config
Normal file
@@ -0,0 +1 @@
|
||||
CONFIG_SQUASHFS_XATTR=y
|
||||
18
support/testing/tests/core/test_bad_arch.py
Normal file
18
support/testing/tests/core/test_bad_arch.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import infra
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class DetectBadArchTest(infra.basetest.BRConfigTest):
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + infra.basetest.MINIMAL_CONFIG
|
||||
br2_external = [infra.filepath("tests/core/br2-external/detect-bad-arch")]
|
||||
|
||||
def test_run(self):
|
||||
with self.assertRaises(SystemError):
|
||||
self.b.build()
|
||||
logf_path = infra.log_file_path(self.b.builddir, "build",
|
||||
infra.basetest.BRConfigTest.logtofile)
|
||||
if logf_path:
|
||||
s = 'ERROR: architecture for "/usr/bin/foo" is'
|
||||
with open(logf_path, "r") as f:
|
||||
lines = [line for line in f.readlines() if line.startswith(s)]
|
||||
self.assertEqual(len(lines), 1)
|
||||
110
support/testing/tests/core/test_cpeid.py
Normal file
110
support/testing/tests/core/test_cpeid.py
Normal file
@@ -0,0 +1,110 @@
|
||||
import infra
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
|
||||
class CpeIdTest(infra.basetest.BRConfigTest):
|
||||
config = ""
|
||||
br2_external = [infra.filepath("tests/core/cpeid-br2-external")]
|
||||
|
||||
def get_vars(self, var):
|
||||
cmd = ["make", "--no-print-directory", "-C", self.b.builddir,
|
||||
"VARS=%s%%" % var, "printvars"]
|
||||
lines = subprocess.check_output(cmd).splitlines()
|
||||
return dict([str(x, "utf-8").split("=") for x in lines])
|
||||
|
||||
def get_json(self, pkg):
|
||||
cmd = ["make", "--no-print-directory", "-C", self.b.builddir,
|
||||
"%s-show-info" % pkg]
|
||||
return json.loads(subprocess.check_output(cmd))
|
||||
|
||||
def test_pkg1(self):
|
||||
# this package has no CPE ID information, it should not have
|
||||
# any CPE_ID variable defined.
|
||||
pkg_vars = self.get_vars("CPE_ID_PKG1_CPE_ID")
|
||||
cpe_vars = ["CPE_ID_VALID", "CPE_ID_PRODUCT", "CPE_ID_VERSION", "CPE_ID_UPDATE",
|
||||
"CPE_ID_PREFIX", "CPE_ID"]
|
||||
for v in cpe_vars:
|
||||
self.assertNotIn("CPE_ID_PKG1_%s" % v, pkg_vars)
|
||||
pkg_json = self.get_json("cpe-id-pkg1")
|
||||
self.assertNotIn("cpe-id", pkg_json['cpe-id-pkg1'])
|
||||
|
||||
pkg_vars = self.get_vars("HOST_CPE_ID_PKG1_CPE_ID")
|
||||
for v in cpe_vars:
|
||||
self.assertNotIn("HOST_CPE_ID_PKG1_%s" % v, pkg_vars)
|
||||
pkg_json = self.get_json("host-cpe-id-pkg1")
|
||||
self.assertNotIn("cpe-id", pkg_json['host-cpe-id-pkg1'])
|
||||
|
||||
def test_pkg2(self):
|
||||
# this package has no CPE ID information, it should not have
|
||||
# any CPE_ID variable defined.
|
||||
pkg_vars = self.get_vars("HOST_CPE_ID_PKG2_CPE_ID")
|
||||
cpe_vars = ["CPE_ID_VALID", "CPE_ID_PRODUCT", "CPE_ID_VERSION", "CPE_ID_UPDATE",
|
||||
"CPE_ID_PREFIX", "CPE_ID"]
|
||||
for v in cpe_vars:
|
||||
self.assertNotIn("HOST_CPE_ID_PKG2_%s" % v, pkg_vars)
|
||||
pkg_json = self.get_json("host-cpe-id-pkg2")
|
||||
self.assertNotIn("cpe-id", pkg_json['host-cpe-id-pkg2'])
|
||||
|
||||
def test_pkg3(self):
|
||||
# this package has just <pkg>_CPE_ID_VENDOR defined, so verify
|
||||
# it has the default CPE_ID value, and that inheritance of the
|
||||
# values for the host package is working
|
||||
pkg_vars = self.get_vars("CPE_ID_PKG3_CPE_ID")
|
||||
self.assertEqual(pkg_vars["CPE_ID_PKG3_CPE_ID"],
|
||||
"cpe:2.3:a:cpe-id-pkg3_project:cpe-id-pkg3:67:*:*:*:*:*:*:*")
|
||||
self.assertEqual(pkg_vars["CPE_ID_PKG3_CPE_ID_VALID"], "YES")
|
||||
pkg_json = self.get_json("cpe-id-pkg3")
|
||||
self.assertEqual(pkg_json['cpe-id-pkg3']['cpe-id'],
|
||||
"cpe:2.3:a:cpe-id-pkg3_project:cpe-id-pkg3:67:*:*:*:*:*:*:*")
|
||||
|
||||
pkg_vars = self.get_vars("HOST_CPE_ID_PKG3_CPE_ID")
|
||||
self.assertEqual(pkg_vars["HOST_CPE_ID_PKG3_CPE_ID"],
|
||||
"cpe:2.3:a:cpe-id-pkg3_project:cpe-id-pkg3:67:*:*:*:*:*:*:*")
|
||||
self.assertEqual(pkg_vars["HOST_CPE_ID_PKG3_CPE_ID_VALID"], "YES")
|
||||
pkg_json = self.get_json("host-cpe-id-pkg3")
|
||||
self.assertEqual(pkg_json['host-cpe-id-pkg3']['cpe-id'],
|
||||
"cpe:2.3:a:cpe-id-pkg3_project:cpe-id-pkg3:67:*:*:*:*:*:*:*")
|
||||
|
||||
def test_pkg4(self):
|
||||
# this package defines
|
||||
# <pkg>_CPE_ID_{VENDOR,PRODUCT,VERSION,UPDATE,PREFIX},
|
||||
# make sure we get the computed <pkg>_CPE_ID, and that it is
|
||||
# inherited by the host variant
|
||||
pkg_vars = self.get_vars("CPE_ID_PKG4_CPE_ID")
|
||||
self.assertEqual(pkg_vars["CPE_ID_PKG4_CPE_ID"],
|
||||
"cpe:2.4:a:foo:bar:42:b2:*:*:*:*:*:*")
|
||||
self.assertEqual(pkg_vars["CPE_ID_PKG4_CPE_ID_VALID"], "YES")
|
||||
pkg_json = self.get_json("cpe-id-pkg4")
|
||||
self.assertEqual(pkg_json['cpe-id-pkg4']['cpe-id'],
|
||||
"cpe:2.4:a:foo:bar:42:b2:*:*:*:*:*:*")
|
||||
|
||||
pkg_vars = self.get_vars("HOST_CPE_ID_PKG4_CPE_ID")
|
||||
self.assertEqual(pkg_vars["HOST_CPE_ID_PKG4_CPE_ID"],
|
||||
"cpe:2.4:a:foo:bar:42:b2:*:*:*:*:*:*")
|
||||
self.assertEqual(pkg_vars["HOST_CPE_ID_PKG4_CPE_ID_VALID"], "YES")
|
||||
pkg_json = self.get_json("host-cpe-id-pkg4")
|
||||
self.assertEqual(pkg_json['host-cpe-id-pkg4']['cpe-id'],
|
||||
"cpe:2.4:a:foo:bar:42:b2:*:*:*:*:*:*")
|
||||
|
||||
def test_pkg5(self):
|
||||
# this package defines
|
||||
# <pkg>_CPE_ID_{VENDOR,PRODUCT,VERSION,UPDATE,PREFIX} and
|
||||
# HOST_<pkg>_CPE_ID_{VENDOR,PRODUCT,VERSION,UPDATE,PREFIX}
|
||||
# separately, with different values. Make sure we get the
|
||||
# right <pkg>_CPE_ID and HOST_<pkg>_CPE_ID values.
|
||||
pkg_vars = self.get_vars("CPE_ID_PKG5_CPE_ID")
|
||||
self.assertEqual(pkg_vars["CPE_ID_PKG5_CPE_ID"],
|
||||
"cpe:2.4:a:foo:bar:42:b2:*:*:*:*:*:*")
|
||||
self.assertEqual(pkg_vars["CPE_ID_PKG5_CPE_ID_VALID"], "YES")
|
||||
pkg_json = self.get_json("cpe-id-pkg5")
|
||||
self.assertEqual(pkg_json['cpe-id-pkg5']['cpe-id'],
|
||||
"cpe:2.4:a:foo:bar:42:b2:*:*:*:*:*:*")
|
||||
|
||||
pkg_vars = self.get_vars("HOST_CPE_ID_PKG5_CPE_ID")
|
||||
self.assertEqual(pkg_vars["HOST_CPE_ID_PKG5_CPE_ID"],
|
||||
"cpe:2.5:a:baz:fuz:43:b3:*:*:*:*:*:*")
|
||||
self.assertEqual(pkg_vars["HOST_CPE_ID_PKG5_CPE_ID_VALID"], "YES")
|
||||
pkg_json = self.get_json("host-cpe-id-pkg5")
|
||||
self.assertEqual(pkg_json['host-cpe-id-pkg5']['cpe-id'],
|
||||
"cpe:2.5:a:baz:fuz:43:b3:*:*:*:*:*:*")
|
||||
46
support/testing/tests/core/test_file_capabilities.py
Normal file
46
support/testing/tests/core/test_file_capabilities.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestFileCapabilities(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_arm=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_ROOTFS_DEVICE_TABLE="system/device_table.txt {}"
|
||||
BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES=y
|
||||
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.18.21"
|
||||
BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
|
||||
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{}"
|
||||
BR2_LINUX_KERNEL_DTS_SUPPORT=y
|
||||
BR2_LINUX_KERNEL_INTREE_DTS_NAME="arm/vexpress-v2p-ca9"
|
||||
BR2_PACKAGE_LIBCAP=y
|
||||
BR2_PACKAGE_LIBCAP_TOOLS=y
|
||||
BR2_TARGET_ROOTFS_SQUASHFS=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
""".format(infra.filepath("tests/core/device_table2.txt"),
|
||||
infra.filepath("tests/core/squashfs-xattr-kernel.config"))
|
||||
|
||||
def test_run(self):
|
||||
img = os.path.join(self.builddir, "images", "rootfs.squashfs")
|
||||
infra.img_round_power2(img)
|
||||
|
||||
self.emulator.boot(arch="armv7",
|
||||
kernel=os.path.join(self.builddir, "images", "zImage"),
|
||||
kernel_cmdline=["root=/dev/mmcblk0",
|
||||
"rootfstype=squashfs"],
|
||||
options=["-drive", "file={},if=sd,format=raw".format(img),
|
||||
"-M", "vexpress-a9",
|
||||
"-dtb", os.path.join(self.builddir, "images", "vexpress-v2p-ca9.dtb")])
|
||||
self.emulator.login()
|
||||
|
||||
cmd = "getcap -v /usr/sbin/getcap"
|
||||
output, _ = self.emulator.run(cmd)
|
||||
self.assertIn("cap_kill", output[0])
|
||||
self.assertIn("cap_sys_nice", output[0])
|
||||
self.assertIn("cap_sys_time", output[0])
|
||||
self.assertIn("=eip", output[0])
|
||||
109
support/testing/tests/core/test_hardening.py
Normal file
109
support/testing/tests/core/test_hardening.py
Normal file
@@ -0,0 +1,109 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestHardeningBase(infra.basetest.BRTest):
|
||||
config = \
|
||||
"""
|
||||
BR2_aarch64=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_AARCH64_GLIBC_STABLE=y
|
||||
BR2_PACKAGE_LIGHTTPD=y
|
||||
BR2_PACKAGE_HOST_CHECKSEC=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
"""
|
||||
|
||||
checksec_files = ["usr/sbin/lighttpd", "bin/busybox"]
|
||||
|
||||
def checksec_run(self, target_file):
|
||||
filepath = os.path.join(self.builddir, "target", target_file)
|
||||
cmd = ["host/bin/checksec", "--format=json",
|
||||
"--file={}".format(filepath)]
|
||||
# Checksec is being used for elf file analysis only. There are no
|
||||
# assumptions of target/run-time checks as part of this testing.
|
||||
ret = infra.run_cmd_on_host(self.builddir, cmd)
|
||||
return json.loads(ret)
|
||||
|
||||
|
||||
class TestRelro(TestHardeningBase):
|
||||
config = TestHardeningBase.config + \
|
||||
"""
|
||||
BR2_RELRO_FULL=y
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
for f in self.checksec_files:
|
||||
out = self.checksec_run(f)
|
||||
filepath = os.path.join(self.builddir, "target", f)
|
||||
self.assertEqual(out[filepath]["relro"], "full")
|
||||
self.assertEqual(out[filepath]["pie"], "yes")
|
||||
|
||||
|
||||
class TestRelroPartial(TestHardeningBase):
|
||||
config = TestHardeningBase.config + \
|
||||
"""
|
||||
BR2_RELRO_PARTIAL=y
|
||||
# BR2_PIC_PIE is not set
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
for f in self.checksec_files:
|
||||
out = self.checksec_run(f)
|
||||
filepath = os.path.join(self.builddir, "target", f)
|
||||
self.assertEqual(out[filepath]["relro"], "partial")
|
||||
self.assertEqual(out[filepath]["pie"], "no")
|
||||
|
||||
|
||||
class TestSspNone(TestHardeningBase):
|
||||
config = TestHardeningBase.config + \
|
||||
"""
|
||||
BR2_SSP_NONE=y
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
for f in self.checksec_files:
|
||||
out = self.checksec_run(f)
|
||||
filepath = os.path.join(self.builddir, "target", f)
|
||||
self.assertEqual(out[filepath]["canary"], "no")
|
||||
|
||||
|
||||
class TestSspStrong(TestHardeningBase):
|
||||
config = TestHardeningBase.config + \
|
||||
"""
|
||||
BR2_SSP_STRONG=y
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
for f in self.checksec_files:
|
||||
out = self.checksec_run(f)
|
||||
filepath = os.path.join(self.builddir, "target", f)
|
||||
self.assertEqual(out[filepath]["canary"], "yes")
|
||||
|
||||
|
||||
class TestFortifyNone(TestHardeningBase):
|
||||
config = TestHardeningBase.config + \
|
||||
"""
|
||||
BR2_FORTIFY_SOURCE_NONE=y
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
for f in self.checksec_files:
|
||||
out = self.checksec_run(f)
|
||||
filepath = os.path.join(self.builddir, "target", f)
|
||||
self.assertEqual(out[filepath]["fortified"], "0")
|
||||
|
||||
|
||||
class TestFortifyConserv(TestHardeningBase):
|
||||
config = TestHardeningBase.config + \
|
||||
"""
|
||||
BR2_FORTIFY_SOURCE_1=y
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
for f in self.checksec_files:
|
||||
out = self.checksec_run(f)
|
||||
filepath = os.path.join(self.builddir, "target", f)
|
||||
self.assertNotEqual(out[filepath]["fortified"], "0")
|
||||
48
support/testing/tests/core/test_post_scripts.py
Normal file
48
support/testing/tests/core/test_post_scripts.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import os
|
||||
import csv
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestPostScripts(infra.basetest.BRTest):
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||
"""
|
||||
BR2_INIT_NONE=y
|
||||
BR2_SYSTEM_BIN_SH_NONE=y
|
||||
# BR2_PACKAGE_BUSYBOX is not set
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
|
||||
BR2_ROOTFS_POST_FAKEROOT_SCRIPT="{}"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="{}"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="foobar baz"
|
||||
""".format(infra.filepath("tests/core/post-build.sh"),
|
||||
infra.filepath("tests/core/post-fakeroot.sh"),
|
||||
infra.filepath("tests/core/post-image.sh"))
|
||||
|
||||
def check_post_log_file(self, f, what, target_dir):
|
||||
lines = {}
|
||||
with open(os.path.join(self.builddir, "build", f), newline='') as csvfile:
|
||||
r = csv.reader(csvfile, delimiter=',')
|
||||
for row in r:
|
||||
lines[row[0]] = row[1]
|
||||
|
||||
self.assertEqual(lines["arg1"], what)
|
||||
self.assertEqual(lines["arg2"], "foobar")
|
||||
self.assertEqual(lines["arg3"], "baz")
|
||||
self.assertEqual(lines["TARGET_DIR"], target_dir)
|
||||
self.assertEqual(lines["BUILD_DIR"], os.path.join(self.builddir, "build"))
|
||||
self.assertEqual(lines["HOST_DIR"], os.path.join(self.builddir, "host"))
|
||||
staging = os.readlink(os.path.join(self.builddir, "staging"))
|
||||
self.assertEqual(lines["STAGING_DIR"], staging)
|
||||
self.assertEqual(lines["BINARIES_DIR"], os.path.join(self.builddir, "images"))
|
||||
self.assertEqual(lines["BR2_CONFIG"], os.path.join(self.builddir, ".config"))
|
||||
|
||||
def test_run(self):
|
||||
self.check_post_log_file("post-build.log",
|
||||
os.path.join(self.builddir, "target"),
|
||||
os.path.join(self.builddir, "target"))
|
||||
self.check_post_log_file("post-fakeroot.log",
|
||||
os.path.join(self.builddir, "build/buildroot-fs/tar/target"),
|
||||
os.path.join(self.builddir, "build/buildroot-fs/tar/target"))
|
||||
self.check_post_log_file("post-image.log",
|
||||
os.path.join(self.builddir, "images"),
|
||||
os.path.join(self.builddir, "target"))
|
||||
36
support/testing/tests/core/test_root_password.py
Normal file
36
support/testing/tests/core/test_root_password.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import os
|
||||
import infra.basetest
|
||||
from crypt import crypt
|
||||
|
||||
|
||||
class TestRootPassword(infra.basetest.BRTest):
|
||||
password = "foo"
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||
"""
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
BR2_TARGET_ENABLE_ROOT_LOGIN=y
|
||||
BR2_TARGET_GENERIC_ROOT_PASSWD="{}"
|
||||
""".format(password)
|
||||
|
||||
def test_run(self):
|
||||
# 1. Test by looking hash in the /etc/shadow
|
||||
shadow = os.path.join(self.builddir, "target", "etc", "shadow")
|
||||
with open(shadow, "r") as f:
|
||||
users = f.readlines()
|
||||
for user in users:
|
||||
s = user.split(":")
|
||||
n, h = s[0], s[1]
|
||||
if n == "root":
|
||||
# Fail if the account is disabled or no password is required
|
||||
self.assertTrue(h not in ["", "*"])
|
||||
# Fail if the hash isn't right
|
||||
self.assertEqual(crypt(self.password, h), h)
|
||||
|
||||
# 2. Test by attempting to login
|
||||
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
|
||||
try:
|
||||
self.emulator.boot(arch="armv7", kernel="builtin",
|
||||
options=["-initrd", cpio_file])
|
||||
self.emulator.login(self.password)
|
||||
except SystemError:
|
||||
self.fail("Unable to login with the password")
|
||||
30
support/testing/tests/core/test_rootfs_overlay.py
Normal file
30
support/testing/tests/core/test_rootfs_overlay.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
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")
|
||||
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||
infra.basetest.MINIMAL_CONFIG + \
|
||||
"""
|
||||
BR2_ROOTFS_OVERLAY="{0}1 {0}2"
|
||||
""".format(rootfs_overlay_path)
|
||||
|
||||
def test_run(self):
|
||||
target_file = os.path.join(self.builddir, "target", "test-file1")
|
||||
overlay_file = "{}1/test-file1".format(self.rootfs_overlay_path)
|
||||
ret = compare_file(overlay_file, target_file)
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
target_file = os.path.join(self.builddir, "target", "etc", "test-file2")
|
||||
overlay_file = "{}2/etc/test-file2".format(self.rootfs_overlay_path)
|
||||
ret = compare_file(overlay_file, target_file)
|
||||
self.assertEqual(ret, 0)
|
||||
104
support/testing/tests/core/test_selinux.py
Normal file
104
support/testing/tests/core/test_selinux.py
Normal file
@@ -0,0 +1,104 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestSELinuxInfra(infra.basetest.BRTest):
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG +\
|
||||
"""
|
||||
BR2_PACKAGE_REFPOLICY=y
|
||||
BR2_PACKAGE_PYTHON3=y
|
||||
BR2_PACKAGE_SETOOLS=y
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
"""
|
||||
|
||||
def base_test_run(self):
|
||||
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
|
||||
self.emulator.boot(arch="armv5", kernel="builtin",
|
||||
options=["-initrd", cpio_file])
|
||||
self.emulator.login()
|
||||
|
||||
|
||||
class TestSELinuxExtraModules(TestSELinuxInfra):
|
||||
config = TestSELinuxInfra.config + \
|
||||
"""
|
||||
BR2_REFPOLICY_EXTRA_MODULES="ntp tor"
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
TestSELinuxInfra.base_test_run(self)
|
||||
|
||||
out, ret = self.emulator.run("seinfo -t ntpd_t", 15)
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(out[2].strip(), "ntpd_t")
|
||||
|
||||
out, ret = self.emulator.run("seinfo -t tor_t", 15)
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(out[2].strip(), "tor_t")
|
||||
|
||||
|
||||
class TestSELinuxExtraModulesDirs(TestSELinuxInfra):
|
||||
config = TestSELinuxInfra.config + \
|
||||
"""
|
||||
BR2_REFPOLICY_EXTRA_MODULES_DIRS="{}"
|
||||
""".format(infra.filepath("tests/core/test_selinux/extra_modules"))
|
||||
|
||||
def test_run(self):
|
||||
TestSELinuxInfra.base_test_run(self)
|
||||
|
||||
out, ret = self.emulator.run("seinfo -t buildroot_test_t", 15)
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(out[2].strip(), "buildroot_test_t")
|
||||
|
||||
|
||||
class TestSELinuxSetBooleans(TestSELinuxInfra):
|
||||
config = TestSELinuxInfra.config + \
|
||||
"""
|
||||
BR2_REFPOLICY_SET_BOOLEANS="user_dmesg user_all_users_send_syslog=false"
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
TestSELinuxInfra.base_test_run(self)
|
||||
|
||||
out, ret = self.emulator.run("seinfo -x -b", 15)
|
||||
self.assertEqual(ret, 0)
|
||||
# lines follow the pattern "name (true|false);", plus indentation
|
||||
bools = dict(line.strip().rstrip(';').split()[1:] for line in out[2:])
|
||||
# both of these booleans have the opposite default in refpolicy
|
||||
self.assertEqual(bools["user_dmesg"], "true")
|
||||
self.assertEqual(bools["user_all_users_send_syslog"], "false")
|
||||
|
||||
|
||||
class TestSELinuxCustomGit(TestSELinuxInfra):
|
||||
config = TestSELinuxInfra.config + \
|
||||
"""
|
||||
BR2_PACKAGE_REFPOLICY_CUSTOM_GIT=y
|
||||
BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_URL="https://github.com/SELinuxProject/refpolicy.git"
|
||||
BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_VERSION="RELEASE_2_20200818"
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
pass
|
||||
|
||||
|
||||
class TestSELinuxPackage(TestSELinuxInfra):
|
||||
br2_external = [infra.filepath("tests/core/test_selinux/br2_external")]
|
||||
config = TestSELinuxInfra.config + \
|
||||
"""
|
||||
BR2_PACKAGE_SELINUX_TEST=y
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
TestSELinuxInfra.base_test_run(self)
|
||||
|
||||
out, ret = self.emulator.run("seinfo -t ntpd_t", 15)
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(out[2].strip(), "ntpd_t")
|
||||
|
||||
out, ret = self.emulator.run("seinfo -t tor_t", 15)
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(out[2].strip(), "tor_t")
|
||||
|
||||
out, ret = self.emulator.run("seinfo -t buildroot_test_t", 15)
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(out[2].strip(), "buildroot_test_t")
|
||||
@@ -0,0 +1 @@
|
||||
source "$BR2_EXTERNAL_SELINUX_PATH/package/selinux-test/Config.in"
|
||||
@@ -0,0 +1 @@
|
||||
name: SELINUX
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_SELINUX_PATH)/package/*/*.mk))
|
||||
@@ -0,0 +1,4 @@
|
||||
config BR2_PACKAGE_SELINUX_TEST
|
||||
bool "SELinux test package"
|
||||
help
|
||||
Test package for SELinux Buildroot helpers.
|
||||
@@ -0,0 +1,9 @@
|
||||
################################################################################
|
||||
#
|
||||
# SELinux test package
|
||||
#
|
||||
################################################################################
|
||||
|
||||
SELINUX_TEST_SELINUX_MODULES = ntp tor
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1 @@
|
||||
## <summary>Buildroot rules</summary>
|
||||
@@ -0,0 +1,3 @@
|
||||
policy_module(buildroot, 1.0.0)
|
||||
|
||||
type buildroot_test_t;
|
||||
@@ -0,0 +1 @@
|
||||
## <summary>Buildroot rules</summary>
|
||||
@@ -0,0 +1,3 @@
|
||||
policy_module(buildroot, 1.0.0)
|
||||
|
||||
type buildroot_test_t;
|
||||
89
support/testing/tests/core/test_timezone.py
Normal file
89
support/testing/tests/core/test_timezone.py
Normal file
@@ -0,0 +1,89 @@
|
||||
import os
|
||||
|
||||
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()
|
||||
|
||||
# emulator.login() sets the emulated system date to the host
|
||||
# date. In general, this is desirable (for correct SSL certificate
|
||||
# behaviors, for example).
|
||||
#
|
||||
# This timezone runtime test checks that a Buildroot configuration
|
||||
# is reflected in the generated system at runtime, using the
|
||||
# standard "date" command. To make sure this test is stable in
|
||||
# time (i.e. output is independent to the date/time the test is
|
||||
# executed due to daylight saving time changes), we reset the
|
||||
# system date to a constant value.
|
||||
#
|
||||
# We cannot set the system date to a value less than the system
|
||||
# uptime. So we cannot set the time back to Unix Epoch with the
|
||||
# command "date -s @0" (this would result to a EINVAL Invalid
|
||||
# argument). Instead, we set the time at 1 hour after Epoch. This
|
||||
# is sufficient as the emulated system takes few seconds to start.
|
||||
emulator.run("date -s @3600")
|
||||
|
||||
|
||||
class TestNoTimezone(infra.basetest.BRTest):
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||
"""
|
||||
# BR2_TARGET_TZ_INFO is not set
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
boot_armv5_cpio(self.emulator, self.builddir)
|
||||
tz, _ = self.emulator.run("TZ=UTC date +%Z")
|
||||
self.assertEqual(tz[0].strip(), "UTC")
|
||||
# This test is Glibc specific since there is no Time Zone Database installed
|
||||
# and other C libraries use their own rule for returning time zone name or
|
||||
# abbreviation when TZ is empty or set with a not installed time zone data file.
|
||||
tz, _ = self.emulator.run("TZ= date +%Z")
|
||||
self.assertEqual(tz[0].strip(), "Universal")
|
||||
|
||||
|
||||
class TestAllTimezone(infra.basetest.BRTest):
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||
"""
|
||||
BR2_TARGET_TZ_INFO=y
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
boot_armv5_cpio(self.emulator, self.builddir)
|
||||
tz, _ = self.emulator.run("date +%Z")
|
||||
self.assertEqual(tz[0].strip(), "UTC")
|
||||
tz, _ = self.emulator.run("TZ=UTC date +%Z")
|
||||
self.assertEqual(tz[0].strip(), "UTC")
|
||||
tz, _ = self.emulator.run("TZ=America/Los_Angeles date +%Z")
|
||||
self.assertEqual(tz[0].strip(), "PST")
|
||||
tz, _ = self.emulator.run("TZ=Europe/Paris date +%Z")
|
||||
self.assertEqual(tz[0].strip(), "CET")
|
||||
|
||||
|
||||
class TestNonDefaultLimitedTimezone(infra.basetest.BRTest):
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||
"""
|
||||
BR2_TARGET_TZ_INFO=y
|
||||
BR2_TARGET_TZ_ZONELIST="northamerica"
|
||||
BR2_TARGET_LOCALTIME="America/New_York"
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
boot_armv5_cpio(self.emulator, self.builddir)
|
||||
tz, _ = self.emulator.run("date +%Z")
|
||||
self.assertEqual(tz[0].strip(), "EST")
|
||||
tz, _ = self.emulator.run("TZ=UTC date +%Z")
|
||||
self.assertEqual(tz[0].strip(), "UTC")
|
||||
tz, _ = self.emulator.run("TZ=America/Los_Angeles date +%Z")
|
||||
self.assertEqual(tz[0].strip(), "PST")
|
||||
tz, _ = self.emulator.run("TZ=Europe/Paris date +%Z")
|
||||
self.assertEqual(tz[0].strip(), "Europe")
|
||||
0
support/testing/tests/download/__init__.py
Normal file
0
support/testing/tests/download/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
name: GIT_HASH
|
||||
@@ -0,0 +1,4 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_GIT_HASH_PATH)/package/*/*.mk))
|
||||
|
||||
# Get the git server port number from the test infra
|
||||
GITREMOTE_PORT_NUMBER ?= 9418
|
||||
@@ -0,0 +1 @@
|
||||
sha256 0000000000000000000000000000000000000000000000000000000000000000 bad-a238b1dfcd825d47d834af3c5223417c8411d90d-git4.tar.gz
|
||||
@@ -0,0 +1,11 @@
|
||||
################################################################################
|
||||
#
|
||||
# bad
|
||||
#
|
||||
################################################################################
|
||||
|
||||
BAD_VERSION = a238b1dfcd825d47d834af3c5223417c8411d90d
|
||||
BAD_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
BAD_SITE_METHOD = git
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1 @@
|
||||
sha256 5ee1800b8fd5f4a0d3e48a0c3a32a988ca974d0ef3c9bc8307ee1ff139cc3f3e export-subst-0fdb95cf4f3c5ed4003287649cabb33c5f843e26-git4.tar.gz
|
||||
@@ -0,0 +1,11 @@
|
||||
################################################################################
|
||||
#
|
||||
# export-subst
|
||||
#
|
||||
################################################################################
|
||||
|
||||
EXPORT_SUBST_VERSION = 0fdb95cf4f3c5ed4003287649cabb33c5f843e26
|
||||
EXPORT_SUBST_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
EXPORT_SUBST_SITE_METHOD = git
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1 @@
|
||||
sha256 32879a888bd3cfc10e108a0309940884aa0b01250fad5912c837d23c9918f8de good-a238b1dfcd825d47d834af3c5223417c8411d90d-git4.tar.gz
|
||||
@@ -0,0 +1,11 @@
|
||||
################################################################################
|
||||
#
|
||||
# good
|
||||
#
|
||||
################################################################################
|
||||
|
||||
GOOD_VERSION = a238b1dfcd825d47d834af3c5223417c8411d90d
|
||||
GOOD_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
GOOD_SITE_METHOD = git
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,11 @@
|
||||
################################################################################
|
||||
#
|
||||
# nohash
|
||||
#
|
||||
################################################################################
|
||||
|
||||
NOHASH_VERSION = a238b1dfcd825d47d834af3c5223417c8411d90d
|
||||
NOHASH_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
NOHASH_SITE_METHOD = git
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1 @@
|
||||
name: GIT_REFS
|
||||
@@ -0,0 +1,4 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_GIT_REFS_PATH)/package/*/*.mk))
|
||||
|
||||
# Get the git server port number from the test infra
|
||||
GITREMOTE_PORT_NUMBER ?= 9418
|
||||
@@ -0,0 +1,2 @@
|
||||
sha256 86ab4376a55b9ecd5269adbb43146d28bfc90c785c01dbed11cc6c16fc10406a git-partial-sha1-branch-head-68c197d0879d485f4f6c-git4.tar.gz
|
||||
sha256 2c1126513651b0d346a4e6d1bb75ac1c9999217e18026302d27bea47b06c7fb2 file
|
||||
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
#
|
||||
# git-partial-sha1-branch-head
|
||||
#
|
||||
################################################################################
|
||||
|
||||
GIT_PARTIAL_SHA1_BRANCH_HEAD_VERSION = 68c197d0879d485f4f6c
|
||||
GIT_PARTIAL_SHA1_BRANCH_HEAD_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
GIT_PARTIAL_SHA1_BRANCH_HEAD_SITE_METHOD = git
|
||||
GIT_PARTIAL_SHA1_BRANCH_HEAD_LICENSE_FILES = file
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,2 @@
|
||||
sha256 2baa9ab4c5cab2348de03609288c9c874f1f56e4373d3d089e83f381d45d4e68 git-partial-sha1-reachable-by-branch-317406308d9259e2231b-git4.tar.gz
|
||||
sha256 fabbc65c442bacb5e69b7adfea6d14fbbfc1327134322efd12771dc84387d507 file
|
||||
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
#
|
||||
# git-partial-sha1-reachable-by-branch
|
||||
#
|
||||
################################################################################
|
||||
|
||||
GIT_PARTIAL_SHA1_REACHABLE_BY_BRANCH_VERSION = 317406308d9259e2231b
|
||||
GIT_PARTIAL_SHA1_REACHABLE_BY_BRANCH_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
GIT_PARTIAL_SHA1_REACHABLE_BY_BRANCH_SITE_METHOD = git
|
||||
GIT_PARTIAL_SHA1_REACHABLE_BY_BRANCH_LICENSE_FILES = file
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,2 @@
|
||||
sha256 8042df3cc0a7427d1273a846ef5c38ebf589ba7a2ae8158fed3d29f5fea1cad3 git-partial-sha1-reachable-by-tag-46bae5b639e5a18e2cc4-git4.tar.gz
|
||||
sha256 2de87d77a2f226813f2d9bda906e970e4195605cdba6680443c0c04d89c532b6 file
|
||||
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
#
|
||||
# git-partial-sha1-reachable-by-tag
|
||||
#
|
||||
################################################################################
|
||||
|
||||
GIT_PARTIAL_SHA1_REACHABLE_BY_TAG_VERSION = 46bae5b639e5a18e2cc4
|
||||
GIT_PARTIAL_SHA1_REACHABLE_BY_TAG_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
GIT_PARTIAL_SHA1_REACHABLE_BY_TAG_SITE_METHOD = git
|
||||
GIT_PARTIAL_SHA1_REACHABLE_BY_TAG_LICENSE_FILES = file
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,2 @@
|
||||
sha256 be18eb6180f33ad01c09eefa40d8b58e09a9049d90cedd20a51ef2045beb92ad git-partial-sha1-tag-itself-2b0e0d98a49c97da6a61-git4.tar.gz
|
||||
sha256 6de8772a0a58fa62e2b8c58d4dae55c9db7534ad3b3918ecc849a9008d58f081 file
|
||||
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
#
|
||||
# git-partial-sha1-tag-itself
|
||||
#
|
||||
################################################################################
|
||||
|
||||
GIT_PARTIAL_SHA1_TAG_ITSELF_VERSION = 2b0e0d98a49c97da6a61
|
||||
GIT_PARTIAL_SHA1_TAG_ITSELF_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
GIT_PARTIAL_SHA1_TAG_ITSELF_SITE_METHOD = git
|
||||
GIT_PARTIAL_SHA1_TAG_ITSELF_LICENSE_FILES = file
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,2 @@
|
||||
sha256 36d9064cfd4a028f89b1e482b2543ee15df5ad0076714c175db54f3943f37ca3 git-partial-sha1-tag-points-to-516c9c5f64ec66534d4d-git4.tar.gz
|
||||
sha256 6de8772a0a58fa62e2b8c58d4dae55c9db7534ad3b3918ecc849a9008d58f081 file
|
||||
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
#
|
||||
# git-partial-sha1-tag-points-to
|
||||
#
|
||||
################################################################################
|
||||
|
||||
GIT_PARTIAL_SHA1_TAG_POINTS_TO_VERSION = 516c9c5f64ec66534d4d
|
||||
GIT_PARTIAL_SHA1_TAG_POINTS_TO_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
GIT_PARTIAL_SHA1_TAG_POINTS_TO_SITE_METHOD = git
|
||||
GIT_PARTIAL_SHA1_TAG_POINTS_TO_LICENSE_FILES = file
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,2 @@
|
||||
sha256 94d3addcdc2bf76c996a9278f16d0bef966522e2fc1367e0039cac419e51f4ca git-sha1-branch-head-68c197d0879d485f4f6cee85544722b79e68e59f-git4.tar.gz
|
||||
sha256 2c1126513651b0d346a4e6d1bb75ac1c9999217e18026302d27bea47b06c7fb2 file
|
||||
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
#
|
||||
# git-sha1-branch-head
|
||||
#
|
||||
################################################################################
|
||||
|
||||
GIT_SHA1_BRANCH_HEAD_VERSION = 68c197d0879d485f4f6cee85544722b79e68e59f
|
||||
GIT_SHA1_BRANCH_HEAD_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
GIT_SHA1_BRANCH_HEAD_SITE_METHOD = git
|
||||
GIT_SHA1_BRANCH_HEAD_LICENSE_FILES = file
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,2 @@
|
||||
sha256 1ddd9110d10762476e87b7a8c66cc9fa5df0e29a0476e242a68e0493a4b97f1f git-sha1-reachable-by-branch-317406308d9259e2231bd0d6ddad3de3832bce08-git4.tar.gz
|
||||
sha256 fabbc65c442bacb5e69b7adfea6d14fbbfc1327134322efd12771dc84387d507 file
|
||||
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
#
|
||||
# git-sha1-reachable-by-branch
|
||||
#
|
||||
################################################################################
|
||||
|
||||
GIT_SHA1_REACHABLE_BY_BRANCH_VERSION = 317406308d9259e2231bd0d6ddad3de3832bce08
|
||||
GIT_SHA1_REACHABLE_BY_BRANCH_SITE = $(GITREMOTE_DIR)/repo.git
|
||||
GIT_SHA1_REACHABLE_BY_BRANCH_SITE_METHOD = git
|
||||
GIT_SHA1_REACHABLE_BY_BRANCH_LICENSE_FILES = file
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,2 @@
|
||||
sha256 f2903e4b043fca2abb96a4aeabfcd83914c81929a9e880a743f23da86f7c68d8 git-sha1-reachable-by-tag-46bae5b639e5a18e2cc4dc508f080d566baeff59-git4.tar.gz
|
||||
sha256 2de87d77a2f226813f2d9bda906e970e4195605cdba6680443c0c04d89c532b6 file
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user