From: "Salvatore CRO'" <salvatore.cro@st.com>
To: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] syscalls: fix creat07 setup and argv to execve
Date: Wed, 25 Jan 2012 13:27:18 +0100 [thread overview]
Message-ID: <4F1FF526.7030701@st.com> (raw)
In-Reply-To: <4F1FEEEF.2080506@st.com>
On 1/25/2012 1:00 PM, Carmelo AMOROSO wrote:
> On 25/01/2012 9.55, Salvatore CRO' wrote:
>> Fix test_path variable logic in setup function.
>> Also use a new argv variable to be passed to execve.
>>
>> Signed-off-by: Salvatore Cro<salvatore.cro@st.com>
>> ---
>> testcases/kernel/syscalls/creat/creat07.c | 12 ++++++------
>> 1 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/creat/creat07.c b/testcases/kernel/syscalls/creat/creat07.c
>> index 4ed2c22..43a6030 100644
>> --- a/testcases/kernel/syscalls/creat/creat07.c
>> +++ b/testcases/kernel/syscalls/creat/creat07.c
>> @@ -90,9 +90,8 @@ int main(int ac, char **av)
>> tst_brkm(TBROK|TERRNO, cleanup, "fork #1 failed");
>>
>> if (pid == 0) {
>> - char *av[1];
>> - av[0] = basename(test_app);
>> - (void)execve(test_app, av, NULL);
>> + char *argv[] = { test_app, NULL };
>> + (void)execve(test_app, argv, NULL);
>> perror("execve failed");
>> exit(1);
>> }
>> @@ -138,14 +137,15 @@ void setup(char *app)
>> char *cmd, *pwd = NULL;
>> char test_path[MAXPATHLEN];
>>
>> - if (test_app[0] == '/')
>> - strncpy(test_path, test_app, sizeof(test_app));
>> + if (app[0] == '/')
>> + snprintf(test_path, sizeof(test_path), "%s/%s",
>> + dirname(app), test_app);
>> else {
>> if ((pwd = get_current_dir_name()) == NULL)
>> tst_brkm(TBROK|TERRNO, NULL, "getcwd failed");
>>
>> snprintf(test_path, sizeof(test_path), "%s/%s",
>> - pwd, basename(test_app));
>> + pwd, test_app);
>>
>> free(pwd);
>> }
> Hi Salvo,
> could you clarify why this change is needed ?
test_app is defined as follows :
#define test_app "test1"
so
if (test_app[0] == '/')
was a typo and segfaulting in uClibc.
The test (app) could have been invoked either from 1) <test path> or 2)
from another path :
- 1) test_path for test_app is pwd/test_app (not pwd/basename(test_path))
- 2) test_path is dirname(app)/test_app (not test_app)
Furthermore change related to argv variable is mostly a tidy-up plus
again drop of
basename(test_app).
Hope it's clear enough ;-)
> cheers
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2012-01-25 12:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-25 8:55 [LTP] [PATCH] syscalls: fix creat07 setup and argv to execve Salvatore CRO'
2012-01-25 12:00 ` Carmelo AMOROSO
2012-01-25 12:27 ` Salvatore CRO' [this message]
2012-01-30 15:45 ` Carmelo AMOROSO
2012-02-01 11:56 ` Salvatore CRO'
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=4F1FF526.7030701@st.com \
--to=salvatore.cro@st.com \
--cc=ltp-list@lists.sourceforge.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox