From c77eb1c4132dfb10a471acfbd9d47ed434c8eee4 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Sat, 18 Jun 2016 12:03:48 +1000 Subject: [PATCH] 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 --- tests/integration/start_detached.bats | 16 ++++++++++++++++ tests/integration/start_hello.bats | 14 ++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tests/integration/start_detached.bats b/tests/integration/start_detached.bats index e9df8e8b..52225007 100644 --- a/tests/integration/start_detached.bats +++ b/tests/integration/start_detached.bats @@ -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 diff --git a/tests/integration/start_hello.bats b/tests/integration/start_hello.bats index cddc2be3..6de65e07 100644 --- a/tests/integration/start_hello.bats +++ b/tests/integration/start_hello.bats @@ -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