Skip to content

Commit 9123ce6

Browse files
author
Mrunal Patel
authored
Merge pull request #922 from cyphar/test-uid-gid
tests: add tests with {u,g}id != 0
2 parents 9b3a2f1 + c77eb1c commit 9123ce6

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/integration/start_detached.bats

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ function teardown() {
2222
testcontainer test_busybox running
2323
}
2424

25+
@test "runc run detached ({u,g}id != 0)" {
26+
# replace "uid": 0 with "uid": 1000
27+
# and do a similar thing for gid.
28+
sed -i 's;"uid": 0;"uid": 1000;g' config.json
29+
sed -i 's;"gid": 0;"gid": 100;g' config.json
30+
31+
# run busybox detached
32+
runc run -d --console /dev/pts/ptmx test_busybox
33+
[ "$status" -eq 0 ]
34+
35+
# check state
36+
wait_for_container 15 1 test_busybox
37+
38+
testcontainer test_busybox running
39+
}
40+
2541
@test "runc run detached --pid-file" {
2642
# run busybox detached
2743
runc run --pid-file pid.txt -d --console /dev/pts/ptmx test_busybox

tests/integration/start_hello.bats

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ function teardown() {
2020
[[ "${output}" == *"Hello"* ]]
2121
}
2222

23+
@test "runc run ({u,g}id != 0)" {
24+
# replace "uid": 0 with "uid": 1000
25+
# and do a similar thing for gid.
26+
sed -i 's;"uid": 0;"uid": 1000;g' config.json
27+
sed -i 's;"gid": 0;"gid": 100;g' config.json
28+
29+
# run hello-world
30+
runc run test_hello
31+
[ "$status" -eq 0 ]
32+
33+
# check expected output
34+
[[ "${output}" == *"Hello"* ]]
35+
}
36+
2337
@test "runc run with rootfs set to ." {
2438
cp config.json rootfs/.
2539
rm config.json

0 commit comments

Comments
 (0)