Commit 6efba81d authored by intrigeri's avatar intrigeri
Browse files

Merge remote-tracking branch 'kytv/test/9557-hwclock' into stable

Fix-committed: #9557
parents e6971feb 2c8b8eab
......@@ -18,17 +18,24 @@ When /^I set the system time to "([^"]+)"$/ do |time|
"'#{expected_time_lower_bound}' but is '#{new_time}'")
end
When /^I bump the system time with "([^"]+)"$/ do |timediff|
When /^I bump the (hardware clock's|system) time with "([^"]+)"$/ do |clock_type, timediff|
next if @skip_steps_while_restoring_background
old_time = DateTime.parse(@vm.execute_successfully("date").stdout).to_time
@vm.execute_successfully("date -s 'now #{timediff}'")
new_time = DateTime.parse(@vm.execute_successfully("date").stdout).to_time
case clock_type
when "hardware clock's"
old_time = DateTime.parse(@vm.execute_successfully("hwclock -r").stdout).to_time
@vm.execute_successfully("hwclock --set --date 'now #{timediff}'")
new_time = DateTime.parse(@vm.execute_successfully("hwclock -r").stdout).to_time
when 'system'
old_time = DateTime.parse(@vm.execute_successfully("date").stdout).to_time
@vm.execute_successfully("date -s 'now #{timediff}'")
new_time = DateTime.parse(@vm.execute_successfully("date").stdout).to_time
end
expected_time_lower_bound = DateTime.parse(
cmd_helper(["date", "-d", "#{old_time} #{timediff}"])).to_time
expected_time_upper_bound = expected_time_lower_bound + max_time_drift
assert(expected_time_lower_bound <= new_time &&
new_time <= expected_time_upper_bound,
"The guest's time was supposed to be bumped to " \
"The #{clock_type} time was supposed to be bumped to " \
"'#{expected_time_lower_bound}' but is '#{new_time}'")
end
......@@ -62,3 +69,23 @@ Then /^the system clock is just past Tails' build date$/ do
"The system time (#{system_time}) is more than #{max_diff} seconds " +
"past the build date (#{build_time})")
end
Then /^Tails' hardware clock is close to the host system's time$/ do
host_time = Time.now
hwclock_time_str = @vm.execute('hwclock -r').stdout.chomp
hwclock_time = DateTime.parse(hwclock_time_str).to_time
diff = (hwclock_time - host_time).abs
assert(diff <= max_time_drift)
end
Then /^the hardware clock is still off by "([^"]+)"$/ do |timediff|
next if @skip_steps_while_restoring_background
hwclock = DateTime.parse(@vm.execute_successfully("hwclock -r").stdout.chomp).to_time
expected_time_lower_bound = DateTime.parse(
cmd_helper(["date", "-d", "now #{timediff}"])).to_time - max_time_drift
expected_time_upper_bound = expected_time_lower_bound + max_time_drift
assert(expected_time_lower_bound <= hwclock &&
hwclock <= expected_time_upper_bound,
"The host's hwclock should be approximately " \
"'#{expected_time_lower_bound}' but is actually '#{hwclock}'")
end
......@@ -32,6 +32,18 @@ Feature: Time syncing
And Tor is ready
Then Tails clock is less than 5 minutes incorrect
Scenario: The system time is not synced to the hardware clock
When I bump the system time with "-15 days"
And I warm reboot the computer
And the computer reboots Tails
Then Tails' hardware clock is close to the host system's time
Scenario: Anti-test: Changes to the hardware clock are kept when rebooting
When I bump the hardware clock's time with "-15 days"
And I warm reboot the computer
And the computer reboots Tails
Then the hardware clock is still off by "-15 days"
# Scenario: Clock vs Tor consensus' valid-{after,until} etc.
Scenario: Create a new snapshot to the same state (w.r.t. Sikuli steps) as the Background except we're now in bridge mode
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment