mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
tty.bats: add test cases when stdin is not a tty
Note that stdout/stderr are already redirected by bats' `run` command, so the only way to get a controlling terminal is to open /dev/tty (which fails if there isn't one). Here's how I tested the failure to open /dev/tty: > [root@kir-rhat ~]# ssh -T root@localhost cat ./runme > cd /home/kir/go/src/github.com/opencontainers/runc > ./runc run -b tst xxx-$$ > echo $? > > [root@kir-rhat ~]# ssh -T root@localhost ./runme > time="2020-07-31T16:35:47-07:00" level=error msg="chdir tst: no such file or directory" > 1 If anyone knows how to obtain an tty-less environment without using ssh -T, please raise your hand. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -11,6 +11,14 @@ function teardown() {
|
||||
teardown_busybox
|
||||
}
|
||||
|
||||
@test "runc run [stdin not a tty]" {
|
||||
# stty size fails without a tty
|
||||
update_config '(.. | select(.[]? == "sh")) += ["-c", "stty size"]'
|
||||
# note that stdout/stderr are already redirected by bats' run
|
||||
runc run test_busybox < /dev/null
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "runc run [tty ptsname]" {
|
||||
# Replace sh script with readlink.
|
||||
# shellcheck disable=SC2016
|
||||
@@ -61,6 +69,18 @@ function teardown() {
|
||||
[[ ${lines[1]} =~ 5 ]]
|
||||
}
|
||||
|
||||
@test "runc exec [stdin not a tty]" {
|
||||
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# make sure we're running
|
||||
testcontainer test_busybox running
|
||||
|
||||
# note that stdout/stderr are already redirected by bats' run
|
||||
runc exec -t test_busybox sh -c "stty size" < /dev/null
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "runc exec [tty ptsname]" {
|
||||
# run busybox detached
|
||||
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
|
||||
|
||||
Reference in New Issue
Block a user