Skip to content

Commit

Permalink
Merge pull request kata-containers#30 from jodh-intel/disable-root-te…
Browse files Browse the repository at this point in the history
…sts-in-dev-mode

CI: Disable root tests in dev mode
  • Loading branch information
jodh-intel authored Jan 23, 2018
2 parents f2c29b3 + e74ded9 commit c730ff0
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions .ci/go-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ coverage_file_mode=0644
# Name of HTML format coverage file
html_report_file="coverage.html"

warn()
{
local msg="$*"
echo >&2 "WARNING: $msg"
}

# Run a command as either root or the current user (which might still be root).
#
# If the first argument is "root", run using sudo, else run as the current
Expand Down Expand Up @@ -64,16 +70,22 @@ test_coverage()
{
echo "mode: atomic" > "$test_coverage_file"

users="current"

if [ $(id -u) -eq 0 ]; then
echo >&2 "WARNING: Already running as root so will not re-run tests as non-root user."
echo >&2 "WARNING: As a result, only a subset of tests will be run"
echo >&2 "WARNING: (run this script as a non-privileged to ensure all tests are run)."
users="current"
warn "Already running as root so will not re-run tests as non-root user."
warn "As a result, only a subset of tests will be run"
warn "(run this script as a non-privileged to ensure all tests are run)."
else
# Run the unit-tests *twice* (since some must run as root and
# others must run as non-root), combining the resulting test
# coverage files.
users="current root"
if [ -n "$KATA_DEV_MODE" ]; then
warn "Dangerous to set CI and KATA_DEV_MODE together."
warn "NOT running tests as root."
else
# Run the unit-tests *twice* (since some must run as root and
# others must run as non-root), combining the resulting test
# coverage files.
users+=" root"
fi
fi

echo "INFO: Currently running as user '$(id -un)'"
Expand Down

0 comments on commit c730ff0

Please sign in to comment.