From: Namhyung Kim <namhyung@kernel.org>
To: Jakub Brnak <jbrnak@redhat.com>
Cc: vmolnaro@redhat.com, acme@kernel.org, acme@redhat.com,
irogers@google.com, linux-perf-users@vger.kernel.org,
mpetlan@redhat.com
Subject: Re: [PATCH v3 6/7] perf test: Format log directories for shell tests
Date: Fri, 25 Jul 2025 23:21:52 -0700 [thread overview]
Message-ID: <aIR0AH_-y-jurGZq@google.com> (raw)
In-Reply-To: <20250721132642.40906-7-jbrnak@redhat.com>
On Mon, Jul 21, 2025 at 03:26:41PM +0200, Jakub Brnak wrote:
> From: Veronika Molnarova <vmolnaro@redhat.com>
>
> The name of the log directory can be taken from the test suite
> description, which possibly could contain whitespace characters. This
> can cause further issues if the name is not quoted correctly.
>
> Replace the whitespace characters with an underscore to prevent the
> possible issues caused by the name splitting.
>
> Signed-off-by: Michael Petlan <mpetlan@redhat.com>
> Signed-off-by: Veronika Molnarova <vmolnaro@redhat.com>
> Signed-off-by: Jakub Brnak <jbrnak@redhat.com>
> ---
> tools/perf/tests/builtin-test.c | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index 89b180798224..9cb0788d3307 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -283,6 +283,21 @@ static bool test_exclusive(const struct test_suite *t, int test_case)
> return t->test_cases[test_case].exclusive;
> }
>
> +/* Replace non-alphanumeric characters with _ */
> +static void check_dir_name(const char *src, char *dst)
It's not about just checking the name. Maybe replace_dir_name()?
Thanks,
Namhyung
> +{
> + size_t i;
> + size_t len = strlen(src);
> +
> + for (i = 0; i < len; i++) {
> + if (!isalnum(src[i]))
> + dst[i] = '_';
> + else
> + dst[i] = src[i];
> + }
> + dst[i] = '\0';
> +}
> +
> static int delete_file(const char *fpath, const struct stat *sb __maybe_unused,
> int typeflag, struct FTW *ftwbuf)
> {
> @@ -328,10 +343,12 @@ static bool create_logs(struct test_suite *t, int pass){
>
> static char *setup_shell_logs(const char *name)
> {
> - char template[PATH_MAX];
> + char template[PATH_MAX], valid_name[strlen(name)+1];
> char *temp_dir;
>
> - if (snprintf(template, PATH_MAX, "/tmp/perf_test_%s.XXXXXX", name) < 0) {
> + check_dir_name(name, valid_name);
> +
> + if (snprintf(template, PATH_MAX, "/tmp/perf_test_%s.XXXXXX", valid_name) < 0) {
It'd be better to do snprintf() first and replace the name so that it
doesn't add the valid_name buffer.
Thanks,
Namhyung
> pr_err("Failed to create log dir template");
> return NULL; /* Skip the testsuite */
> }
> --
> 2.50.1
>
next prev parent reply other threads:[~2025-07-26 6:21 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 22:03 [PATCH 00/10] Introduce structure for shell tests vmolnaro
2024-12-20 22:03 ` [PATCH 01/10] perf test perftool_testsuite: Add missing description vmolnaro
2024-12-20 22:03 ` [PATCH 02/10] perf test perftool_testsuite: Return correct value for skipping vmolnaro
2024-12-20 22:03 ` [PATCH 03/10] perf test perftool_testsuite: Use absolute paths vmolnaro
2024-12-20 22:03 ` [PATCH 04/10] perf tests: Create a structure for shell tests vmolnaro
2024-12-20 22:03 ` [PATCH 05/10] perf testsuite: Fix perf-report tests installation vmolnaro
2024-12-20 22:03 ` [PATCH 06/10] perf test: Provide setup for the shell test suite vmolnaro
2024-12-20 22:03 ` [PATCH 07/10] perftool-testsuite: Add empty setup for base_probe vmolnaro
2024-12-20 22:03 ` [PATCH 08/10] perf test: Introduce storing logs for shell tests vmolnaro
2024-12-20 22:03 ` [PATCH 09/10] perf test: Format log directories " vmolnaro
2024-12-20 22:03 ` [PATCH 10/10] perf test: Remove perftool drivers vmolnaro
2025-01-13 15:24 ` [PATCH 00/10] Introduce structure for shell tests Arnaldo Carvalho de Melo
2025-01-13 18:25 ` [PATCH v2 " vmolnaro
2025-07-21 13:26 ` [PATCH v3 0/7] " Jakub Brnak
2025-07-21 13:26 ` [PATCH v3 1/7] perf test perftool_testsuite: Use absolute paths Jakub Brnak
2025-07-26 6:00 ` Namhyung Kim
2025-08-21 11:01 ` Jakub Brnak
2025-07-21 13:26 ` [PATCH v3 2/7] perf tests: Create a structure for shell tests Jakub Brnak
2025-07-21 19:39 ` Ian Rogers
2025-07-26 6:03 ` Namhyung Kim
2025-08-21 11:15 ` Jakub Brnak
2025-07-21 13:26 ` [PATCH v3 3/7] perf test: Provide setup for the shell test suite Jakub Brnak
2025-07-26 6:07 ` Namhyung Kim
2025-08-04 14:39 ` Michael Petlan
2025-07-21 13:26 ` [PATCH v3 4/7] perftool-testsuite: Add empty setup for base_probe Jakub Brnak
2025-07-21 13:26 ` [PATCH v3 5/7] perf test: Introduce storing logs for shell tests Jakub Brnak
2025-07-21 19:43 ` Ian Rogers
2025-07-26 6:17 ` Namhyung Kim
2025-07-21 13:26 ` [PATCH v3 6/7] perf test: Format log directories " Jakub Brnak
2025-07-26 6:21 ` Namhyung Kim [this message]
2025-07-21 13:26 ` [PATCH v3 7/7] perf test: Remove perftool drivers Jakub Brnak
2025-07-21 19:46 ` Ian Rogers
2025-07-31 12:54 ` [PATCH v3 0/7] Introduce structure for shell tests tejas05
2025-01-13 18:25 ` [PATCH v2 01/10] perf test perftool_testsuite: Add missing description vmolnaro
2025-01-13 18:25 ` [PATCH v2 02/10] perf test perftool_testsuite: Return correct value for skipping vmolnaro
2025-01-13 18:25 ` [PATCH v2 03/10] perf test perftool_testsuite: Use absolute paths vmolnaro
2025-01-13 18:25 ` [PATCH v2 04/10] perf tests: Create a structure for shell tests vmolnaro
2025-01-13 18:26 ` [PATCH v2 05/10] perf testsuite: Fix perf-report tests installation vmolnaro
2025-01-13 18:26 ` [PATCH v2 06/10] perf test: Provide setup for the shell test suite vmolnaro
2025-01-13 18:26 ` [PATCH v2 07/10] perftool-testsuite: Add empty setup for base_probe vmolnaro
2025-01-13 18:26 ` [PATCH v2 08/10] perf test: Introduce storing logs for shell tests vmolnaro
2025-01-13 18:26 ` [PATCH v2 09/10] perf test: Format log directories " vmolnaro
2025-01-13 18:26 ` [PATCH v2 10/10] perf test: Remove perftool drivers vmolnaro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aIR0AH_-y-jurGZq@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=irogers@google.com \
--cc=jbrnak@redhat.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=mpetlan@redhat.com \
--cc=vmolnaro@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.