Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e35f439

Browse files
committed
Add a test case for hostanme and domainname
Signed-off-by: utam0k <[email protected]>
1 parent bfbc652 commit e35f439

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

tests/integration/dev.bats

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
load helpers
44

5-
function setup() {
6-
setup_busybox
7-
}
8-
95
function teardown() {
106
teardown_bundle
117
}
128

139
@test "runc run [redundant default /dev/tty]" {
10+
setup_busybox
11+
1412
update_config ' .linux.devices += [{"path": "/dev/tty", "type": "c", "major": 5, "minor": 0}]
1513
| .process.args |= ["ls", "-lLn", "/dev/tty"]'
1614

@@ -25,6 +23,8 @@ function teardown() {
2523
}
2624

2725
@test "runc run [redundant default /dev/ptmx]" {
26+
setup_busybox
27+
2828
update_config ' .linux.devices += [{"path": "/dev/ptmx", "type": "c", "major": 5, "minor": 2}]
2929
| .process.args |= ["ls", "-lLn", "/dev/ptmx"]'
3030

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

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

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

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

142+
setup_busybox
143+
136144
runc run -d --console-socket "$CONSOLE_SOCKET" test_exec
137145
[ "$status" -eq 0 ]
138146

@@ -144,3 +152,26 @@ function teardown() {
144152
runc exec -t test_exec sh -c "ls -l /proc/self/fd/0; echo 123"
145153
[ "$status" -eq 0 ]
146154
}
155+
156+
@test "runc run [hostname domainname]" {
157+
requires root
158+
159+
setup_debian
160+
161+
update_config ' .process.args |= ["sh"]
162+
| .hostname = "myhostname"
163+
| .domainname= "mydomainname"'
164+
165+
runc run -d --console-socket "$CONSOLE_SOCKET" test_allow_char
166+
[ "$status" -eq 0 ]
167+
168+
# test hostname
169+
runc exec test_allow_char sh -c 'hostname'
170+
[ "$status" -eq 0 ]
171+
[[ "${lines[0]}" == *'myhostname'* ]]
172+
173+
# test domainname
174+
runc exec test_allow_char sh -c 'domainname'
175+
[ "$status" -eq 0 ]
176+
[[ "${lines[0]}" == *'mydomainname'* ]]
177+
}

0 commit comments

Comments
 (0)