Merge branch 'next'

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
Peter Korsgaard
2024-09-06 21:05:52 +02:00
400 changed files with 4249 additions and 5640 deletions

View File

@@ -0,0 +1,106 @@
import os
import subprocess
import infra.basetest
class TestDosFsTools(infra.basetest.BRTest):
# This test needs a Kernel with vfat and NLS support. The vfat
# filesystem also needs character set conversion libraries, since
# its default encoding is CP850.
kern_frag = \
infra.filepath("tests/package/test_dosfstools/linux-vfat.fragment")
config = \
f"""
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.47"
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="{kern_frag}"
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_DOSFSTOOLS=y
BR2_PACKAGE_DOSFSTOOLS_FATLABEL=y
BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y
BR2_PACKAGE_DOSFSTOOLS_MKFS_FAT=y
BR2_SYSTEM_ENABLE_NLS=y
BR2_TARGET_ROOTFS_CPIO=y
BR2_TARGET_ROOTFS_CPIO_GZIP=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_COPY=y
"""
def test_run(self):
# Prepare the disk image.
disk_file = os.path.join(self.builddir, "images", "disk.img")
self.emulator.logfile.write(f"Creating disk image: {disk_file}\n")
self.emulator.logfile.flush()
subprocess.check_call(
["dd", "if=/dev/zero", f"of={disk_file}", "bs=1M", "count=256"],
stdout=self.emulator.logfile,
stderr=self.emulator.logfile)
# Run the emulator with a blank drive.
img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
kern = os.path.join(self.builddir, "images", "Image")
bootargs = ["console=ttyAMA0"]
qemu_opts = ["-M", "virt", "-cpu", "cortex-a57", "-m", "256M",
"-initrd", img,
"-drive", f"file={disk_file},if=virtio,format=raw"]
self.emulator.boot(arch="aarch64",
kernel=kern,
kernel_cmdline=bootargs,
options=qemu_opts)
self.emulator.login()
# Variables for this test.
dev = "/dev/vda"
label = "BR_TEST"
mnt_pt = "/tmp/vfat"
data_file = f"{mnt_pt}/data.bin"
# We create the vfat filesystem on our device.
self.assertRunOk(f"mkfs.vfat {dev}")
# We set a label on this filesystem.
self.assertRunOk(f"fatlabel {dev} '{label}'")
# We create a mount point and mount this filesystem.
self.assertRunOk(f"mkdir -p {mnt_pt}")
self.assertRunOk(f"mount {dev} {mnt_pt}")
# We create a file with random data, to use this new
# filesystem a bit.
self.assertRunOk(f"dd if=/dev/urandom of={data_file} bs=1M count=10")
# We compute the sha256 hash and save it for later.
hash_cmd = f"sha256sum {data_file}"
out, ret = self.emulator.run(hash_cmd)
self.assertEqual(ret, 0)
data_sha256 = out[0]
# We unmount the filesystem.
self.assertRunOk(f"umount {mnt_pt}")
# We run a filesystem check. Since we cleanly unmounted the
# filesystem, we are not expecting any repair. This is just to
# test the program works correctly.
self.assertRunOk(f"fsck.vfat -v {dev}")
# We query the label and check it is the one we set at the
# beginning.
out, ret = self.emulator.run(f"fatlabel {dev}")
self.assertEqual(ret, 0)
self.assertEqual(out[0], label)
# We remount our filesystem.
self.assertRunOk(f"mount {dev} {mnt_pt}")
# We should recompute the same sha256 hash as before, on the
# first data file we created at the beginning.
out, ret = self.emulator.run(hash_cmd)
self.assertEqual(ret, 0)
self.assertEqual(out[0], data_sha256)

View File

@@ -0,0 +1,3 @@
CONFIG_VFAT_FS=y
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_ISO8859_1=y

View File

@@ -0,0 +1,107 @@
import os
import subprocess
import infra.basetest
class TestParted(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_PACKAGE_E2FSPROGS=y
BR2_PACKAGE_PARTED=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
# Prepare the disk image.
disk_file = os.path.join(self.builddir, "images", "disk.img")
self.emulator.logfile.write(f"Creating disk image: {disk_file}\n")
self.emulator.logfile.flush()
subprocess.check_call(
["dd", "if=/dev/zero", f"of={disk_file}", "bs=1M", "count=256"],
stdout=self.emulator.logfile,
stderr=self.emulator.logfile)
# Run the emulator with a drive.
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv5",
kernel="builtin",
options=[
"-initrd", cpio_file,
"-drive", f"file={disk_file},format=raw"])
self.emulator.login()
# We check the program can run.
self.assertRunOk("parted --version")
dev = "/dev/sda"
parted = f"parted {dev}"
# We print the partition list of our drive. Since the drive is
# supposed to be blank, it should not have a partition table.
part_list_cmd = f"{parted} print list"
out, ret = self.emulator.run(part_list_cmd, timeout=10)
self.assertEqual(ret, 0)
self.assertIn("Partition Table: unknown", out)
# We create a GPT partition table.
mklabel_cmd = f"{parted} mklabel gpt"
self.assertRunOk(mklabel_cmd, timeout=10)
# We print again the partition list. We should now see our
# partition table.
out, ret = self.emulator.run(part_list_cmd, timeout=10)
self.assertEqual(ret, 0)
self.assertIn("Partition Table: gpt", out)
# We create 3 partitions on our drive.
partitions = [
"MyPart1 ext2 1MiB 25%",
"MyPart2 ext4 25% 50%",
"MyPart3 ext4 50% 100%"
]
for part in partitions:
mkpart_cmd = f"{parted} mkpart {part}"
self.assertRunOk(mkpart_cmd, timeout=10)
# We print again the list of partitions, this time in machine
# parseable format. We check we have our 3 partitions.
cmd = f"parted -m {dev} print list"
out, ret = self.emulator.run(cmd, timeout=10)
self.assertEqual(ret, 0)
for part in range(1, 4):
self.assertTrue(out[1+part].startswith(f"{part}:"))
self.assertTrue(out[1+part].endswith(f":MyPart{part}:;"))
# We format our partitions.
self.assertRunOk(f"mkfs.ext2 {dev}1", timeout=10)
self.assertRunOk(f"mkfs.ext4 {dev}2", timeout=10)
self.assertRunOk(f"mkfs.ext4 {dev}3", timeout=10)
# We create a random data file in the temporary directory. It
# will be the reference source file that will be copied later
# on each of our filesystems.
data_file = "data.bin"
cmd = f"dd if=/dev/urandom of=/tmp/{data_file} bs=1M count=10"
self.assertRunOk(cmd)
# We compute the sha256 hash and save it for later.
hash_cmd = f"sha256sum {data_file}"
out, ret = self.emulator.run(f"( cd /tmp && {hash_cmd} )")
self.assertEqual(ret, 0)
data_sha256 = out[0]
# For each partition, we create a mount point directory, mount
# the filesystem, copy the reference data file in it, sync the
# filesystem, and compute the sha256 hash of the file. This
# sequence will exercise a bit the partitions and filesystems
# in read/write operations.
for part in range(1, 4):
self.assertRunOk(f"mkdir -p /tmp/MyPart{part}")
self.assertRunOk(f"mount {dev}{part} /tmp/MyPart{part}")
self.assertRunOk(f"cp /tmp/{data_file} /tmp/MyPart{part}/")
self.assertRunOk("sync")
out, ret = self.emulator.run(f"( cd /tmp/MyPart{part} && {hash_cmd} )")
self.assertEqual(ret, 0)
self.assertEqual(out[0], data_sha256)

View File

@@ -0,0 +1,53 @@
import os
import infra.basetest
class TestWhich(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_PACKAGE_WHICH=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def 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()
# We check the program can run. This also checks we are using
# the actual GNU which, since the BusyBox implementation does
# not accept this option.
self.assertRunOk("which --version")
# We check the primary usage is working.
out, ret = self.emulator.run("which sh")
self.assertEqual(ret, 0)
self.assertEqual(out[0], "/bin/sh")
alias_name = "buildoot_test_alias"
# We check "which" returns an error when the program is not
# found.
_, ret = self.emulator.run(f"which {alias_name}")
self.assertNotEqual(ret, 0)
# We define a shell alias.
alias_cmd = "/bin/true"
alias_def = f"{alias_name}='{alias_cmd}'"
self.assertRunOk(f"alias {alias_def}")
# We check our alias definition actually works, just by
# invoking it (since it's aliased to "true").
self.assertRunOk(alias_name)
# We check "which" is able to read aliases from the shell.
cmd = f"alias | which -i {alias_name}"
out, ret = self.emulator.run(cmd)
self.assertEqual(ret, 0)
self.assertEqual(out[0], alias_def)
self.assertEqual(out[1].strip(), alias_cmd)

View File

@@ -0,0 +1,41 @@
from tests.toolchain.test_external import TestExternalToolchain
class TestExternalToolchainArmArm(TestExternalToolchain):
config = """
BR2_arm=y
BR2_cortex_a8=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_ARM_ARM=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "arm-none-linux-gnueabihf"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainArmAarch64(TestExternalToolchain):
config = """
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_ARM_AARCH64=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "aarch64-none-linux-gnu"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainArmAarch64Be(TestExternalToolchain):
config = """
BR2_aarch64_be=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_ARM_AARCH64_BE=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "aarch64_be-none-linux-gnu"
def test_run(self):
TestExternalToolchain.common_check(self)

View File

@@ -2262,6 +2262,23 @@ class TestExternalToolchainBootlinRiscv32ilp32dGlibcBleedingEdge(TestExternalToo
TestExternalToolchain.common_check(self)
class TestExternalToolchainBootlinRiscv32ilp32dGlibcStable(TestExternalToolchain):
config = """
BR2_riscv=y
BR2_riscv_g=y
BR2_RISCV_32=y
BR2_RISCV_ABI_ILP32D=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_RISCV32_ILP32D_GLIBC_STABLE=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "riscv32-linux"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainBootlinRiscv32ilp32dMuslBleedingEdge(TestExternalToolchain):
config = """
BR2_riscv=y
@@ -2296,6 +2313,40 @@ class TestExternalToolchainBootlinRiscv32ilp32dMuslStable(TestExternalToolchain)
TestExternalToolchain.common_check(self)
class TestExternalToolchainBootlinRiscv32ilp32dUclibcBleedingEdge(TestExternalToolchain):
config = """
BR2_riscv=y
BR2_riscv_g=y
BR2_RISCV_32=y
BR2_RISCV_ABI_ILP32D=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_RISCV32_ILP32D_UCLIBC_BLEEDING_EDGE=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "riscv32-linux"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainBootlinRiscv32ilp32dUclibcStable(TestExternalToolchain):
config = """
BR2_riscv=y
BR2_riscv_g=y
BR2_RISCV_32=y
BR2_RISCV_ABI_ILP32D=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_RISCV32_ILP32D_UCLIBC_STABLE=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "riscv32-linux"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainBootlinRiscv64lp64dGlibcBleedingEdge(TestExternalToolchain):
config = """
BR2_riscv=y
@@ -2434,6 +2485,36 @@ class TestExternalToolchainBootlinS390xz13GlibcStable(TestExternalToolchain):
TestExternalToolchain.common_check(self)
class TestExternalToolchainBootlinS390xz13MuslBleedingEdge(TestExternalToolchain):
config = """
BR2_s390x=y
BR2_s390x_z13=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_S390X_Z13_MUSL_BLEEDING_EDGE=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "s390x-linux"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainBootlinS390xz13MuslStable(TestExternalToolchain):
config = """
BR2_s390x=y
BR2_s390x_z13=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_S390X_Z13_MUSL_STABLE=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "s390x-linux"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainBootlinShsh4GlibcBleedingEdge(TestExternalToolchain):
config = """
BR2_sh=y

View File

@@ -0,0 +1,91 @@
from tests.toolchain.test_external import TestExternalToolchain
class TestExternalToolchainSynopsysArc700LE(TestExternalToolchain):
config = """
BR2_arcle=y
BR2_arc770d=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARC=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARC700=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "arc-linux"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainSynopsysArc700BE(TestExternalToolchain):
config = """
BR2_arceb=y
BR2_arc770d=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARC=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARC700=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "arceb-linux"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainSynopsysArcHSGlibcLE(TestExternalToolchain):
config = """
BR2_arcle=y
BR2_archs38_full=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARC=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARCHS_GLIBC=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "arc-linux"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainSynopsysArcHSGlibcBE(TestExternalToolchain):
config = """
BR2_arceb=y
BR2_archs38_full=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARC=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARCHS_GLIBC=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "arceb-linux"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainSynopsysArcHSuClibcLE(TestExternalToolchain):
config = """
BR2_arcle=y
BR2_archs38_full=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARC=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARCHS_UCLIBC=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "arc-linux"
def test_run(self):
TestExternalToolchain.common_check(self)
class TestExternalToolchainSynopsysArcHSuClibcBE(TestExternalToolchain):
config = """
BR2_arceb=y
BR2_archs38_full=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARC=y
BR2_TOOLCHAIN_EXTERNAL_SYNOPSYS_ARCHS_UCLIBC=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
toolchain_prefix = "arceb-linux"
def test_run(self):
TestExternalToolchain.common_check(self)