summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranonym <anonym@riseup.net>2017-12-14 17:38:30 +0100
committeranonym <anonym@riseup.net>2019-05-14 16:51:14 +0200
commitef18f3b8e3a2cfa8a2379b5ef6e4278b97e1a6a3 (patch)
tree8db24d1ef5786cfcd797be87d221d881b429bce0
parent706cde463d845cd5202295fa06f9712f7f5aea76 (diff)
Test suite: drop trailing \n from remote shell/cmd_helper's stdout/stderr.
It's a source of programming errors, as recently observed when working on #14819 where a `.chomp` was forgotten. Now that part is unnecessary so we also clean up the code by removing all such occurrences.
-rwxr-xr-xfeatures/scripts/vm-execute6
-rw-r--r--features/step_definitions/apt.rb2
-rw-r--r--features/step_definitions/browser.rb10
-rw-r--r--features/step_definitions/checks.rb12
-rw-r--r--features/step_definitions/common_steps.rb14
-rw-r--r--features/step_definitions/dhcp.rb2
-rw-r--r--features/step_definitions/erase_memory.rb6
-rw-r--r--features/step_definitions/firewall_leaks.rb2
-rw-r--r--features/step_definitions/mac_spoofing.rb6
-rw-r--r--features/step_definitions/pidgin.rb2
-rw-r--r--features/step_definitions/root_access_control.rb2
-rw-r--r--features/step_definitions/time_syncing.rb6
-rw-r--r--features/step_definitions/torified_gnupg.rb2
-rw-r--r--features/step_definitions/unsafe_browser.rb2
-rw-r--r--features/step_definitions/usb.rb52
-rw-r--r--features/support/config.rb4
-rw-r--r--features/support/helpers/command.rb2
-rw-r--r--features/support/helpers/misc.rb2
-rw-r--r--features/support/helpers/remote_shell.rb12
-rw-r--r--features/support/helpers/vm.rb6
20 files changed, 82 insertions, 70 deletions
diff --git a/features/scripts/vm-execute b/features/scripts/vm-execute
index 8594647..17b176e 100755
--- a/features/scripts/vm-execute
+++ b/features/scripts/vm-execute
@@ -48,6 +48,8 @@ opt_parser.parse!(ARGV)
cmd = ARGV.join(" ")
c = RemoteShell::ShellCommand.new(FakeVM.new, cmd, cmd_opts)
puts "Return status: #{c.returncode}"
-puts "STDOUT:\n#{c.stdout}"
-puts "STDERR:\n#{c.stderr}"
+puts "STDOUT:"
+puts "#{c.stdout}\n"
+puts "STDERR:"
+puts "#{c.stderr}\n"
exit c.returncode
diff --git a/features/step_definitions/apt.rb b/features/step_definitions/apt.rb
index 0b8d26f..59039a4 100644
--- a/features/step_definitions/apt.rb
+++ b/features/step_definitions/apt.rb
@@ -4,7 +4,7 @@ Given /^the only hosts in APT sources are "([^"]*)"$/ do |hosts_str|
hosts = hosts_str.split(',')
apt_sources = $vm.execute_successfully(
"cat /etc/apt/sources.list /etc/apt/sources.list.d/*"
- ).stdout.chomp
+ ).stdout
apt_sources.each_line do |line|
next if ! line.start_with? "deb"
source_host = URI(line.split[1]).host
diff --git a/features/step_definitions/browser.rb b/features/step_definitions/browser.rb
index 89a264c..7f8b6d5 100644
--- a/features/step_definitions/browser.rb
+++ b/features/step_definitions/browser.rb
@@ -22,7 +22,7 @@ def xul_application_info(application)
user = LIVE_USER
binary = $vm.execute_successfully(
'echo ${TBB_INSTALL}/firefox.real', :libs => 'tor-browser'
- ).stdout.chomp
+ ).stdout
cmd_regex = "#{binary} .* -profile /home/#{user}/\.tor-browser/profile\.default"
chroot = ""
browser_reload_button_image = "TorBrowserReloadButton.png"
@@ -32,7 +32,7 @@ def xul_application_info(application)
user = "clearnet"
binary = $vm.execute_successfully(
'echo ${TBB_INSTALL}/firefox.real', :libs => 'tor-browser'
- ).stdout.chomp
+ ).stdout
cmd_regex = "#{binary} .* -profile /home/#{user}/\.unsafe-browser/profile\.default"
chroot = "/var/lib/unsafe-browser/chroot"
browser_reload_button_image = "UnsafeBrowserReloadButton.png"
@@ -43,10 +43,10 @@ def xul_application_info(application)
# We do not enable AppArmor confinement for the Tor Launcher.
binary = $vm.execute_successfully(
'echo ${TBB_INSTALL}/firefox-unconfined', :libs => 'tor-browser'
- ).stdout.chomp
+ ).stdout
tor_launcher_install = $vm.execute_successfully(
'echo ${TOR_LAUNCHER_INSTALL}', :libs => 'tor-browser'
- ).stdout.chomp
+ ).stdout
cmd_regex = "#{binary}\s+-app #{tor_launcher_install}/application\.ini.*"
chroot = ""
new_tab_button_image = nil
@@ -163,7 +163,7 @@ end
Then /^the (.*) uses all expected TBB shared libraries$/ do |application|
info = xul_application_info(application)
- pid = $vm.execute_successfully("pgrep --uid #{info[:user]} --full --exact '#{info[:cmd_regex]}'").stdout.chomp
+ pid = $vm.execute_successfully("pgrep --uid #{info[:user]} --full --exact '#{info[:cmd_regex]}'").stdout
assert(/\A\d+\z/.match(pid), "It seems like #{application} is not running")
xul_app_shared_lib_check(pid, info[:chroot], info[:unused_tbb_libs])
end
diff --git a/features/step_definitions/checks.rb b/features/step_definitions/checks.rb
index 8ed375b..c486e73 100644
--- a/features/step_definitions/checks.rb
+++ b/features/step_definitions/checks.rb
@@ -39,13 +39,13 @@ Then /^the live user has been setup by live\-boot$/ do
assert($vm.execute("test -e /var/lib/live/config/user-setup").success?,
"live-boot failed its user-setup")
actual_username = $vm.execute(". /etc/live/config/username.conf; " +
- "echo $LIVE_USERNAME").stdout.chomp
+ "echo $LIVE_USERNAME").stdout
assert_equal(LIVE_USER, actual_username)
end
Then /^the live user is a member of only its own group and "(.*?)"$/ do |groups|
expected_groups = groups.split(" ") << LIVE_USER
- actual_groups = $vm.execute("groups #{LIVE_USER}").stdout.chomp.sub(/^#{LIVE_USER} : /, "").split(" ")
+ actual_groups = $vm.execute("groups #{LIVE_USER}").stdout.sub(/^#{LIVE_USER} : /, "").split(" ")
unexpected = actual_groups - expected_groups
missing = expected_groups - actual_groups
assert_equal(0, unexpected.size,
@@ -58,14 +58,14 @@ Then /^the live user owns its home dir and it has normal permissions$/ do
home = "/home/#{LIVE_USER}"
assert($vm.execute("test -d #{home}").success?,
"The live user's home doesn't exist or is not a directory")
- owner = $vm.execute("stat -c %U:%G #{home}").stdout.chomp
- perms = $vm.execute("stat -c %a #{home}").stdout.chomp
+ owner = $vm.execute("stat -c %U:%G #{home}").stdout
+ perms = $vm.execute("stat -c %a #{home}").stdout
assert_equal("#{LIVE_USER}:#{LIVE_USER}", owner)
assert_equal("700", perms)
end
Then /^no unexpected services are listening for network connections$/ do
- for line in $vm.execute_successfully("ss -ltupn").stdout.chomp.split("\n") do
+ for line in $vm.execute_successfully("ss -ltupn").stdout.split("\n") do
splitted = line.split(/[[:blank:]]+/)
proto = splitted[0]
next unless ['tcp', 'udp'].include?(proto)
@@ -151,7 +151,7 @@ Then /^AppArmor is enabled$/ do
end
Then /^some AppArmor profiles are enforced$/ do
- assert($vm.execute("aa-status --enforced").stdout.chomp.to_i > 0,
+ assert($vm.execute("aa-status --enforced").stdout.to_i > 0,
"No AppArmor profile is enforced")
end
diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb
index eec0dbe..f3c3771 100644
--- a/features/step_definitions/common_steps.rb
+++ b/features/step_definitions/common_steps.rb
@@ -635,7 +635,7 @@ end
Given /^I switch to the "([^"]+)" NetworkManager connection$/ do |con_name|
$vm.execute("nmcli connection up id #{con_name}")
try_for_success(timeout: 60) do
- $vm.execute("nmcli --terse --fields NAME,STATE connection show").stdout.chomp.split("\n").include?("#{con_name}:activated")
+ $vm.execute("nmcli --terse --fields NAME,STATE connection show").stdout.split("\n").include?("#{con_name}:activated")
end
end
@@ -684,7 +684,7 @@ def is_persistent?(app)
conf = get_persistence_presets_config(true)["#{app}"]
c = $vm.execute("findmnt --noheadings --output SOURCE --target '#{conf}'")
# This check assumes that we haven't enabled read-only persistence.
- c.success? and c.stdout.chomp != "aufs"
+ c.success? and c.stdout != "aufs"
end
Then /^persistence for "([^"]+)" is (|not )enabled$/ do |app, enabled|
@@ -893,7 +893,7 @@ EOF
message: "Something is wrong with the LAN web server"
) do
content = $vm.execute_successfully("curl #{@web_server_url}",
- :user => LIVE_USER).stdout.chomp
+ :user => LIVE_USER).stdout
web_server_hello_msg == content
end
end
@@ -919,7 +919,7 @@ Given /^I (?:re)?start monitoring the AppArmor log of "([^"]+)"$/ do |profile|
# We will only care about entries for this profile from this time
# and on.
guest_time = $vm.execute_successfully(
- 'date +"%Y-%m-%d %H:%M:%S"').stdout.chomp
+ 'date +"%Y-%m-%d %H:%M:%S"').stdout
@apparmor_profile_monitoring_start ||= Hash.new
@apparmor_profile_monitoring_start[profile] = guest_time
end
@@ -936,7 +936,7 @@ When /^AppArmor has (not )?denied "([^"]+)" from opening "([^"]+)"$/ do |anti_te
"journalctl --full --no-pager " +
"--since='#{@apparmor_profile_monitoring_start[profile]}' " +
"SYSLOG_IDENTIFIER=kernel | grep -w '#{audit_line_regex}'"
- ).stdout.chomp
+ ).stdout
assert(audit_log.empty? == (anti_test ? true : false))
}
rescue TryFailed, Test::Unit::AssertionFailedError => e
@@ -998,7 +998,7 @@ def share_host_files(files)
files.each { |f| g.upload(f, "/" + File.basename(f)) }
end
step "I plug USB drive \"#{disk}\""
- mount_dir = $vm.execute_successfully('mktemp -d').stdout.chomp
+ mount_dir = $vm.execute_successfully('mktemp -d').stdout
dev = $vm.disk_dev(disk)
partition = dev + '1'
$vm.execute_successfully("mount #{partition} #{mount_dir}")
@@ -1008,7 +1008,7 @@ end
def mount_USB_drive(disk, fs_options = {})
fs_options[:encrypted] ||= false
- @tmp_usb_drive_mount_dir = $vm.execute_successfully('mktemp -d').stdout.chomp
+ @tmp_usb_drive_mount_dir = $vm.execute_successfully('mktemp -d').stdout
dev = $vm.disk_dev(disk)
partition = dev + '1'
if fs_options[:encrypted]
diff --git a/features/step_definitions/dhcp.rb b/features/step_definitions/dhcp.rb
index ba3e7b0..a3b4e8d 100644
--- a/features/step_definitions/dhcp.rb
+++ b/features/step_definitions/dhcp.rb
@@ -1,6 +1,6 @@
Then /^the hostname should not have been leaked on the network$/ do
begin
- hostnames = ["amnesia", $vm.execute("hostname").stdout.chomp]
+ hostnames = ["amnesia", $vm.execute("hostname").stdout]
packets = PacketFu::PcapFile.new.file_to_array(filename: @sniffer.pcap_file)
packets.each do |p|
# if PacketFu::TCPPacket.can_parse?(p)
diff --git a/features/step_definitions/erase_memory.rb b/features/step_definitions/erase_memory.rb
index b65bfd6..de782d2 100644
--- a/features/step_definitions/erase_memory.rb
+++ b/features/step_definitions/erase_memory.rb
@@ -12,7 +12,7 @@ def udev_watchdog_monitored_device
monitored_device_id = $vm.file_content('/sys' + monitored_out + '/dev').chomp
monitored_device =
$vm.execute_successfully(
- "readlink -f /dev/block/'#{monitored_device_id}'").stdout.chomp
+ "readlink -f /dev/block/'#{monitored_device_id}'").stdout
return monitored_device
end
@@ -21,11 +21,11 @@ Given /^udev-watchdog is monitoring the correct device$/ do
end
def used_ram_in_MiB
- return $vm.execute_successfully("free -m | awk '/^Mem:/ { print $3 }'").stdout.chomp.to_i
+ return $vm.execute_successfully("free -m | awk '/^Mem:/ { print $3 }'").stdout.to_i
end
def detected_ram_in_MiB
- return $vm.execute_successfully("free -m | awk '/^Mem:/ { print $2 }'").stdout.chomp.to_i
+ return $vm.execute_successfully("free -m | awk '/^Mem:/ { print $2 }'").stdout.to_i
end
def pattern_coverage_in_guest_ram(reference_memory_b)
diff --git a/features/step_definitions/firewall_leaks.rb b/features/step_definitions/firewall_leaks.rb
index 0cd94cc..e6ce31b 100644
--- a/features/step_definitions/firewall_leaks.rb
+++ b/features/step_definitions/firewall_leaks.rb
@@ -6,7 +6,7 @@ end
Given(/^I disable Tails' firewall$/) do
$vm.execute("/usr/local/lib/do_not_ever_run_me")
- iptables = $vm.execute("iptables -L -n -v").stdout.chomp.split("\n")
+ iptables = $vm.execute("iptables -L -n -v").stdout.split("\n")
for line in iptables do
if !line[/Chain (INPUT|OUTPUT|FORWARD) \(policy ACCEPT/] and
!line[/pkts[[:blank:]]+bytes[[:blank:]]+target/] and
diff --git a/features/step_definitions/mac_spoofing.rb b/features/step_definitions/mac_spoofing.rb
index 55307c5..e610c65 100644
--- a/features/step_definitions/mac_spoofing.rb
+++ b/features/step_definitions/mac_spoofing.rb
@@ -18,7 +18,7 @@ Then /^the (\d+)(?:st|nd|rd|th) network device has (its real|a spoofed) MAC addr
nic = "eth#{dev_nr.to_i - 1}"
nic_current_mac = $vm.execute_successfully(
"get_current_mac_of_nic #{nic}", :libs => 'hardware'
- ).stdout.chomp
+ ).stdout
begin
if is_spoofed
if nic_real_mac == nic_current_mac
@@ -93,7 +93,7 @@ Then /^the MAC spoofing panic mode disabled networking$/ do
["nic_ipv4_addr", "nic_ipv6_addr"].each do |function|
addr = $vm.execute_successfully(
"#{function} #{nic}", :libs => 'hardware'
- ).stdout.chomp
+ ).stdout
assert_equal("", addr, "NIC #{nic} was assigned address #{addr}")
end
end
@@ -104,7 +104,7 @@ When /^I hotplug a network device( and wait for it to be initialized)?$/ do |wai
# XXX:Buster: when we stop supporting the test suite on Stretch
# hosts, let's remove this workaround related to #14819 and just
# settle on a device that works on all supported platforms.
- if cmd_helper('lsb_release --short --codename').chomp == 'stretch'
+ if cmd_helper('lsb_release --short --codename') == 'stretch'
device = 'virtio'
else
device = 'pcnet'
diff --git a/features/step_definitions/pidgin.rb b/features/step_definitions/pidgin.rb
index 72a5029..7f1f2d0 100644
--- a/features/step_definitions/pidgin.rb
+++ b/features/step_definitions/pidgin.rb
@@ -206,7 +206,7 @@ When /^I join some empty multi-user chat$/ do
@screen.type("a", Sikuli::KeyModifier.CTRL)
@screen.type("c", Sikuli::KeyModifier.CTRL)
conference_server =
- $vm.execute_successfully("xclip -o", :user => LIVE_USER).stdout.chomp
+ $vm.execute_successfully("xclip -o", :user => LIVE_USER).stdout
@chat_room_jid = chat_room + "@" + conference_server
@screen.click("PidginJoinChatButton.png")
diff --git a/features/step_definitions/root_access_control.rb b/features/step_definitions/root_access_control.rb
index ba0ed59..9f0c49d 100644
--- a/features/step_definitions/root_access_control.rb
+++ b/features/step_definitions/root_access_control.rb
@@ -1,7 +1,7 @@
Then /^I should be able to run administration commands as the live user$/ do
stdout = $vm.execute("echo #{@sudo_password} | sudo -S whoami",
:user => LIVE_USER).stdout
- actual_user = stdout.sub(/^\[sudo\] password for #{LIVE_USER}: /, "").chomp
+ actual_user = stdout.sub(/^\[sudo\] password for #{LIVE_USER}: /, "")
assert_equal("root", actual_user, "Could not use sudo")
end
diff --git a/features/step_definitions/time_syncing.rb b/features/step_definitions/time_syncing.rb
index a562546..18a1561 100644
--- a/features/step_definitions/time_syncing.rb
+++ b/features/step_definitions/time_syncing.rb
@@ -41,7 +41,7 @@ When /^I bump the (hardware clock's|system) time with "([^"]+)"$/ do |clock_type
end
Then /^Tails clock is less than (\d+) minutes incorrect$/ do |max_diff_mins|
- guest_time_str = $vm.execute("date --rfc-2822").stdout.chomp
+ guest_time_str = $vm.execute("date --rfc-2822").stdout
guest_time = Time.rfc2822(guest_time_str)
host_time = Time.now
diff = (host_time - guest_time).abs
@@ -82,14 +82,14 @@ 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_str = $vm.execute('hwclock -r').stdout
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|
- hwclock = DateTime.parse($vm.execute_successfully("hwclock -r").stdout.chomp).to_time
+ hwclock = DateTime.parse($vm.execute_successfully("hwclock -r").stdout).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
diff --git a/features/step_definitions/torified_gnupg.rb b/features/step_definitions/torified_gnupg.rb
index 1a3d1b8..13b8b5a 100644
--- a/features/step_definitions/torified_gnupg.rb
+++ b/features/step_definitions/torified_gnupg.rb
@@ -251,7 +251,7 @@ Then /^GnuPG's dirmngr uses the configured keyserver$/ do
dirmngr_request = $vm.execute_successfully(
'gpg-connect-agent --dirmngr "keyserver --hosttable" /bye', user: LIVE_USER
)
- server = dirmngr_request.stdout.chomp.lines[1].split[4]
+ server = dirmngr_request.stdout.lines[1].split[4]
server = /keyserver\s+(\S+)$/.match(
$vm.file_content("/home/#{LIVE_USER}/.gnupg/dirmngr.conf")
)[1]
diff --git a/features/step_definitions/unsafe_browser.rb b/features/step_definitions/unsafe_browser.rb
index 434c0c4..f29df97 100644
--- a/features/step_definitions/unsafe_browser.rb
+++ b/features/step_definitions/unsafe_browser.rb
@@ -190,7 +190,7 @@ But /^checking for updates is disabled in the Unsafe Browser's configuration$/ d
end
Then /^the clearnet user has (|not )sent packets out to the Internet$/ do |sent|
- uid = $vm.execute_successfully("id -u clearnet").stdout.chomp.to_i
+ uid = $vm.execute_successfully("id -u clearnet").stdout.to_i
pkts = ip4tables_packet_counter_sum(:tables => ['OUTPUT'], :uid => uid)
case sent
when ''
diff --git a/features/step_definitions/usb.rb b/features/step_definitions/usb.rb
index 4e93c27..46efcf3 100644
--- a/features/step_definitions/usb.rb
+++ b/features/step_definitions/usb.rb
@@ -16,7 +16,7 @@ EOF
# above perl script any way
script.delete!("\n")
presets_configs = $vm.execute_successfully("perl -E '#{script}'")
- .stdout.chomp.split("\n")
+ .stdout.split("\n")
assert presets_configs.size >= 10,
"Got #{presets_configs.size} persistence preset configuration lines, " +
"which is too few"
@@ -48,7 +48,7 @@ def persistent_mounts
end
def persistent_volumes_mountpoints
- $vm.execute("ls -1 -d /live/persistence/*_unlocked/").stdout.chomp.split
+ $vm.execute("ls -1 -d /live/persistence/*_unlocked/").stdout.split
end
# Returns an array that for each persistence preset the running Tails is aware of,
@@ -76,7 +76,7 @@ EOF
# above perl script any way
script.delete!("\n")
presets = $vm.execute_successfully("perl -E '#{script}'")
- .stdout.chomp.split("\n")
+ .stdout.split("\n")
assert presets.size >= 10,
"Got #{presets.size} persistence presets, " +
"which is too few"
@@ -316,7 +316,7 @@ def tails_is_installed_helper(name, tails_root, loader)
assert(c.success?,
"USB drive '#{name}' has differences in /live:\n#{c.stdout}\n#{c.stderr}")
- syslinux_files = $vm.execute("ls -1 #{target_root}/syslinux").stdout.chomp.split
+ syslinux_files = $vm.execute("ls -1 #{target_root}/syslinux").stdout.split
# We deal with these files separately
ignores = ["syslinux.cfg", "exithelp.cfg", "ldlinux.c32", "ldlinux.sys"]
for f in syslinux_files - ignores do
@@ -428,7 +428,7 @@ Given /^all persistence presets(| from the old Tails version)(| but the first on
assert_not_nil($remembered_persistence_mounts)
expected_mounts = $remembered_persistence_mounts
end
- mount = $vm.execute("mount").stdout.chomp
+ mount = $vm.execute("mount").stdout
for _, dir in expected_mounts do
assert(mount.include?("on #{dir} "),
"Persistent directory '#{dir}' is not mounted")
@@ -446,15 +446,15 @@ end
def boot_device
# Approach borrowed from
# config/chroot_local_includes/lib/live/config/998-permissions
- boot_dev_id = $vm.execute("udevadm info --device-id-of-file=/lib/live/mount/medium").stdout.chomp
- boot_dev = $vm.execute("readlink -f /dev/block/'#{boot_dev_id}'").stdout.chomp
+ boot_dev_id = $vm.execute("udevadm info --device-id-of-file=/lib/live/mount/medium").stdout
+ boot_dev = $vm.execute("readlink -f /dev/block/'#{boot_dev_id}'").stdout
return boot_dev
end
def device_info(dev)
# Approach borrowed from
# config/chroot_local_includes/lib/live/config/998-permissions
- info = $vm.execute("udevadm info --query=property --name='#{dev}'").stdout.chomp
+ info = $vm.execute("udevadm info --query=property --name='#{dev}'").stdout
info.split("\n").map { |e| e.split('=') } .to_h
end
@@ -511,17 +511,17 @@ end
Then /^the boot device has safe access rights$/ do
super_boot_dev = boot_device.sub(/[[:digit:]]+$/, "")
- devs = $vm.execute("ls -1 #{super_boot_dev}*").stdout.chomp.split
+ devs = $vm.execute("ls -1 #{super_boot_dev}*").stdout.split
assert(devs.size > 0, "Could not determine boot device")
- all_users = $vm.execute("cut -d':' -f1 /etc/passwd").stdout.chomp.split
+ all_users = $vm.execute("cut -d':' -f1 /etc/passwd").stdout.split
all_users_with_groups = all_users.collect do |user|
- groups = $vm.execute("groups #{user}").stdout.chomp.sub(/^#{user} : /, "").split(" ")
+ groups = $vm.execute("groups #{user}").stdout.sub(/^#{user} : /, "").split(" ")
[user, groups]
end
for dev in devs do
- dev_owner = $vm.execute("stat -c %U #{dev}").stdout.chomp
- dev_group = $vm.execute("stat -c %G #{dev}").stdout.chomp
- dev_perms = $vm.execute("stat -c %a #{dev}").stdout.chomp
+ dev_owner = $vm.execute("stat -c %U #{dev}").stdout
+ dev_group = $vm.execute("stat -c %G #{dev}").stdout
+ dev_perms = $vm.execute("stat -c %a #{dev}").stdout
assert_equal("root", dev_owner)
assert(dev_group == "disk" || dev_group == "root",
"Boot device '#{dev}' owned by group '#{dev_group}', expected " +
@@ -542,9 +542,9 @@ end
Then /^all persistent filesystems have safe access rights$/ do
persistent_volumes_mountpoints.each do |mountpoint|
- fs_owner = $vm.execute("stat -c %U #{mountpoint}").stdout.chomp
- fs_group = $vm.execute("stat -c %G #{mountpoint}").stdout.chomp
- fs_perms = $vm.execute("stat -c %a #{mountpoint}").stdout.chomp
+ fs_owner = $vm.execute("stat -c %U #{mountpoint}").stdout
+ fs_group = $vm.execute("stat -c %G #{mountpoint}").stdout
+ fs_perms = $vm.execute("stat -c %a #{mountpoint}").stdout
assert_equal("root", fs_owner)
assert_equal("root", fs_group)
assert_equal('775', fs_perms)
@@ -563,10 +563,10 @@ Then /^all persistence configuration files have safe access rights$/ do
"#{mountpoint}/live-persistence.conf does exist, while it should not")
$vm.execute(
"ls -1 #{mountpoint}/persistence.conf* #{mountpoint}/live-*.conf"
- ).stdout.chomp.split.each do |f|
- file_owner = $vm.execute("stat -c %U '#{f}'").stdout.chomp
- file_group = $vm.execute("stat -c %G '#{f}'").stdout.chomp
- file_perms = $vm.execute("stat -c %a '#{f}'").stdout.chomp
+ ).stdout.split.each do |f|
+ file_owner = $vm.execute("stat -c %U '#{f}'").stdout
+ file_group = $vm.execute("stat -c %G '#{f}'").stdout
+ file_perms = $vm.execute("stat -c %a '#{f}'").stdout
assert_equal("tails-persistence-setup", file_owner)
assert_equal("tails-persistence-setup", file_group)
case f
@@ -590,8 +590,8 @@ Then /^all persistent directories(| from the old Tails version) have safe access
expected_dirs.each do |src, dest|
full_src = "#{mountpoint}/#{src}"
assert_vmcommand_success $vm.execute("test -d #{full_src}")
- dir_perms = $vm.execute_successfully("stat -c %a '#{full_src}'").stdout.chomp
- dir_owner = $vm.execute_successfully("stat -c %U '#{full_src}'").stdout.chomp
+ dir_perms = $vm.execute_successfully("stat -c %a '#{full_src}'").stdout
+ dir_owner = $vm.execute_successfully("stat -c %U '#{full_src}'").stdout
if dest.start_with?("/home/#{LIVE_USER}")
expected_perms = "700"
expected_owner = LIVE_USER
@@ -611,7 +611,7 @@ end
When /^I write some files expected to persist$/ do
persistent_mounts.each do |_, dir|
- owner = $vm.execute("stat -c %U #{dir}").stdout.chomp
+ owner = $vm.execute("stat -c %U #{dir}").stdout
assert($vm.execute("touch #{dir}/XXX_persist", :user => owner).success?,
"Could not create file in persistent directory #{dir}")
end
@@ -625,7 +625,7 @@ end
When /^I remove some files expected to persist$/ do
persistent_mounts.each do |_, dir|
- owner = $vm.execute("stat -c %U #{dir}").stdout.chomp
+ owner = $vm.execute("stat -c %U #{dir}").stdout
assert($vm.execute("rm #{dir}/XXX_persist", :user => owner).success?,
"Could not remove file in persistent directory #{dir}")
end
@@ -633,7 +633,7 @@ end
When /^I write some files not expected to persist$/ do
persistent_mounts.each do |_, dir|
- owner = $vm.execute("stat -c %U #{dir}").stdout.chomp
+ owner = $vm.execute("stat -c %U #{dir}").stdout
assert($vm.execute("touch #{dir}/XXX_gone", :user => owner).success?,
"Could not create file in persistent directory #{dir}")
end
diff --git a/features/support/config.rb b/features/support/config.rb
index c580642..f749dca 100644
--- a/features/support/config.rb
+++ b/features/support/config.rb
@@ -43,7 +43,7 @@ DEBUG_LOG_PSEUDO_FIFO = "#{$config["TMPDIR"]}/debug_log_pseudo_fifo"
DISPLAY = ENV['DISPLAY']
GIT_DIR = ENV['PWD']
KEEP_SNAPSHOTS = !ENV['KEEP_SNAPSHOTS'].nil?
-LIVE_USER = cmd_helper(". config/chroot_local-includes/etc/live/config.d/username.conf; echo ${LIVE_USERNAME}").chomp
+LIVE_USER = cmd_helper(". config/chroot_local-includes/etc/live/config.d/username.conf; echo ${LIVE_USERNAME}")
TAILS_ISO = ENV['TAILS_ISO']
TAILS_IMG = TAILS_ISO.sub(/\.iso/, '.img')
OLD_TAILS_ISO = ENV['OLD_TAILS_ISO'] || TAILS_ISO
@@ -83,5 +83,5 @@ SERVICES_EXPECTED_ON_ALL_IFACES =
SOME_DNS_SERVER = "208.67.222.222"
VM_XML_PATH = "#{Dir.pwd}/features/domains"
-TAILS_SIGNING_KEY = cmd_helper(". #{Dir.pwd}/config/amnesia; echo ${AMNESIA_DEV_KEYID}").tr(' ', '').chomp
+TAILS_SIGNING_KEY = cmd_helper(". #{Dir.pwd}/config/amnesia; echo ${AMNESIA_DEV_KEYID}").tr(' ', '')
TAILS_DEBIAN_REPO_KEY = "221F9A3C6FA3E09E182E060BC7988EA7A358D82E"
diff --git a/features/support/helpers/command.rb b/features/support/helpers/command.rb
index a12acf6..3f85158 100644
--- a/features/support/helpers/command.rb
+++ b/features/support/helpers/command.rb
@@ -6,7 +6,7 @@ def cmd_helper(cmd, env = {})
end
env = ENV.to_h.merge(env)
IO.popen(env, cmd) do |p|
- out = p.readlines.join("\n")
+ out = p.read.chomp
p.close
ret = $?
assert_equal(0, ret, "Command failed (returned #{ret}): #{cmd}:\n#{out}")
diff --git a/features/support/helpers/misc.rb b/features/support/helpers/misc.rb
index 53e697b..757ec9f 100644
--- a/features/support/helpers/misc.rb
+++ b/features/support/helpers/misc.rb
@@ -79,7 +79,7 @@ def get_free_space(machine, path)
raise 'Unsupported machine type #{machine} passed.'
end
output = free.split("\n").last
- return output.match(/[^\s]\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+.*/)[1].chomp.to_i
+ return output.match(/[^\s]\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+.*/)[1].to_i
end
def random_string_from_set(set, min_len, max_len)
diff --git a/features/support/helpers/remote_shell.rb b/features/support/helpers/remote_shell.rb
index 9f5ceba..45e6b91 100644
--- a/features/support/helpers/remote_shell.rb
+++ b/features/support/helpers/remote_shell.rb
@@ -65,7 +65,17 @@ module RemoteShell
opts[:spawn] = false unless opts.has_key?(:spawn)
type = opts[:spawn] ? "spawn" : "call"
debug_log("#{type}ing as #{opts[:user]}: #{cmd}")
- ret = RemoteShell.communicate(vm, 'sh_' + type, opts[:user], cmd, **opts)
+ status, stdout, stderr =
+ RemoteShell.communicate(vm, 'sh_' + type, opts[:user], cmd, **opts)
+ # The extra \n on the end printed by most shell-friendly
+ # programs adds no value and just causes trouble for
+ # us. Example:
+ # stdout == "expected string"
+ # would otherwise actually require one of:
+ # stdout.chomp == "expected string"
+ # stdout == "expected string\n"
+ # which is easy to forget. So let's kill it!
+ ret = [status, stdout.chomp, stderr.chomp]
debug_log("#{type} returned: #{ret}") if not(opts[:spawn])
return ret
end
diff --git a/features/support/helpers/vm.rb b/features/support/helpers/vm.rb
index 7e2dc07..0bcd800 100644
--- a/features/support/helpers/vm.rb
+++ b/features/support/helpers/vm.rb
@@ -451,7 +451,7 @@ class VM
def remote_shell_is_up?
msg = 'hello?'
Timeout::timeout(3) do
- execute_successfully("echo '#{msg}'").stdout.chomp == msg
+ execute_successfully("echo '#{msg}'").stdout == msg
end
rescue
false
@@ -479,7 +479,7 @@ class VM
end
def pidof(process)
- return execute("pidof -x -o '%PPID' " + process).stdout.chomp.split
+ return execute("pidof -x -o '%PPID' " + process).stdout.split
end
def select_virtual_desktop(desktop_number, user = LIVE_USER)
@@ -542,7 +542,7 @@ class VM
shift
done'
EOF
- ).stdout.chomp.split("\0")
+ ).stdout.split("\0")
end
def file_open(path)