Skip to content

Commit

Permalink
Add a test case for hostanme and domainname
Browse files Browse the repository at this point in the history
Signed-off-by: utam0k <k0ma@utam0k.jp>
  • Loading branch information
utam0k committed Sep 12, 2022
1 parent bfbc652 commit e35f439
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions tests/integration/dev.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

load helpers

function setup() {
setup_busybox
}

function teardown() {
teardown_bundle
}

@test "runc run [redundant default /dev/tty]" {
setup_busybox

update_config ' .linux.devices += [{"path": "/dev/tty", "type": "c", "major": 5, "minor": 0}]
| .process.args |= ["ls", "-lLn", "/dev/tty"]'

Expand All @@ -25,6 +23,8 @@ function teardown() {
}

@test "runc run [redundant default /dev/ptmx]" {
setup_busybox

update_config ' .linux.devices += [{"path": "/dev/ptmx", "type": "c", "major": 5, "minor": 2}]
| .process.args |= ["ls", "-lLn", "/dev/ptmx"]'

Expand All @@ -36,6 +36,8 @@ function teardown() {
@test "runc run/update [device cgroup deny]" {
requires root

setup_busybox

update_config ' .linux.resources.devices = [{"allow": false, "access": "rwm"}]
| .linux.devices = [{"path": "/dev/kmsg", "type": "c", "major": 1, "minor": 11}]
| .process.capabilities.bounding += ["CAP_SYSLOG"]
Expand Down Expand Up @@ -73,6 +75,8 @@ function teardown() {
@test "runc run [device cgroup allow rw char device]" {
requires root

setup_busybox

update_config ' .linux.resources.devices = [{"allow": false, "access": "rwm"},{"allow": true, "type": "c", "major": 1, "minor": 11, "access": "rw"}]
| .linux.devices = [{"path": "/dev/kmsg", "type": "c", "major": 1, "minor": 11}]
| .process.args |= ["sh"]
Expand Down Expand Up @@ -104,6 +108,8 @@ function teardown() {
@test "runc run [device cgroup allow rm block device]" {
requires root

setup_busybox

# Get the first block device.
IFS=$' \t:' read -r device major minor <<<"$(lsblk -nd -o NAME,MAJ:MIN)"
# Could have used -o PATH but lsblk from CentOS 7 does not have it.
Expand Down Expand Up @@ -133,6 +139,8 @@ function teardown() {
@test "runc exec vs systemctl daemon-reload" {
requires systemd root

setup_busybox

runc run -d --console-socket "$CONSOLE_SOCKET" test_exec
[ "$status" -eq 0 ]

Expand All @@ -144,3 +152,26 @@ function teardown() {
runc exec -t test_exec sh -c "ls -l /proc/self/fd/0; echo 123"
[ "$status" -eq 0 ]
}

@test "runc run [hostname domainname]" {
requires root

setup_debian

update_config ' .process.args |= ["sh"]
| .hostname = "myhostname"
| .domainname= "mydomainname"'

runc run -d --console-socket "$CONSOLE_SOCKET" test_allow_char
[ "$status" -eq 0 ]

# test hostname
runc exec test_allow_char sh -c 'hostname'
[ "$status" -eq 0 ]
[[ "${lines[0]}" == *'myhostname'* ]]

# test domainname
runc exec test_allow_char sh -c 'domainname'
[ "$status" -eq 0 ]
[[ "${lines[0]}" == *'mydomainname'* ]]
}

0 comments on commit e35f439

Please sign in to comment.