tests: add tests with {u,g}id != 0

This is a very important testcase, as certain permission issues can
arise if we don't test this automatically.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
Aleksa Sarai 2016-06-18 12:03:48 +10:00
parent 5dc3f3576e
commit c77eb1c413
2 changed files with 30 additions and 0 deletions

View File

@ -22,6 +22,22 @@ function teardown() {
testcontainer test_busybox running
}
@test "runc run detached ({u,g}id != 0)" {
# replace "uid": 0 with "uid": 1000
# and do a similar thing for gid.
sed -i 's;"uid": 0;"uid": 1000;g' config.json
sed -i 's;"gid": 0;"gid": 100;g' config.json
# run busybox detached
runc run -d --console /dev/pts/ptmx test_busybox
[ "$status" -eq 0 ]
# check state
wait_for_container 15 1 test_busybox
testcontainer test_busybox running
}
@test "runc run detached --pid-file" {
# run busybox detached
runc run --pid-file pid.txt -d --console /dev/pts/ptmx test_busybox

View File

@ -20,6 +20,20 @@ function teardown() {
[[ "${output}" == *"Hello"* ]]
}
@test "runc run ({u,g}id != 0)" {
# replace "uid": 0 with "uid": 1000
# and do a similar thing for gid.
sed -i 's;"uid": 0;"uid": 1000;g' config.json
sed -i 's;"gid": 0;"gid": 100;g' config.json
# run hello-world
runc run test_hello
[ "$status" -eq 0 ]
# check expected output
[[ "${output}" == *"Hello"* ]]
}
@test "runc run with rootfs set to ." {
cp config.json rootfs/.
rm config.json