1import os
2import infra.basetest
3
4
5class TestRuby(infra.basetest.BRTest):
6    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
7        """
8        BR2_TARGET_ROOTFS_CPIO=y
9        # BR2_TARGET_ROOTFS_TAR is not set
10        BR2_PACKAGE_RUBY=y
11        BR2_PACKAGE_ZLIB=y
12        """
13
14    def version_test(self):
15        cmd = "ruby -v"
16        output, exit_code = self.emulator.run(cmd)
17        self.assertEqual(exit_code, 0)
18
19    def zlib_test(self, timeout=-1):
20        cmd = "ruby -e 'require \"zlib\"'"
21        _, exit_code = self.emulator.run(cmd, timeout)
22        self.assertEqual(exit_code, 0)
23
24    def login(self):
25        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
26        self.emulator.boot(arch="armv5",
27                           kernel="builtin",
28                           options=["-initrd", cpio_file])
29        self.emulator.login()
30
31    def test_run(self):
32        self.login()
33        self.version_test()
34        self.zlib_test()
35