mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-10-01 06:21:56 -09:00
support/testing: add a "file" package runtime test
Signed-off-by: Julien Olivain <ju.o@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
committed by
Peter Korsgaard
parent
9ce02d84ad
commit
e03513c773
@@ -1769,6 +1769,8 @@ F: support/testing/tests/package/test_cryptsetup/
|
|||||||
F: support/testing/tests/package/test_ddrescue.py
|
F: support/testing/tests/package/test_ddrescue.py
|
||||||
F: support/testing/tests/package/test_ddrescue/
|
F: support/testing/tests/package/test_ddrescue/
|
||||||
F: support/testing/tests/package/test_dos2unix.py
|
F: support/testing/tests/package/test_dos2unix.py
|
||||||
|
F: support/testing/tests/package/test_file.py
|
||||||
|
F: support/testing/tests/package/test_file/
|
||||||
F: support/testing/tests/package/test_fluidsynth.py
|
F: support/testing/tests/package/test_fluidsynth.py
|
||||||
F: support/testing/tests/package/test_fluidsynth/
|
F: support/testing/tests/package/test_fluidsynth/
|
||||||
F: support/testing/tests/package/test_fping.py
|
F: support/testing/tests/package/test_fping.py
|
||||||
|
|||||||
48
support/testing/tests/package/test_file.py
Normal file
48
support/testing/tests/package/test_file.py
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import infra.basetest
|
||||||
|
|
||||||
|
|
||||||
|
class TestFile(infra.basetest.BRTest):
|
||||||
|
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||||
|
f"""
|
||||||
|
BR2_PACKAGE_FILE=y
|
||||||
|
BR2_ROOTFS_OVERLAY="{infra.filepath("tests/package/test_file/rootfs-overlay")}"
|
||||||
|
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()
|
||||||
|
|
||||||
|
self.assertRunOk("file --version")
|
||||||
|
|
||||||
|
tests = [
|
||||||
|
("", "plain-text.txt", "ASCII text"),
|
||||||
|
("-i", "plain-text.txt", "text/plain"),
|
||||||
|
("", "plain-text.txt.gz", "gzip compressed data"),
|
||||||
|
("-i", "plain-text.txt.gz", "application/gzip"),
|
||||||
|
("-z", "plain-text.txt.gz", "ASCII text"),
|
||||||
|
("", "random-data.bin", "data"),
|
||||||
|
("-i", "random-data.bin", "application/octet-stream"),
|
||||||
|
("", "code.c", "C source"),
|
||||||
|
("-i", "code.c", "text/x-c"),
|
||||||
|
("", "script.sh", "POSIX shell script"),
|
||||||
|
("-i", "script.sh", "text/x-shellscript"),
|
||||||
|
("", "script.py", "Python script"),
|
||||||
|
("", "/usr/share/misc/magic.mgc", "magic binary file for file"),
|
||||||
|
("", "/usr/bin/file", "ELF"),
|
||||||
|
("", "/dev/zero", "character special"),
|
||||||
|
("", "/", "directory"),
|
||||||
|
("-h", "symlink-to-plain-text.txt", "symbolic link"),
|
||||||
|
("-L", "symlink-to-plain-text.txt", "ASCII text")
|
||||||
|
]
|
||||||
|
for opt_str, path, pattern in tests:
|
||||||
|
cmd = f"file {opt_str} '{path}'"
|
||||||
|
out, ret = self.emulator.run(cmd)
|
||||||
|
self.assertEqual(ret, 0, f"Failed to run '{cmd}'")
|
||||||
|
self.assertIn(pattern, "\n".join(out))
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
printf("Hello Buildroot!\n");
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
This is a plain text file...
|
||||||
Binary file not shown.
Binary file not shown.
3
support/testing/tests/package/test_file/rootfs-overlay/root/script.py
Executable file
3
support/testing/tests/package/test_file/rootfs-overlay/root/script.py
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
print("Hello Buildroot!")
|
||||||
3
support/testing/tests/package/test_file/rootfs-overlay/root/script.sh
Executable file
3
support/testing/tests/package/test_file/rootfs-overlay/root/script.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
echo "Hello Buildroot!"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
plain-text.txt
|
||||||
Reference in New Issue
Block a user