From nobody Sat Apr 4 06:30:09 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 119F03EAC67 for ; Fri, 20 Mar 2026 18:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774031381; cv=none; b=mAmOuTYVf40FZJ1BKUbu8X8afMA5dVmSa8bYQt4srRk8L79WWIqqZHUMalIoJckYsAOzthoO69RP2GAgKFIwtSZ71eC8ZMr9M/FKCklyzHWzCeMwB5xYtwP6Wjb6LTiNyh5zdHgdDICPh7jViU3EuVgTT9COyFaUo7Intz9wU+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774031381; c=relaxed/simple; bh=CNCvVk8M6cXHeuhKo9e9N7wSVZT50Sy8YkEIIck7oxw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=licA1R7OZDZEGZqSGETnYQBhhw2gpjdSpEGmM1S9TzcSfPdRiG5FrOsXb4E3vlqgtEGlYjBTD/qJHtFRLSbHPXlasgdD5OQbftB/w8ibp/ZCMdP6J9n3lu61PAln9SJdAsGumBhrzuCoByEhcvYnX40bQ1/ozOzA5fl0yLiPgls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=WPj7X55w; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="WPj7X55w" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-486fd27754bso13944315e9.3 for ; Fri, 20 Mar 2026 11:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1774031378; x=1774636178; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Xhj6iK9mxvXqiBpyK8tX4BgiBzUUg/ToJ+/LCEiKyk8=; b=WPj7X55w+Y6s2MWVQlCI8Yj+owhrOT5jlZGwcgAsQPKRj/nN8t4LIfKBwGWF116k/D 4WSe26YFYdjuJbeBRaQld/VIH7UhTEDwO8ZmXwRAlvdtjfJdBfEn9DlV4W4C4kA8o911 VVNQs4Wanf5RXLm7aLZrBmklaSou2Hd33vuJRHg963dfJDpZWhKPLeKcEnzV7cSc0Lp+ M2LCIcTIq/qca4eghkMvRMzGlMaFuGTXJQRsl/lSZM5CRW5clBw0EBoZ0EPC2DE7+MLX wOrZ0ZMm2wxbIKABkLXqJzZbTPrp17bvIBFdVeGj24QFGexkZwmhwzECx4RcN69XkNr6 /31A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774031378; x=1774636178; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Xhj6iK9mxvXqiBpyK8tX4BgiBzUUg/ToJ+/LCEiKyk8=; b=Aa+vS7hj70koOAnj1/litlOjEpxxqNBG/lKwg1t6y30vAV9Xdy1PK4Le+5aTR3q0Ax iAxpq0GsYp5OaEyjReSXvnqtQCH0YhR5WrMh/5OSI4ZgumHiRaf+Pd1hXbWgyjUarU5e z2DFD3rRtJUqs0CkDD5e+jEq3eNBCYkrBSpgOQSa+l2cJfK8yCNqF+LJXA8q+6J0PpWA 3NQJLjQZcUOatxbZU/Fj3eXvE5tLw8CuRc7DbmjHPNkBjAgcZuSmDDilFeJEUyKRni4g 00XOhZrdeQXeG6ezQV/eBV+nyJrF9AvAUgZAECcjNTxxS1Nb9Ao++DCx85un8IBU36o4 RTTA== X-Forwarded-Encrypted: i=1; AJvYcCU1u6ahWSckp4CO2JM3ZdqbqfgzHeMGtEf3RRB+ubBcZILQJLHtEbNRdV2tqkNw5BhExu09TqEaWpJWFWg=@vger.kernel.org X-Gm-Message-State: AOJu0YwO1lYhLpln3892p4lPZy/FFSqcQ0IF6c/V8cf1cs0xDyh0PltU Go2gtc/Bmh+CnBdVEDDmbP1Vtezm44LJ5xBzjCVO1gpdxVeCh0eEQ6t2QXrJp6k8SMs= X-Gm-Gg: ATEYQzyh3KsScdiPXp4HZ8UOFeFkHSEFoLOkLIo12L6Ys4qCRVWZck6wG1ZkPM1bRu1 pu/Ybtma+b15Hi6s/Fwp63asK1fO/mYeNost+M/nKkUNq8SCKlkmYEHwNHZNrMOohV4srNEtZWw ESbr7aT4IExR6qHK37P4sZfdGzqaa/QRLNGL+8++Vl7415KUGPvMErWhp/rfaFZcetSJX1MPO5U 5QO0a9uVNM2cGr26nscSB0+CGyNFMuaPnaX46K48tHhLaTlJCXIccJoyVU/YMKuB0PtKMP2BPu1 4zikDalEMFBpwvFgnp9oS8RXGl1VKh/3C2AaepSqUYCBhK/pIkZD4AVqVKTfl4ejw2HZzy/CX/S fJxwUOdmxjm8RE4fG0XIqFFDumwUapDS+sSRJpAKi5/g02CwMVP64GzhPgryEUVrFnQIg9BTL/3 iQ3FmGszG8/A== X-Received: by 2002:a05:600c:c493:b0:485:4388:3492 with SMTP id 5b1f17b1804b1-486fedbd0b0mr62060455e9.11.1774031378372; Fri, 20 Mar 2026 11:29:38 -0700 (PDT) Received: from localhost ([189.99.238.44]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-64eabd6dc60sm1903545d50.6.2026.03.20.11.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 11:29:37 -0700 (PDT) From: =?utf-8?q?Ricardo_B=2E_Marli=C3=A8re?= Date: Fri, 20 Mar 2026 15:29:19 -0300 Subject: [PATCH 4/6] selftests/run_kselftest.sh: Allow choosing per-test log directory Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260320-selftests-fixes-v1-4-79144f76be01@suse.com> References: <20260320-selftests-fixes-v1-0-79144f76be01@suse.com> In-Reply-To: <20260320-selftests-fixes-v1-0-79144f76be01@suse.com> To: Shuah Khan , Nathan Chancellor , Nicolas Schier Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, =?utf-8?q?Ricardo_B=2E_Marli=C3=A8re?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openssh-sha256; t=1774031363; l=3675; i=rbm@suse.com; h=from:subject:message-id; bh=CNCvVk8M6cXHeuhKo9e9N7wSVZT50Sy8YkEIIck7oxw=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgguRCc5X8/UX9M40lkMnr//aFGOhce x5ezt8MFNUFlqYAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QGta/eA4GB0RU2QzWdbG6D7/tTx92qA+t+0kDc8F5W+598SHiw+WPZ/kiCt8flBMjTE4/+7KpIW 5TyEdF0vKTwA= X-Developer-Key: i=rbm@suse.com; a=openssh; fpr=SHA256:pzhe0fJpYLz+3cZ33FFPhIfaUElk9CXPFFXmalIH+1g The --per-test-log option currently hard-codes /tmp. However, the system under test will most likely have tmpfs mounted there. Since it's not clear which filenames the log files will have, the user should be able to specify a persistent directory to store the logs. Keeping those logs are important because the run_kselftest.sh runner will only yield KTAP output, trimming information that is otherwise available through running individual tests directly. Allow --per-test-log to take an optional directory argument. Keep the existing behaviour when the option is passed without an argument, but if a directory is provided, create it if needed, reject non-directory paths and non-writable directories, canonicalize it, and have runner.sh write per-test logs there instead of /tmp. This also makes relative paths safe by resolving them before the runner changes into a collection directory. Signed-off-by: Ricardo B. Marli=C3=A8re --- tools/testing/selftests/kselftest/runner.sh | 3 ++- tools/testing/selftests/run_kselftest.sh | 30 +++++++++++++++++++++++++= ++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/se= lftests/kselftest/runner.sh index 3a62039fa621..6e13818fe433 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -6,6 +6,7 @@ export skip_rc=3D4 export timeout_rc=3D124 export logfile=3D/dev/stdout export per_test_logging=3D +export per_test_log_dir=3D/tmp export RUN_IN_NETNS=3D =20 # Defaults for "settings" file fields: @@ -189,7 +190,7 @@ run_many() BASENAME_TEST=3D$(basename $TEST) test_num=3D$(( test_num + 1 )) if [ -n "$per_test_logging" ]; then - logfile=3D"/tmp/$BASENAME_TEST" + logfile=3D"$per_test_log_dir/$BASENAME_TEST" cat /dev/null > "$logfile" fi if [ -n "$RUN_IN_NETNS" ]; then diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selft= ests/run_kselftest.sh index 5f7bce9a640b..fdbbe5b8b079 100755 --- a/tools/testing/selftests/run_kselftest.sh +++ b/tools/testing/selftests/run_kselftest.sh @@ -22,7 +22,7 @@ usage() cat <&2 + exit 1 + fi + if [ ! -d "$per_test_log_dir" ] && \ + ! mkdir -p "$per_test_log_dir"; then + echo "Could not create log dir:" \ + "$per_test_log_dir" >&2 + exit 1 + fi + per_test_log_dir=3D$(cd "$per_test_log_dir" && pwd -P) + if [ -z "$per_test_log_dir" ]; then + echo "Could not resolve per-test log directory" >&2 + exit 1 + fi + if [ ! -w "$per_test_log_dir" ]; then + echo "Per-test log dir is not writable:" \ + "$per_test_log_dir" >&2 + exit 1 + fi + shift 2 + else + shift + fi ;; -t | --test) TESTS=3D"$TESTS $2" shift 2 ;; --=20 2.53.0