diff mbox series

[1/1] cpuacct.sh: Fix tst_get_free_pids failure detection

Message ID 20210920134229.28014-1-pvorel@suse.cz
State Accepted
Headers show
Series [1/1] cpuacct.sh: Fix tst_get_free_pids failure detection | expand

Commit Message

Petr Vorel Sept. 20, 2021, 1:42 p.m. UTC
local tasksmax=$(tst_get_free_pids) is successful, even
tst_get_free_pids fails. Assignment needs to be separated from
declaration to get tst_get_free_pids exit code. Similar fix to
87a82a62c ("lib/tst_test.sh: fix ROD_SILENT command return status check")

It fixes error:
tst_pid.c:79: TINFO: Cannot read session user limits from '/sys/fs/cgroup/user.slice/user-0.slice/pids.max'
tst_pid.c:83: TBROK: Expected 1 conversions got 0 FILE '/sys/fs/cgroup/pids/user.slice/user-0.slice/pids.max'
/opt/ltp/testcases/bin/cpuacct.sh: line 77: [: -le: unary operator expected

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/controllers/cpuacct/cpuacct.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Petr Vorel Sept. 21, 2021, 7:39 a.m. UTC | #1
Hi,

FYI merged.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/controllers/cpuacct/cpuacct.sh b/testcases/kernel/controllers/cpuacct/cpuacct.sh
index 3002d0a8a..ca881988f 100755
--- a/testcases/kernel/controllers/cpuacct/cpuacct.sh
+++ b/testcases/kernel/controllers/cpuacct/cpuacct.sh
@@ -71,8 +71,10 @@  check_free_memory()
 check_limits()
 {
 	local tasksneeded=$((max * nbprocess))
-	local tasksmax=$(tst_get_free_pids)
-	test $? -eq 0 || return 0
+	local tasksmax
+
+	tasksmax=$(tst_get_free_pids)
+	[ $? -eq 0 ] || return 0
 
 	if [ $tasksmax -le $tasksneeded ]; then
 		tst_brk TCONF "limit of tasks is too low (approximate need $tasksneeded, limit $tasksmax)"