Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Rajakavitha Kodhandapani
tails
Commits
21d38bcd
Commit
21d38bcd
authored
Jun 28, 2015
by
kytv
Browse files
Refactor
parent
5135d118
Changes
1
Hide whitespace changes
Inline
Side-by-side
features/step_definitions/time_syncing.rb
View file @
21d38bcd
...
...
@@ -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
...
...
@@ -72,20 +79,6 @@ Then /^the hardware clock was not updated when Tails shut down$/ do
assert
(
diff
<=
max_time_drift
)
end
When
/^I bump the hardware clock's time with "([^"]+)"$/
do
|
timediff
|
next
if
@skip_steps_while_restoring_background
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
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 host's hwclock was supposed to be bumped to "
\
"'
#{
expected_time_lower_bound
}
' but is '
#{
new_time
}
'"
)
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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment