From ffe5cdc4f1c87f5346ca69d26ac2fc57e331cf73 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Sun, 5 Mar 2017 00:20:40 +1100 Subject: [PATCH] tests: add various !terminal tests Previously we weren't testing that detached io works properly -- which will be quite important in the case for rootless containers. Signed-off-by: Aleksa Sarai --- tests/integration/config.json | 0 tests/integration/tty.bats | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tests/integration/config.json diff --git a/tests/integration/config.json b/tests/integration/config.json new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration/tty.bats b/tests/integration/tty.bats index baad58d7a..021f6058a 100644 --- a/tests/integration/tty.bats +++ b/tests/integration/tty.bats @@ -173,3 +173,58 @@ EOF # test tty width and height against original process.json [[ ${lines[0]} =~ "rows 10; columns 110" ]] } + +@test "runc create [terminal=false]" { + # Disable terminal creation. + sed -i 's|"terminal": true,|"terminal": false,|g' config.json + # Replace sh script with sleep. + sed -i 's|"sh"|"sleep", "1000s"|' config.json + + # Make sure that the handling of detached IO is done properly. See #1354. + __runc create test_busybox + + # Start the command. + runc start test_busybox + [ "$status" -eq 0 ] + + testcontainer test_busybox running + + # Kill the container. + runc kill test_busybox KILL + [ "$status" -eq 0 ] +} + +@test "runc run [terminal=false]" { + # Disable terminal creation. + sed -i 's|"terminal": true,|"terminal": false,|g' config.json + # Replace sh script with sleep. + sed -i 's|"sh"|"sleep", "1000s"|' config.json + + # Make sure that the handling of non-detached IO is done properly. See #1354. + ( + __runc run test_busybox + ) & + + wait_for_container 15 1 test_busybox + testcontainer test_busybox running + + # Kill the container. + runc kill test_busybox KILL + [ "$status" -eq 0 ] +} + +@test "runc run -d [terminal=false]" { + # Disable terminal creation. + sed -i 's|"terminal": true,|"terminal": false,|g' config.json + # Replace sh script with sleep. + sed -i 's|"sh"|"sleep", "1000s"|' config.json + + # Make sure that the handling of detached IO is done properly. See #1354. + __runc run -d test_busybox + + testcontainer test_busybox running + + # Kill the container. + runc kill test_busybox KILL + [ "$status" -eq 0 ] +}