From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 4/6] lib: extend PATH as part of test setup
Date: Tue, 10 Oct 2017 17:18:52 +0200 [thread overview]
Message-ID: <20171010151852.GA12028@rei> (raw)
In-Reply-To: <fe40d9a0263afff913c646a6bc1fad88e0ce9747.1507647255.git.jstancek@redhat.com>
Hi!
> +static void add_paths(void)
> +{
> + char *old_path = getenv("PATH");
> + const char *start_dir;
> + char *new_path;
> + int new_path_size;
> +
> + start_dir = tst_get_startwd();
> +
> + /* ".:" + "$start_dir" + '\0' */
> + new_path_size = 2 + strlen(start_dir) + 1;
> + if (old_path)
> + /* ":" + "$old_path" */
> + new_path_size += 1 + strlen(old_path);
> +
> + new_path = SAFE_MALLOC(new_path_size);
> + strcpy(new_path, ".:");
> + strcat(new_path, start_dir);
> +
> + if (old_path) {
> + strcat(new_path, ":");
> + strcat(new_path, old_path);
> + }
I do not like the strcat() function much, I would have probably handled
these with asprintf();
if (old_path)
SAFE_ASPRINTF(&new_path, "%s::%s", old_path, start_dir);
else
SAFE_ASPRINTF(&new_path, "::%s", start_dir);
The rest of the patchset looks good.
BTW, we should also drop the note about setting $PATH from the
documentation once this is merged.
> + SAFE_SETENV("PATH", new_path, 1);
> + free(new_path);
> +}
> +
> static void testrun(void)
> {
> unsigned int i = 0;
> unsigned long long stop_time = 0;
> int cont = 1;
>
> + add_paths();
> do_test_setup();
>
> if (duration > 0)
> --
> 1.8.3.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2017-10-10 15:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 15:05 [LTP] [PATCH 1/6] lib: add LTP_IPC_PATH to env. variables by default Jan Stancek
2017-10-10 15:05 ` [LTP] [PATCH 2/6] lib: move tst_get_startwd() to old_tmpdir header Jan Stancek
2017-10-10 15:05 ` [LTP] [PATCH 3/6] safe_macros: add SAFE_SETENV() Jan Stancek
2017-10-10 15:05 ` [LTP] [PATCH 4/6] lib: extend PATH as part of test setup Jan Stancek
2017-10-10 15:18 ` Cyril Hrubis [this message]
2017-10-11 7:45 ` Jan Stancek
2017-10-11 8:00 ` Cyril Hrubis
2017-10-10 15:05 ` [LTP] [PATCH 5/6] creat07: no need to pass tst_ipc_envp anymore Jan Stancek
2017-10-12 8:08 ` Cyril Hrubis
2017-10-12 8:47 ` Li Wang
2017-10-12 8:50 ` Jan Stancek
2017-10-12 9:34 ` Jan Stancek
2017-10-10 15:05 ` [LTP] [PATCH 6/6] lib: drop tst_ipc_envp Jan Stancek
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=20171010151852.GA12028@rei \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/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.