unit tests: root check

The unit tests currently require running as root.  This has caused some
confusion that justifies adding a root check to `make localunit` and
error out for non-root users instead of starting the tests deemed to
fail.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2020-07-21 13:30:07 +02:00
parent df6920aa79
commit d628de31d7
2 changed files with 6 additions and 0 deletions

View File

@ -307,6 +307,7 @@ testunit: libpodimage ## Run unittest on the built image
.PHONY: localunit
localunit: test/goecho/goecho varlink_generate
hack/check_root.sh make localunit
ginkgo \
-r \
$(TESTFLAGS) \

5
hack/check_root.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
if ! [ $(id -u) = 0 ]; then
echo "Please run as root! '$@' requires root privileges."
exit 1
fi