From: CAI Qian <[email protected]>
Subject: Re: [LTP] fork05 test case fails due to optimization
Date: Sat, 11 Apr 2009 04:02:41 -0700 (PDT)

> 
> 
> 
> --- On Tue, 4/7/09, rohit verma <[email protected]> wrote:
> 
>> From: rohit verma <[email protected]>
>> Subject: [LTP] fork05 test case fails due to optimization
>> To: [email protected]
>> Date: Tuesday, April 7, 2009, 5:57 PM
>> There is a change in compilation
>> mechanism in LTP from Feb 09
>> distribution.The previous Make mechanism did not provide
>> any
>> optimization while compiling the fork05 test program and
>> the test used
>> to Pass . However the newer Makefile uses optimization
>> level 2 while
>> compiling, if this file is executed the test case fails ..
>> 
> 
> This is definitely a case. I can reproduce it on Fedora 10, so I have
> created a bug of it, and copied the author Ulrich Drepper,
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=495296
>

Ulrich Drepper has pointed out in the above bug report that this failure
was due to incorrect test code.

  The test code isn't correct.  The compiler cannot look inside the asm
  statements in main() and see that they are really necessary.  Based on
  the information given the compiler can drop some of them.

  Change all asms in main from

    asm(...)

  to

    asm volatile(...)

  and the code works fine.

With the following patch, it works fine with and without compilation
optimization.

Signed-off-by: CAI Qian <[email protected]>

--- ltp/testcases/kernel/syscalls/fork/fork05.c.orig    2009-04-12 
13:24:48.000000000 +0800
+++ ltp/testcases/kernel/syscalls/fork/fork05.c 2009-04-12 13:26:28.000000000 
+0800
@@ -178,23 +178,23 @@
 
   modify_ldt (1, &ldt0, sizeof (ldt0));
 
-  asm ("movw %w0, %%fs" : : "q" (7));
+  asm volatile ("movw %w0, %%fs" : : "q" (7));
 
-  asm ("movl %%fs:0, %0" : "=r" (lo));
+  asm volatile ("movl %%fs:0, %0" : "=r" (lo));
   tst_resm(TINFO,"a = %d", lo);
 
-  asm ("pushl %%fs; popl %0" : "=q" (lo));
+  asm volatile ("pushl %%fs; popl %0" : "=q" (lo));
   tst_resm(TINFO,"%%fs = %#06hx", lo);
 
-  asm ("movl %0, %%fs:0" : : "r" (99));
+  asm volatile ("movl %0, %%fs:0" : : "r" (99));
 
   pid = fork ();
 
   if (pid == 0) {
-      asm ("pushl %%fs; popl %0" : "=q" (lo));
+      asm volatile ("pushl %%fs; popl %0" : "=q" (lo));
       tst_resm(TINFO,"%%fs = %#06hx", lo);
 
-      asm ("movl %%fs:0, %0" : "=r" (lo));
+      asm volatile ("movl %%fs:0, %0" : "=r" (lo));
       tst_resm(TINFO,"a = %d", lo);
 
       if (lo != 99)

 
> CAI Qian
> 
>> With Older Make mechanism
>> cc -Wall  -I../../include -g -Wall
>> -I../../../../include -Wall
>> fork05.c  -L../../../../lib -lltp -o fork05
>> 
>> With Newer Make mechanism
>> gcc -g -O2 -I../../include -g -Wall -I../../../../include
>> -Wall
>> fork05.c  -L../../../../lib -lltp -o fork05
>> 
>> Note: If we compile the program in the same
>> directory(/testcases/kernel/syscalls/fork) ,the
>> optimization flag do
>> not come into picture and the test case passes. The
>> optimization is
>> set by some top level Makefile
>> 
>> Regards,
>> Rohit
>> 
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by:
>> High Quality Requirements in a Collaborative Environment.
>> Download a free trial of Rational Requirements Composer
>> Now!
>> http://p.sf.net/sfu/www-ibm-com
>> _______________________________________________
>> Ltp-list mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/ltp-list
>> 
> 
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> High Quality Requirements in a Collaborative Environment.
> Download a free trial of Rational Requirements Composer Now!
> http://p.sf.net/sfu/www-ibm-com
> _______________________________________________
> Ltp-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to