From: "Salvatore CRO'" <salvatore.cro@st.com>
To: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] clone06: fix error of TERM environment variable is not available
Date: Tue, 14 Feb 2012 08:54:42 +0100 [thread overview]
Message-ID: <4F3A1342.5030109@st.com> (raw)
In-Reply-To: <4F39D61D.80309@cn.fujitsu.com>
On 2/14/2012 4:33 AM, Peng Haitao wrote:
> When TERM environment variable is not available, the case may be fail.
> The patch use the following steps:
> 1. unset a predetermined env variable if it's present.
> 2. set it to a known value
> 3. Make sure that the env variable set in 2. matches both in the child
> and parent.
Humm... I'm not so keen on this solution as it sounds like a .... IMO.
The case when env variable is not defined should be treated the same
way. This
proves once again that both parent and child get the same results.
If your execution ends up with
clone06 0 TWARN : sprintf() failed: errno=???(0): Success
when TERM is not defined, this is because sprintf check is not correct :
if ((sprintf(var, "%s", getenv("TERM") ? : "")) <= 0) {
tst_resm(TWARN|TERRNO, "sprintf() failed");
}
In this case var is evaluated to "" and sprintf will return "0 byte
read" that is quite acceptable.
Child will face an analogue situation so test will pass.
Correct patch should be to change sprintf check to :
if ((sprintf(var, "%s", getenv("TERM") ? : "")) < 0) {
tst_resm(TWARN|TERRNO, "sprintf() failed");
}
I will send it asap...
Ciao,
Salvo.
> Signed-off-by: Peng Haitao<penght@cn.fujitsu.com>
> ---
> testcases/kernel/syscalls/clone/clone06.c | 9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
> index 1734776..5701e4a 100644
> --- a/testcases/kernel/syscalls/clone/clone06.c
> +++ b/testcases/kernel/syscalls/clone/clone06.c
> @@ -165,6 +165,15 @@ int main(int ac, char **av)
> void setup()
> {
>
> + char *term;
> +
> + term = getenv("TERM");
> + if (term)
> + if (unsetenv("TERM") == -1)
> + tst_brkm(TBROK|TERRNO, NULL, "unsetenv failed");
> + if (setenv("TERM", "xterm", 1) == -1)
> + tst_brkm(TBROK|TERRNO, NULL, "setenv failed");
> +
> tst_sig(NOFORK, DEF_HANDLER, cleanup);
>
> TEST_PAUSE;
------------------------------------------------------------------------------
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 parent reply other threads:[~2012-02-14 7:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4F39D61D.80309@cn.fujitsu.com>
2012-02-14 7:54 ` Salvatore CRO' [this message]
[not found] ` <4F3A158D.8070403@st.com>
[not found] ` <4F3A18B8.5060506@cn.fujitsu.com>
[not found] ` <4F3A1AE8.9050905@st.com>
[not found] ` <4F3A1FC1.5040103@cn.fujitsu.com>
2012-02-14 10:03 ` [LTP] Fwd: Re: [PATCH] clone06: fix error of TERM environment variable is not available 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=4F3A1342.5030109@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