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