mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-19 16:40:46 -09:00
support/testing/tests/package/test_dos2unix.py: new runtime test
Signed-off-by: Julien Olivain <ju.o@free.fr> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
2b6ea18e47
commit
3435d52bab
@@ -1729,6 +1729,7 @@ F: support/testing/tests/package/sample_python_pyalsa.py
|
|||||||
F: support/testing/tests/package/sample_python_spake2.py
|
F: support/testing/tests/package/sample_python_spake2.py
|
||||||
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_gnupg2.py
|
F: support/testing/tests/package/test_gnupg2.py
|
||||||
F: support/testing/tests/package/test_highway.py
|
F: support/testing/tests/package/test_highway.py
|
||||||
F: support/testing/tests/package/test_hwloc.py
|
F: support/testing/tests/package/test_hwloc.py
|
||||||
|
|||||||
45
support/testing/tests/package/test_dos2unix.py
Normal file
45
support/testing/tests/package/test_dos2unix.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import infra.basetest
|
||||||
|
|
||||||
|
|
||||||
|
class TestDos2Unix(infra.basetest.BRTest):
|
||||||
|
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||||
|
"""
|
||||||
|
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
|
||||||
|
BR2_PACKAGE_DOS2UNIX=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()
|
||||||
|
|
||||||
|
# Check the program can run. This test also checks that we're
|
||||||
|
# using the real "dos2unix" rather than the applet provided in
|
||||||
|
# BusyBox, since the "--version" option is recognized by the
|
||||||
|
# real dos2unix and return an error in BusyBox.
|
||||||
|
self.assertRunOk("dos2unix --version")
|
||||||
|
|
||||||
|
# Create a text file with UNIX new-lines
|
||||||
|
self.assertRunOk("echo -e 'Hello\\nBuildroot' > original.txt")
|
||||||
|
|
||||||
|
# Convert the original UNIX file to DOS
|
||||||
|
self.assertRunOk("unix2dos -n original.txt dos.txt")
|
||||||
|
|
||||||
|
# DOS file is expected to be different than the UNIX file
|
||||||
|
_, exit_code = self.emulator.run("cmp original.txt dos.txt")
|
||||||
|
self.assertNotEqual(exit_code, 0)
|
||||||
|
|
||||||
|
# The "cat -A" command should print '^M$' for CR-LF
|
||||||
|
self.assertRunOk("cat -A dos.txt | grep -Fq '^M$'")
|
||||||
|
|
||||||
|
# Convert back DOS file to UNIX
|
||||||
|
self.assertRunOk("dos2unix -n dos.txt unix.txt")
|
||||||
|
|
||||||
|
# "unix.txt" should be identical to "original.txt"
|
||||||
|
self.assertRunOk("cmp original.txt unix.txt")
|
||||||
Reference in New Issue
Block a user