Skip to content

Commit

Permalink
Fixup bundle counting in real_content test library
Browse files Browse the repository at this point in the history
Eliminate some uses of wc -l that don't help. Take advantage of lines
array to count bundles.
Separate STDERR messages from $output and ${lines[@]} that are used for
bundles.
  • Loading branch information
bwarden committed Aug 26, 2024
1 parent 8742b3a commit b1bbef0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/real_content/real_content_lib.bash
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ install_bundles() {
[ "$1" = "-r" ] && { CMD="verify --fix"; shift ; }

if [ -z "$BUNDLE_LIST" ]; then
run sudo sh -c "$SWUPD bundle-list --all $SWUPD_OPTS_SHORT --quiet"
run --separate-stderr sudo sh -c "$SWUPD bundle-list --all $SWUPD_OPTS_SHORT --quiet"
# shellcheck disable=SC2154
# SC2154: output is referenced but not assigned.
# the output variable is being assigned and exported by bats
BUNDLE_LIST=$(echo "$output" | tr '\n' ' ')
num_pkgs=$(echo "$output" | wc -l)
num_pkgs=${#lines[@]}

cur_version=$(grep VERSION_ID "${ROOT_DIR}/usr/lib/os-release" | cut -d = -f 2)
num_pkgs_mom=$(sh -c "curl ${URL}/$cur_version/Manifest.MoM 2>/dev/null | grep ^M\\\\. | wc -l")
num_pkgs_mom=$(sh -c "curl ${URL}/$cur_version/Manifest.MoM 2>/dev/null | grep -c ^M\\\\.")

if [ "$num_pkgs" -ne "$num_pkgs_mom" ]; then
print "Number of packages on bundle-list --all is $num_pkgs. Expected is $num_pkgs_mom:"
Expand All @@ -72,7 +72,7 @@ install_bundles() {
CUR_VER=$("$SWUPD" info $SWUPD_OPTS | grep "Installed version"|cut -d ':' -f 2)
BUNDLE_LIST="${BUNDLE_LIST// /,}"
run sudo sh -c "$SWUPD $CMD $SWUPD_OPTS -B $BUNDLE_LIST -V $CUR_VER"
print "Instalation completed"
print "Installation completed"

assert_status_is 0
verify_system
Expand Down

0 comments on commit b1bbef0

Please sign in to comment.