Skip to content

Commit 1b3b47b

Browse files
committed
check: check kmemleak before test run start
When the kernel enables kmemleak, the check script scans for memory leaks at the end of every test case run. However, if memory has already leaked before the blktests test run starts, the leak is detected at the end of the first test case. This makes it look as if the leak happend during the firest test case, which is confusing. To avoid this, check for memory leaks once before staring blktests. If any leaks are found, report them separately. Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent 7baa454 commit 1b3b47b

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

check

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ _setup_kmemleak() {
229229

230230
_check_kmemleak() {
231231
local kmemleak
232+
local out=$1
232233

233234
((KMEMLEAK)) || return 0
234235

@@ -240,7 +241,7 @@ _check_kmemleak() {
240241
return 0
241242
fi
242243

243-
printf '%s\n' "$kmemleak" > "${seqres}.kmemleak"
244+
printf '%s\n' "$kmemleak" > "$out"
244245
return 1
245246
}
246247

@@ -477,7 +478,7 @@ __call_test() {
477478
elif ! _check_dmesg "$dmesg_marker"; then
478479
TEST_RUN["status"]=fail
479480
TEST_RUN["reason"]=dmesg
480-
elif ! _check_kmemleak; then
481+
elif ! _check_kmemleak "${seqres}.kmemleak"; then
481482
TEST_RUN["status"]=fail
482483
TEST_RUN["reason"]=kmemleak
483484
else
@@ -1022,6 +1023,7 @@ _check() {
10221023
10231024
local test_dev test_name
10241025
local -a all_test_devs_in_array
1026+
local km_log="${OUTPUT}/start.kmemleak"
10251027
10261028
for test_name in "${!TEST_CASE_DEV_ARRAY[@]}"; do
10271029
IFS=" " read -r -a all_test_devs_in_array <<< \
@@ -1050,6 +1052,14 @@ _check() {
10501052
done
10511053
done
10521054
1055+
if ((KMEMLEAK)); then
1056+
# check if memory is already leaked before blktests run
1057+
_setup_kmemleak
1058+
if ! _check_kmemleak "$km_log"; then
1059+
echo "Memory leak detected before test run start. See '${km_log}'."
1060+
fi
1061+
fi
1062+
10531063
local test_name group prev_group
10541064
local tests=()
10551065
local ret=0

0 commit comments

Comments
 (0)