github.com/opencontainers/runc@v1.2.0-rc.1.0.20240520010911-492dc558cdd6/tests/integration/timens.bats (about) 1 #!/usr/bin/env bats 2 3 load helpers 4 5 function setup() { 6 setup_busybox 7 } 8 9 function teardown() { 10 teardown_bundle 11 } 12 13 @test "runc run [timens offsets with no timens]" { 14 requires timens 15 16 update_config '.process.args = ["cat", "/proc/self/timens_offsets"]' 17 update_config '.linux.namespaces = .linux.namespace | map(select(.type != "time"))' 18 update_config '.linux.timeOffsets = { 19 "monotonic": { "secs": 7881, "nanosecs": 2718281 }, 20 "boottime": { "secs": 1337, "nanosecs": 3141519 } 21 }' 22 23 runc run test_busybox 24 [ "$status" -ne 0 ] 25 } 26 27 @test "runc run [timens with no offsets]" { 28 requires timens 29 30 update_config '.process.args = ["cat", "/proc/self/timens_offsets"]' 31 update_config '.linux.namespaces += [{"type": "time"}] 32 | .linux.timeOffsets = null' 33 34 runc run test_busybox 35 [ "$status" -eq 0 ] 36 # Default offsets are 0. 37 grep -E '^monotonic\s+0\s+0$' <<<"$output" 38 grep -E '^boottime\s+0\s+0$' <<<"$output" 39 } 40 41 @test "runc run [simple timens]" { 42 requires timens 43 44 update_config '.process.args = ["cat", "/proc/self/timens_offsets"]' 45 update_config '.linux.namespaces += [{"type": "time"}] 46 | .linux.timeOffsets = { 47 "monotonic": { "secs": 7881, "nanosecs": 2718281 }, 48 "boottime": { "secs": 1337, "nanosecs": 3141519 } 49 }' 50 51 runc run test_busybox 52 [ "$status" -eq 0 ] 53 grep -E '^monotonic\s+7881\s+2718281$' <<<"$output" 54 grep -E '^boottime\s+1337\s+3141519$' <<<"$output" 55 } 56 57 @test "runc run [simple timens + userns]" { 58 requires root 59 requires timens 60 61 update_config ' .linux.namespaces += [{"type": "user"}] 62 | .linux.uidMappings += [{"hostID": 100000, "containerID": 0, "size": 65534}] 63 | .linux.gidMappings += [{"hostID": 200000, "containerID": 0, "size": 65534}] ' 64 remap_rootfs 65 66 update_config '.process.args = ["cat", "/proc/self/timens_offsets"]' 67 update_config '.linux.namespaces += [{"type": "time"}] 68 | .linux.timeOffsets = { 69 "monotonic": { "secs": 7881, "nanosecs": 2718281 }, 70 "boottime": { "secs": 1337, "nanosecs": 3141519 } 71 }' 72 73 runc run test_busybox 74 [ "$status" -eq 0 ] 75 grep -E '^monotonic\s+7881\s+2718281$' <<<"$output" 76 grep -E '^boottime\s+1337\s+3141519$' <<<"$output" 77 }