Skip to content

Commit

Permalink
tests/int/*bats: ignore SC2016
Browse files Browse the repository at this point in the history
Ignore the shellcheck warnings like this one:

> In tty.bats line 32:
> 	update_config '(.. | select(.[]? == "sh")) += ["-c", "stat -c %u:%g $(tty) | tr : \\\\n"]'
>                     ^-- SC2016: Expressions don't expand in single quotes, use double quotes for that.

While at it, fix some minor whitespace issues in tty.bats.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Aug 10, 2020
1 parent e52d68f commit 87964a1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions tests/integration/cgroups.bats
Expand Up @@ -170,6 +170,7 @@ function setup() {
[[ ${lines[0]} == "0::/foo" ]]

# teardown: remove "/foo"
# shellcheck disable=SC2016
runc exec test_cgroups_group sh -uxc 'echo -memory > /sys/fs/cgroup/cgroup.subtree_control; for f in $(cat /sys/fs/cgroup/foo/cgroup.procs); do echo $f > /sys/fs/cgroup/cgroup.procs; done; rmdir /sys/fs/cgroup/foo'
runc exec test_cgroups_group test ! -d /sys/fs/cgroup/foo
[ "$status" -eq 0 ]
Expand Down
1 change: 1 addition & 0 deletions tests/integration/checkpoint.bats
Expand Up @@ -27,6 +27,7 @@ function teardown() {

function setup_pipes() {
# The changes to 'terminal' are needed for running in detached mode
# shellcheck disable=SC2016
update_config ' (.. | select(.terminal? != null)) .terminal |= false
| (.. | select(.[]? == "sh")) += ["-c", "for i in `seq 10`; do read xxx || continue; echo ponG $xxx; done"]'

Expand Down
1 change: 1 addition & 0 deletions tests/integration/events.bats
Expand Up @@ -131,6 +131,7 @@ function teardown() {
(__runc events test_busybox > events.log) &
(
retry 10 1 eval "grep -q 'test_busybox' events.log"
# shellcheck disable=SC2016
__runc exec -d test_busybox sh -c 'test=$(dd if=/dev/urandom ibs=5120k)'
retry 10 1 eval "grep -q 'oom' events.log"
__runc delete -f test_busybox
Expand Down
23 changes: 15 additions & 8 deletions tests/integration/tty.bats
Expand Up @@ -13,7 +13,8 @@ function teardown() {

@test "runc run [tty ptsname]" {
# Replace sh script with readlink.
update_config '(.. | select(.[]? == "sh")) += ["-c", "for file in /proc/self/fd/[012]; do readlink $file; done"]'
# shellcheck disable=SC2016
update_config '(.. | select(.[]? == "sh")) += ["-c", "for file in /proc/self/fd/[012]; do readlink $file; done"]'

# run busybox
runc run test_busybox
Expand All @@ -29,7 +30,8 @@ function teardown() {
[[ "$ROOTLESS" -ne 0 ]] && requires rootless_idmap

# Replace sh script with stat.
update_config '(.. | select(.[]? == "sh")) += ["-c", "stat -c %u:%g $(tty) | tr : \\\\n"]'
# shellcheck disable=SC2016
update_config '(.. | select(.[]? == "sh")) += ["-c", "stat -c %u:%g $(tty) | tr : \\\\n"]'

# run busybox
runc run test_busybox
Expand All @@ -46,7 +48,8 @@ function teardown() {
# replace "uid": 0 with "uid": 1000
# and do a similar thing for gid.
# Replace sh script with stat.
update_config ' (.. | select(.uid? == 0)) .uid |= 1000
# shellcheck disable=SC2016
update_config ' (.. | select(.uid? == 0)) .uid |= 1000
| (.. | select(.gid? == 0)) .gid |= 100
| (.. | select(.[]? == "sh")) += ["-c", "stat -c %u:%g $(tty) | tr : \\\\n"]'

Expand All @@ -67,7 +70,8 @@ function teardown() {
testcontainer test_busybox running

# run the exec
runc exec -t test_busybox sh -c 'for file in /proc/self/fd/[012]; do readlink $file; done'
# shellcheck disable=SC2016
runc exec -t test_busybox sh -c 'for file in /proc/self/fd/[012]; do readlink $file; done'
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ /dev/pts/+ ]]
[[ ${lines[1]} =~ /dev/pts/+ ]]
Expand All @@ -87,7 +91,8 @@ function teardown() {
testcontainer test_busybox running

# run the exec
runc exec -t test_busybox sh -c 'stat -c %u:%g $(tty) | tr : \\n'
# shellcheck disable=SC2016
runc exec -t test_busybox sh -c 'stat -c %u:%g $(tty) | tr : \\n'
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ 0 ]]
[[ ${lines[1]} =~ 5 ]]
Expand All @@ -99,8 +104,9 @@ function teardown() {

# replace "uid": 0 with "uid": 1000
# and do a similar thing for gid.
# shellcheck disable=SC2016
update_config ' (.. | select(.uid? == 0)) .uid |= 1000
| (.. | select(.gid? == 0)) .gid |= 100'
| (.. | select(.gid? == 0)) .gid |= 100'

# run busybox detached
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
Expand All @@ -110,6 +116,7 @@ function teardown() {
testcontainer test_busybox running

# run the exec
# shellcheck disable=SC2016
runc exec -t test_busybox sh -c 'stat -c %u:%g $(tty) | tr : \\n'
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ 1000 ]]
Expand Down Expand Up @@ -197,7 +204,7 @@ EOF
@test "runc run [terminal=false]" {
# Disable terminal creation.
# Replace sh script with sleep.

update_config ' (.. | select(.terminal? != null)) .terminal |= false
| (.. | select(.[]? == "sh")) += ["sleep", "1000s"]
| del(.. | select(.? == "sh"))'
Expand All @@ -219,7 +226,7 @@ EOF
# Disable terminal creation.
# Replace sh script with sleep.
update_config ' (.. | select(.terminal? != null)) .terminal |= false
| (.. | select(.[]? == "sh")) += ["sleep", "1000s"]
| (.. | select(.[]? == "sh")) += ["sleep", "1000s"]
| del(.. | select(.? == "sh"))'

# Make sure that the handling of detached IO is done properly. See #1354.
Expand Down

0 comments on commit 87964a1

Please sign in to comment.