Skip to contentSkip to conversation

cpuacct.sh: Fix tst_get_free_pids failure detection

PATCH In review Petr Vorel 1 participant 2 messages Sep 20, 2021 – Sep 21, 2021

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 cpuacct.sh: Fix tst_get_free_pids failure detection

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

---
 testcases/kernel/controllers/cpuacct/cpuacct.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
testcases/kernel/controllers/cpuacct/cpuacct.sh +4 -2
index 3002d0a8a..ca881988f 100755
@@ -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)"
Signature · 5 lines
2.33.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

Hi,

FYI merged.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp