diff options
Diffstat (limited to 'features/step_definitions/time_syncing.rb')
-rw-r--r-- | features/step_definitions/time_syncing.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/features/step_definitions/time_syncing.rb b/features/step_definitions/time_syncing.rb new file mode 100644 index 00000000..161a4162 --- /dev/null +++ b/features/step_definitions/time_syncing.rb @@ -0,0 +1,20 @@ +When /^I set the system time to "([^"]+)"$/ do |time| + next if @skip_steps_while_restoring_background + @vm.execute("date -s '#{time}'") +end + +When /^I bump the system time with "([^"]+)"$/ do |timediff| + next if @skip_steps_while_restoring_background + @vm.execute("date -s 'now #{timediff}'") +end + +Then /^Tails clock is less than (\d+) minutes incorrect$/ do |max_diff_mins| + next if @skip_steps_while_restoring_background + guest_time_str = @vm.execute("date --rfc-2822").stdout.chomp + guest_time = Time.rfc2822(guest_time_str) + host_time = Time.now + diff = (host_time - guest_time).abs + assert(diff < max_diff_mins.to_i*60, + "The guest's clock is off by #{diff} seconds (#{guest_time})") + puts "Time was #{diff} seconds off" +end |