]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - support/testing/tests/fs/test_iso9660.py
support/testing: fix code 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
29 def test_mount_internal_external(emulator, builddir, internal=True):
30     img = os.path.join(builddir, "images", "rootfs.iso9660")
31     emulator.boot(arch="i386", options=["-cdrom", img])
32     emulator.login()
33
34     if internal:
35         cmd = "mount | grep 'rootfs on / type rootfs'"
36     else:
37         cmd = "mount | grep '/dev/root on / type iso9660'"
38
39     _, exit_code = emulator.run(cmd)
40     return exit_code
41
42
43 def test_touch_file(emulator):
44     _, exit_code = emulator.run("touch test")
45     return exit_code
46
47 #
48 # Grub 2
49
50
51 class TestIso9660Grub2External(infra.basetest.BRTest):
52     config = BASIC_CONFIG + \
53         """
54         BR2_TARGET_ROOTFS_ISO9660=y
55         # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
56         BR2_TARGET_GRUB2=y
57         BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
58         BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
59         BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
60         """.format(infra.filepath("conf/grub2.cfg"))
61
62     def test_run(self):
63         exit_code = test_mount_internal_external(self.emulator,
64                                                  self.builddir, internal=False)
65         self.assertEqual(exit_code, 0)
66
67         exit_code = test_touch_file(self.emulator)
68         self.assertEqual(exit_code, 1)
69
70
71 class TestIso9660Grub2Internal(infra.basetest.BRTest):
72     config = BASIC_CONFIG + \
73         """
74         BR2_TARGET_ROOTFS_ISO9660=y
75         BR2_TARGET_ROOTFS_ISO9660_INITRD=y
76         BR2_TARGET_GRUB2=y
77         BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
78         BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
79         BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
80         """.format(infra.filepath("conf/grub2.cfg"))
81
82     def test_run(self):
83         exit_code = test_mount_internal_external(self.emulator,
84                                                  self.builddir, internal=True)
85         self.assertEqual(exit_code, 0)
86
87         exit_code = test_touch_file(self.emulator)
88         self.assertEqual(exit_code, 0)
89
90 #
91 # Syslinux
92
93
94 class TestIso9660SyslinuxExternal(infra.basetest.BRTest):
95     config = BASIC_CONFIG + \
96         """
97         BR2_TARGET_ROOTFS_ISO9660=y
98         # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
99         BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
100         BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
101         BR2_TARGET_SYSLINUX=y
102         """.format(infra.filepath("conf/isolinux.cfg"))
103
104     def test_run(self):
105         exit_code = test_mount_internal_external(self.emulator,
106                                                  self.builddir, internal=False)
107         self.assertEqual(exit_code, 0)
108
109         exit_code = test_touch_file(self.emulator)
110         self.assertEqual(exit_code, 1)
111
112
113 class TestIso9660SyslinuxInternal(infra.basetest.BRTest):
114     config = BASIC_CONFIG + \
115         """
116         BR2_TARGET_ROOTFS_ISO9660=y
117         BR2_TARGET_ROOTFS_ISO9660_INITRD=y
118         BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
119         BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
120         BR2_TARGET_SYSLINUX=y
121         """.format(infra.filepath("conf/isolinux.cfg"))
122
123     def test_run(self):
124         exit_code = test_mount_internal_external(self.emulator,
125                                                  self.builddir, internal=True)
126         self.assertEqual(exit_code, 0)
127
128         exit_code = test_touch_file(self.emulator)
129         self.assertEqual(exit_code, 0)