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<[email protected]>
> ---
>   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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to