Merge remote-tracking branch 'flapflap/de-network_configuration'
[tails-test.git] / features / step_definitions / time_syncing.rb
blob161a4162307305f6615dffd6a7dc0a7875365aaf
1 When /^I set the system time to "([^"]+)"$/ do |time|
2   next if @skip_steps_while_restoring_background
3   @vm.execute("date -s '#{time}'")
4 end
6 When /^I bump the system time with "([^"]+)"$/ do |timediff|
7   next if @skip_steps_while_restoring_background
8   @vm.execute("date -s 'now #{timediff}'")
9 end
11 Then /^Tails clock is less than (\d+) minutes incorrect$/ do |max_diff_mins|
12   next if @skip_steps_while_restoring_background
13   guest_time_str = @vm.execute("date --rfc-2822").stdout.chomp
14   guest_time = Time.rfc2822(guest_time_str)
15   host_time = Time.now
16   diff = (host_time - guest_time).abs
17   assert(diff < max_diff_mins.to_i*60,
18          "The guest's clock is off by #{diff} seconds (#{guest_time})")
19   puts "Time was #{diff} seconds off"
20 end