hc
2023-02-13 e440ec23c5a540cdd3f7464e8779219be6fd3d95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
 
import infra.basetest
 
 
def boot_armv5_cpio(emulator, builddir):
        img = os.path.join(builddir, "images", "rootfs.cpio")
        emulator.boot(arch="armv5", kernel="builtin",
                      options=["-initrd", img])
        emulator.login()
 
 
class TestNoTimezone(infra.basetest.BRTest):
    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
        """
        # BR2_TARGET_TZ_INFO is not set
        BR2_TARGET_ROOTFS_CPIO=y
        # BR2_TARGET_ROOTFS_TAR is not set
        """
 
    def test_run(self):
        boot_armv5_cpio(self.emulator, self.builddir)
        tz, _ = self.emulator.run("TZ=UTC date +%Z")
        self.assertEqual(tz[0].strip(), "UTC")
        tz, _ = self.emulator.run("TZ=America/Los_Angeles date +%Z")
        self.assertEqual(tz[0].strip(), "UTC")
 
 
class TestGlibcAllTimezone(infra.basetest.BRTest):
    config = \
        """
        BR2_arm=y
        BR2_TOOLCHAIN_EXTERNAL=y
        BR2_TARGET_TZ_INFO=y
        BR2_TARGET_ROOTFS_CPIO=y
        # BR2_TARGET_ROOTFS_TAR is not set
        """
 
    def test_run(self):
        boot_armv5_cpio(self.emulator, self.builddir)
        tz, _ = self.emulator.run("date +%Z")
        self.assertEqual(tz[0].strip(), "UTC")
        tz, _ = self.emulator.run("TZ=UTC date +%Z")
        self.assertEqual(tz[0].strip(), "UTC")
        tz, _ = self.emulator.run("TZ=America/Los_Angeles date +%Z")
        self.assertEqual(tz[0].strip(), "PST")
        tz, _ = self.emulator.run("TZ=Europe/Paris date +%Z")
        self.assertEqual(tz[0].strip(), "CET")
 
 
class TestGlibcNonDefaultLimitedTimezone(infra.basetest.BRTest):
    config = \
        """
        BR2_arm=y
        BR2_TOOLCHAIN_EXTERNAL=y
        BR2_TARGET_TZ_INFO=y
        BR2_TARGET_TZ_ZONELIST="northamerica"
        BR2_TARGET_LOCALTIME="America/New_York"
        BR2_TARGET_ROOTFS_CPIO=y
        # BR2_TARGET_ROOTFS_TAR is not set
        """
 
    def test_run(self):
        boot_armv5_cpio(self.emulator, self.builddir)
        tz, _ = self.emulator.run("date +%Z")
        self.assertEqual(tz[0].strip(), "EST")
        tz, _ = self.emulator.run("TZ=UTC date +%Z")
        self.assertEqual(tz[0].strip(), "UTC")
        tz, _ = self.emulator.run("TZ=America/Los_Angeles date +%Z")
        self.assertEqual(tz[0].strip(), "PST")
        tz, _ = self.emulator.run("TZ=Europe/Paris date +%Z")
        self.assertEqual(tz[0].strip(), "Europe")