]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - support/testing/tests/fs/test_iso9660.py
support/testing: standardize defconfig fragments style
[coffee/buildroot.git] / support / testing / tests / fs / test_iso9660.py
1 import os
2
3 import infra.basetest
4
5 BASIC_CONFIG = \
6     """
7     BR2_x86_pentium4=y
8     BR2_TOOLCHAIN_EXTERNAL=y
9     BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
10     BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
11     BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-i386-pentium4-full-2015.05-496-g85945aa.tar.bz2"
12     BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
13     BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_2=y
14     BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
15     # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
16     BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
17     BR2_TOOLCHAIN_EXTERNAL_CXX=y
18     BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
19     BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
20     BR2_LINUX_KERNEL=y
21     BR2_LINUX_KERNEL_CUSTOM_VERSION=y
22     BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.0"
23     BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
24     BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="{}"
25     # BR2_TARGET_ROOTFS_TAR is not set
26     """.format(infra.filepath("conf/minimal-x86-qemu-kernel.config"))
27
28 def test_mount_internal_external(emulator, builddir, internal=True):
29     img = os.path.join(builddir, "images", "rootfs.iso9660")
30     emulator.boot(arch="i386", options=["-cdrom", img])
31     emulator.login()
32
33     if internal:
34         cmd = "mount | grep 'rootfs on / type rootfs'"
35     else:
36         cmd = "mount | grep '/dev/root on / type iso9660'"
37
38     _, exit_code = emulator.run(cmd)
39     return exit_code
40
41 def test_touch_file(emulator):
42     _, exit_code = emulator.run("touch test")
43     return exit_code
44
45 #
46 # Grub 2
47 #
48
49 class TestIso9660Grub2External(infra.basetest.BRTest):
50     config = BASIC_CONFIG + \
51         """
52         BR2_TARGET_ROOTFS_ISO9660=y
53         # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
54         BR2_TARGET_GRUB2=y
55         BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
56         BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
57         BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
58         """.format(infra.filepath("conf/grub2.cfg"))
59
60     def test_run(self):
61         exit_code = test_mount_internal_external(self.emulator,
62                                                  self.builddir, internal=False)
63         self.assertEqual(exit_code, 0)
64
65         exit_code = test_touch_file(self.emulator)
66         self.assertEqual(exit_code, 1)
67
68 class TestIso9660Grub2Internal(infra.basetest.BRTest):
69     config = BASIC_CONFIG + \
70         """
71         BR2_TARGET_ROOTFS_ISO9660=y
72         BR2_TARGET_ROOTFS_ISO9660_INITRD=y
73         BR2_TARGET_GRUB2=y
74         BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
75         BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
76         BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
77         """.format(infra.filepath("conf/grub2.cfg"))
78
79     def test_run(self):
80         exit_code = test_mount_internal_external(self.emulator,
81                                                  self.builddir, internal=True)
82         self.assertEqual(exit_code, 0)
83
84         exit_code = test_touch_file(self.emulator)
85         self.assertEqual(exit_code, 0)
86
87 #
88 # Syslinux
89 #
90
91 class TestIso9660SyslinuxExternal(infra.basetest.BRTest):
92     config = BASIC_CONFIG + \
93         """
94         BR2_TARGET_ROOTFS_ISO9660=y
95         # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
96         BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
97         BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
98         BR2_TARGET_SYSLINUX=y
99         """.format(infra.filepath("conf/isolinux.cfg"))
100
101     def test_run(self):
102         exit_code = test_mount_internal_external(self.emulator,
103                                                  self.builddir, internal=False)
104         self.assertEqual(exit_code, 0)
105
106         exit_code = test_touch_file(self.emulator)
107         self.assertEqual(exit_code, 1)
108
109 class TestIso9660SyslinuxInternal(infra.basetest.BRTest):
110     config = BASIC_CONFIG + \
111         """
112         BR2_TARGET_ROOTFS_ISO9660=y
113         BR2_TARGET_ROOTFS_ISO9660_INITRD=y
114         BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
115         BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
116         BR2_TARGET_SYSLINUX=y
117         """.format(infra.filepath("conf/isolinux.cfg"))
118
119     def test_run(self):
120         exit_code = test_mount_internal_external(self.emulator,
121                                                  self.builddir, internal=True)
122         self.assertEqual(exit_code, 0)
123
124         exit_code = test_touch_file(self.emulator)
125         self.assertEqual(exit_code, 0)