-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests/int/helpers: cleanup, enable shellcheck #3175
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It is not used since PR 2757, as all tests are run with cd to bundle directory. runc_spec argument count checking is removed since otherwise shellcheck complains: > SC2120: runc_spec references arguments, but none are ever passed. Signed-off-by: Kir Kolyshkin <[email protected]>
... and add the file to be checked by shellcheck. The warnings fixed are: In tests/integration/helpers.bash line 10: INTEGRATION_ROOT=$(dirname "$(readlink -f "$BASH_SOURCE")") ^----------^ SC2128: Expanding an array without an index only gives the first element. In tests/integration/helpers.bash line 22: TESTDATA="${INTEGRATION_ROOT}/testdata" ^------^ SC2034: TESTDATA appears unused. Verify use (or export if used externally). In tests/integration/helpers.bash line 42: echo "runc $@ (status=$status):" >&2 ^-- SC2145: Argument mixes string and array. Use * or separate argument. ^-----^ SC2154: status is referenced but not assigned. In tests/integration/helpers.bash line 43: echo "$output" >&2 ^-----^ SC2154: output is referenced but not assigned. In tests/integration/helpers.bash line 77: | .linux.gidMappings += [{"hostID": '"$(($ROOTLESS_GIDMAP_START + 10))"', "containerID": 1, "size": 20}] ^--------------------^ SC2004: $/${} is unnecessary on arithmetic variables. In tests/integration/helpers.bash line 78: | .linux.gidMappings += [{"hostID": '"$(($ROOTLESS_GIDMAP_START + 100))"', "containerID": 1000, "size": '"$(($ROOTLESS_GIDMAP_LENGTH - 1000))"'}]' ^--------------------^ SC2004: $/${} is unnecessary on arithmetic variables. ^---------------------^ SC2004: $/${} is unnecessary on arithmetic variables. In tests/integration/helpers.bash line 125: base_path=$(gawk '$(NF-2) == "cgroup" && $NF ~ /\<'${g}'\>/ { print $5; exit }' /proc/self/mountinfo) ^--^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: base_path=$(gawk '$(NF-2) == "cgroup" && $NF ~ /\<'"${g}"'\>/ { print $5; exit }' /proc/self/mountinfo) In tests/integration/helpers.bash line 127: eval CGROUP_${g^^}_BASE_PATH="${base_path}" ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: eval CGROUP_"${g^^}"_BASE_PATH="${base_path}" In tests/integration/helpers.bash line 229: if [ "x$CGROUP_UNIFIED" = "xyes" ]; then ^----------------^ SC2268: Avoid x-prefix in comparisons as it no longer serves a purpose. Did you mean: if [ "$CGROUP_UNIFIED" = "yes" ]; then In tests/integration/helpers.bash line 234: eval cgroup=\$${var}${REL_CGROUPS_PATH} ^----^ SC2086: Double quote to prevent globbing and word splitting. ^-----------------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: eval cgroup=\$"${var}""${REL_CGROUPS_PATH}" In tests/integration/helpers.bash line 236: cat $cgroup/$source ^-----^ SC2086: Double quote to prevent globbing and word splitting. ^-----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: cat "$cgroup"/"$source" In tests/integration/helpers.bash line 242: current="$(get_cgroup_value $1)" ^-- SC2086: Double quote to prevent globbing and word splitting. Did you mean: current="$(get_cgroup_value "$1")" In tests/integration/helpers.bash line 245: echo "current" $current "!?" "$expected" ^------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: echo "current" "$current" "!?" "$expected" In tests/integration/helpers.bash line 257: [ $(id -u) != "0" ] && user="--user" ^------^ SC2046: Quote this to prevent word splitting. In tests/integration/helpers.bash line 259: current=$(systemctl show $user --property $source $SD_UNIT_NAME | awk -F= '{print $2}') ^-----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: current=$(systemctl show $user --property "$source" $SD_UNIT_NAME | awk -F= '{print $2}') In tests/integration/helpers.bash line 261: [ "$current" = "$expected" ] || [ -n "$expected2" -a "$current" = "$expected2" ] ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. In tests/integration/helpers.bash line 309: check_cgroup_value "cpu.weight" $weight ^-----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: check_cgroup_value "cpu.weight" "$weight" In tests/integration/helpers.bash line 310: check_systemd_value "CPUWeight" $weight ^-----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: check_systemd_value "CPUWeight" "$weight" In tests/integration/helpers.bash line 383: if [ $CGROUP_UNIFIED = "no" -a ! -e "${CGROUP_MEMORY_BASE_PATH}/memory.memsw.limit_in_bytes" ]; then ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. In tests/integration/helpers.bash line 412: local cpu_count=$(grep -c '^processor' /proc/cpuinfo) ^-------^ SC2155: Declare and assign separately to avoid masking return values. In tests/integration/helpers.bash line 450: sleep $delay ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: sleep "$delay" In tests/integration/helpers.bash line 453: echo "Command \"$@\" failed $attempts times. Output: $output" ^-- SC2145: Argument mixes string and array. Use * or separate argument. In tests/integration/helpers.bash line 471: runc state $1 ^-- SC2086: Double quote to prevent globbing and word splitting. Did you mean: runc state "$1" In tests/integration/helpers.bash line 472: if [ $2 == "checkpointed" ]; then ^-- SC2086: Double quote to prevent globbing and word splitting. Did you mean: if [ "$2" == "checkpointed" ]; then In tests/integration/helpers.bash line 484: mkdir $dir ^--^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: mkdir "$dir" In tests/integration/helpers.bash line 497: kill -9 $(cat "$dir/pid") ^---------------^ SC2046: Quote this to prevent word splitting. In tests/integration/helpers.bash line 508: export ROOT=$(mktemp -d "$BATS_RUN_TMPDIR/runc.XXXXXX") ^--^ SC2155: Declare and assign separately to avoid masking return values. In tests/integration/helpers.bash line 512: cd "$ROOT/bundle" ^---------------^ SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. Did you mean: cd "$ROOT/bundle" || exit In tests/integration/helpers.bash line 535: cd "$INTEGRATION_ROOT" ^--------------------^ SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. Did you mean: cd "$INTEGRATION_ROOT" || exit For more information: https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. ... https://www.shellcheck.net/wiki/SC2034 -- TESTDATA appears unused. Verify u... https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt... Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin
force-pushed
the
tests-int-cleanups
branch
from
August 23, 2021 22:53
6823947
to
fb629db
Compare
kolyshkin
changed the title
tests/int: cleanups
tests/int/helpers: cleanup, enable shellcheck
Aug 24, 2021
thaJeztah
approved these changes
Aug 24, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
mrunalp
approved these changes
Aug 25, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Originally part of #3090, separated out to simplify review.
tests/int/helpers: rm $bundle handling
It is not used since PR tests/int: cleanups #2757, as all tests are run with cd to bundle
directory.
runc_spec argument count checking is removed since otherwise shellcheck
complains:
tests/int/helpers: fix shellcheck warnings
... and add the file to be checked by shellcheck.