git: 559c7ac87dfb - stable/14 - renice: Clean up the tests a bit.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Sun, 21 Jan 2024 18:11:06 UTC
The branch stable/14 has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=559c7ac87dfbd2d6ad224541fed029a78cf50c11

commit 559c7ac87dfbd2d6ad224541fed029a78cf50c11
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-12-20 16:59:37 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-01-21 16:08:48 +0000

    renice: Clean up the tests a bit.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Reviewed by:    ngie, asomers
    Differential Revision:  https://reviews.freebsd.org/D43087
    
    (cherry picked from commit afdce0837014fb7a41fced959c9457f89e878052)
---
 usr.bin/renice/tests/renice_test.sh | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/usr.bin/renice/tests/renice_test.sh b/usr.bin/renice/tests/renice_test.sh
index 8a4df7879ad4..7983eb594716 100755
--- a/usr.bin/renice/tests/renice_test.sh
+++ b/usr.bin/renice/tests/renice_test.sh
@@ -14,8 +14,9 @@ _renice() {
 
 atf_check_nice_value() {
 	local pid=$1
-	local nice=$2
-	atf_check test "$(ps -o nice= -p $pid)" -eq "$nice"
+	local expected=$2
+	local actual="$(ps -o nice= -p $pid)"
+	atf_check test "$actual" -eq "$expected"
 }
 
 atf_test_case renice_abs_pid
@@ -57,7 +58,7 @@ renice_abs_pgid_head() {
 renice_abs_pgid_body() {
 	local pid pgid nice incr
 	# make sure target runs in a different pgrp than ours
-	pid=$(sh -mc "sleep 60 >/dev/null & echo \$!")
+	pid="$(sh -mc "sleep 60 >/dev/null & echo \$!")"
 	pgid="$(ps -o pgid= -p $pid)"
 	nice="$(ps -o nice= -p $pid)"
 	incr=3
@@ -73,7 +74,7 @@ renice_rel_pgid_head() {
 renice_rel_pgid_body() {
 	local pid pgid nice incr
 	# make sure target runs in a different pgrp than ours
-	pid=$(sh -mc "sleep 60 >/dev/null & echo \$!")
+	pid="$(sh -mc "sleep 60 >/dev/null & echo \$!")"
 	pgid="$(ps -o pgid= -p $pid)"
 	nice="$(ps -o nice= -p $pid)"
 	incr=3
@@ -90,7 +91,7 @@ renice_abs_user_head() {
 }
 renice_abs_user_body() {
 	local user pid nice incr
-	pid=$(su -m $TEST_USER -c "/bin/sh -c 'sleep 60 >/dev/null & echo \$!'")
+	pid="$(su -m $TEST_USER -c "/bin/sh -c 'sleep 60 >/dev/null & echo \$!'")"
 	nice="$(ps -o nice= -p $pid)"
 	incr=3
 	_renice $((nice+incr)) -u $TEST_USER
@@ -105,7 +106,7 @@ renice_rel_user_head() {
 }
 renice_rel_user_body() {
 	local user pid nice incr
-	pid=$(su -m $TEST_USER -c "/bin/sh -c 'sleep 60 >/dev/null & echo \$!'")
+	pid="$(su -m $TEST_USER -c "/bin/sh -c 'sleep 60 >/dev/null & echo \$!'")"
 	nice="$(ps -o nice= -p $pid)"
 	incr=3
 	_renice -u -n $incr $TEST_USER