|
|
594167 |
From ce027f67d29066f188891c94447e50c12168a693 Mon Sep 17 00:00:00 2001
|
|
|
594167 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
594167 |
Date: Tue, 14 Jun 2022 09:02:00 +0900
|
|
|
594167 |
Subject: [PATCH] test: support debian/ubuntu specific timezone config file
|
|
|
594167 |
|
|
|
594167 |
(cherry picked from commit aab61a8c990a54703ae70ca951d0502860010267)
|
|
|
594167 |
|
|
|
594167 |
Related: #2087652
|
|
|
594167 |
---
|
|
|
594167 |
test/units/testsuite-45.sh | 24 ++++++++++++++++++++++++
|
|
|
594167 |
1 file changed, 24 insertions(+)
|
|
|
594167 |
|
|
|
594167 |
diff --git a/test/units/testsuite-45.sh b/test/units/testsuite-45.sh
|
|
|
594167 |
index 2069d2437f..d0f9dd9461 100755
|
|
|
594167 |
--- a/test/units/testsuite-45.sh
|
|
|
594167 |
+++ b/test/units/testsuite-45.sh
|
|
|
594167 |
@@ -7,9 +7,24 @@ set -o pipefail
|
|
|
594167 |
# shellcheck source=test/units/assert.sh
|
|
|
594167 |
. "$(dirname "$0")"/assert.sh
|
|
|
594167 |
|
|
|
594167 |
+restore_timezone() {
|
|
|
594167 |
+ if [[ -f /tmp/timezone.bak ]]; then
|
|
|
594167 |
+ mv /tmp/timezone.bak /etc/timezone
|
|
|
594167 |
+ else
|
|
|
594167 |
+ rm -f /etc/timezone
|
|
|
594167 |
+ fi
|
|
|
594167 |
+}
|
|
|
594167 |
+
|
|
|
594167 |
test_timezone() {
|
|
|
594167 |
local ORIG_TZ=
|
|
|
594167 |
|
|
|
594167 |
+ # Debian/Ubuntu specific file
|
|
|
594167 |
+ if [[ -f /etc/timezone ]]; then
|
|
|
594167 |
+ mv /etc/timezone /tmp/timezone.bak
|
|
|
594167 |
+ fi
|
|
|
594167 |
+
|
|
|
594167 |
+ trap restore_timezone EXIT
|
|
|
594167 |
+
|
|
|
594167 |
if [[ -L /etc/localtime ]]; then
|
|
|
594167 |
ORIG_TZ=$(readlink /etc/localtime | sed 's#^.*zoneinfo/##')
|
|
|
594167 |
echo "original tz: $ORIG_TZ"
|
|
|
594167 |
@@ -21,13 +36,22 @@ test_timezone() {
|
|
|
594167 |
echo 'change timezone'
|
|
|
594167 |
assert_eq "$(timedatectl --no-pager set-timezone Europe/Kiev 2>&1)" ""
|
|
|
594167 |
assert_eq "$(readlink /etc/localtime | sed 's#^.*zoneinfo/##')" "Europe/Kiev"
|
|
|
594167 |
+ if [[ -f /etc/timezone ]]; then
|
|
|
594167 |
+ assert_eq "$(cat /etc/timezone)" "Europe/Kiev"
|
|
|
594167 |
+ fi
|
|
|
594167 |
assert_in "Time zone: Europe/Kiev \(EEST, \+0[0-9]00\)" "$(timedatectl)"
|
|
|
594167 |
|
|
|
594167 |
if [[ -n "$ORIG_TZ" ]]; then
|
|
|
594167 |
echo 'reset timezone to original'
|
|
|
594167 |
assert_eq "$(timedatectl set-timezone "$ORIG_TZ" 2>&1)" ""
|
|
|
594167 |
assert_eq "$(readlink /etc/localtime | sed 's#^.*zoneinfo/##')" "$ORIG_TZ"
|
|
|
594167 |
+ if [[ -f /etc/timezone ]]; then
|
|
|
594167 |
+ assert_eq "$(cat /etc/timezone)" "$ORIG_TZ"
|
|
|
594167 |
+ fi
|
|
|
594167 |
fi
|
|
|
594167 |
+
|
|
|
594167 |
+ restore_timezone
|
|
|
594167 |
+ trap - EXIT
|
|
|
594167 |
}
|
|
|
594167 |
|
|
|
594167 |
restore_adjtime() {
|