|
| 1 | +{ |
| 2 | + timezone-static = import ./make-test.nix ({ pkgs, ... }: { |
| 3 | + name = "timezone-static"; |
| 4 | + meta.maintainers = with pkgs.lib.maintainers; [ lheckemann ]; |
| 5 | + |
| 6 | + machine.time.timeZone = "Europe/Amsterdam"; |
| 7 | + |
| 8 | + testScript = '' |
| 9 | + $machine->waitForUnit("dbus.socket"); |
| 10 | + $machine->fail("timedatectl set-timezone Asia/Tokyo"); |
| 11 | + my @dateResult = $machine->execute('date -d @0 "+%Y-%m-%d %H:%M:%S"'); |
| 12 | + $dateResult[1] eq "1970-01-01 01:00:00\n" or die "Timezone seems to be wrong"; |
| 13 | + ''; |
| 14 | + }); |
| 15 | + |
| 16 | + timezone-imperative = import ./make-test.nix ({ pkgs, ... }: { |
| 17 | + name = "timezone-imperative"; |
| 18 | + meta.maintainers = with pkgs.lib.maintainers; [ lheckemann ]; |
| 19 | + |
| 20 | + machine.time.timeZone = null; |
| 21 | + |
| 22 | + testScript = '' |
| 23 | + $machine->waitForUnit("dbus.socket"); |
| 24 | +
|
| 25 | + # Should default to UTC |
| 26 | + my @dateResult = $machine->execute('date -d @0 "+%Y-%m-%d %H:%M:%S"'); |
| 27 | + print $dateResult[1]; |
| 28 | + $dateResult[1] eq "1970-01-01 00:00:00\n" or die "Timezone seems to be wrong"; |
| 29 | +
|
| 30 | + $machine->succeed("timedatectl set-timezone Asia/Tokyo"); |
| 31 | +
|
| 32 | + # Adjustment should be taken into account |
| 33 | + my @dateResult = $machine->execute('date -d @0 "+%Y-%m-%d %H:%M:%S"'); |
| 34 | + print $dateResult[1]; |
| 35 | + $dateResult[1] eq "1970-01-01 09:00:00\n" or die "Timezone was not adjusted"; |
| 36 | +
|
| 37 | + # Adjustment should persist across a reboot |
| 38 | + $machine->shutdown; |
| 39 | + $machine->waitForUnit("dbus.socket"); |
| 40 | + my @dateResult = $machine->execute('date -d @0 "+%Y-%m-%d %H:%M:%S"'); |
| 41 | + print $dateResult[1]; |
| 42 | + $dateResult[1] eq "1970-01-01 09:00:00\n" or die "Timezone adjustment was not persisted"; |
| 43 | + ''; |
| 44 | + }); |
| 45 | +} |
0 commit comments