xref: /OK3568_Linux_fs/buildroot/support/testing/tests/package/test_perl.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1import os
2
3import infra.basetest
4
5
6class TestPerlBase(infra.basetest.BRTest):
7    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
8        """
9        BR2_TARGET_ROOTFS_CPIO=y
10        # BR2_TARGET_ROOTFS_TAR is not set
11        """
12
13    def login(self):
14        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
15        self.emulator.boot(arch="armv5",
16                           kernel="builtin",
17                           options=["-initrd", cpio_file])
18        self.emulator.login()
19
20    def module_test(self, module, script="1"):
21        cmd = "perl -M{} -e '{}'".format(module, script)
22        self.assertRunOk(cmd)
23
24
25class TestPerl(TestPerlBase):
26    config = TestPerlBase.config + \
27        """
28        BR2_PACKAGE_PERL=y
29        """
30
31    def version_test(self):
32        cmd = "perl -v"
33        output, exit_code = self.emulator.run(cmd)
34        self.assertEqual(exit_code, 0)
35        self.assertIn("This is perl 5", output[1])
36
37    def core_modules_test(self):
38        self.module_test("Cwd")
39        self.module_test("Data::Dumper")
40        self.module_test("Devel::Peek")
41        self.module_test("Digest::MD5")
42        self.module_test("Digest::SHA")
43        self.module_test("Encode")
44        self.module_test("Fcntl")
45        self.module_test("File::Glob")
46        self.module_test("Hash::Util")
47        self.module_test("I18N::Langinfo")
48        self.module_test("IO::Handle")
49        self.module_test("IPC::SysV")
50        self.module_test("List::Util")
51        self.module_test("MIME::Base64")
52        self.module_test("POSIX")
53        self.module_test("Socket")
54        self.module_test("Storable")
55        self.module_test("Sys::Hostname")
56        self.module_test("Sys::Syslog")
57        self.module_test("Time::HiRes")
58        self.module_test("Time::Piece")
59        self.module_test("Unicode::Collate")
60        self.module_test("Unicode::Normalize")
61
62    def test_run(self):
63        self.login()
64        self.version_test()
65        self.core_modules_test()
66