TestCases

From Linux PARISC Wiki
(Difference between revisions)
Jump to: navigation, search
(Kernel Testcases)
m (formatting update)
 
Line 24: Line 24:
 
== Threads and fork on VIPT-WB machines ==
 
== Threads and fork on VIPT-WB machines ==
  
* Affects [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=561203|#561203]].
+
* Affects [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=561203 #561203].
* Discussed on [[http://thread.gmane.org/gmane.linux.ports.parisc/2503|this thread]] and [[http://thread.gmane.org/gmane.linux.ports.parisc/2751|this thread]]
+
* Discussed on [http://thread.gmane.org/gmane.linux.ports.parisc/2503 this thread] and [http://thread.gmane.org/gmane.linux.ports.parisc/2751 this thread]
  
Summary from [[http://article.gmane.org/gmane.linux.ports.parisc/2823|JDA]]:
+
Summary from [http://article.gmane.org/gmane.linux.ports.parisc/2823 JDA]:
  
 
''The minifail bug is a "Threads and fork" problem
 
''The minifail bug is a "Threads and fork" problem
Line 35: Line 35:
 
is caused by the same problem.''
 
is caused by the same problem.''
  
Initial patch [[http://marc.info/?l=linux-parisc&m=126202676424518&q=p3|syscall.S.d.1]] from [[http://article.gmane.org/gmane.linux.ports.parisc/2524|JDA]]
+
Initial patch [http://marc.info/?l=linux-parisc&m=126202676424518&q=p3 syscall.S.d.1] from [http://article.gmane.org/gmane.linux.ports.parisc/2524 JDA]
  
First testcase [[http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=25;filename=minifail.cpp;att=1;bug=561203|minifail.cpp]]
+
First testcase [http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=25;filename=minifail.cpp;att=1;bug=561203 minifail.cpp]
  
 
Build with:
 
Build with:
* g++ -I/usr/include/qt4 -lQtCore minifail.cpp -o minifail -O0 -g
+
<code>g++ -I/usr/include/qt4 -lQtCore minifail.cpp -o minifail -O0 -g</code>
  
 
Fails occasionally with:
 
Fails occasionally with:
Line 60: Line 60:
 
  </nowiki>
 
  </nowiki>
  
* Reduced [[http://marc.info/?l=linux-parisc&m=126503924510791&q=p4|minifail6.cpp]], from [[http://article.gmane.org/gmane.linux.ports.parisc/2606|this post]]:
+
* Reduced [http://marc.info/?l=linux-parisc&m=126503924510791&q=p4 minifail6.cpp], from [http://article.gmane.org/gmane.linux.ports.parisc/2606 this post]
* Tentative [[http://marc.info/?l=linux-parisc&m=126514540817084&q=p3|patch]], see this [[http://article.gmane.org/gmane.linux.ports.parisc/2615|post]]
+
* Tentative [http://marc.info/?l=linux-parisc&m=126514540817084&q=p3 patch]], see this [http://article.gmane.org/gmane.linux.ports.parisc/2615 post]
* Other version [[http://marc.info/?l=linux-parisc&m=126523464015510&q=p3|minifail3.c]] from [[http://article.gmane.org/gmane.linux.ports.parisc/2618|Helge Deller]]
+
* Other version [http://marc.info/?l=linux-parisc&m=126523464015510&q=p3 minifail3.c] from [http://article.gmane.org/gmane.linux.ports.parisc/2618 Helge Deller]
* Other version [[http://marc.info/?l=linux-parisc&m=126835038716389&q=p3|minifail9.cpp]] from [[http://article.gmane.org/gmane.linux.ports.parisc/2685|JDA]]
+
* Other version [http://marc.info/?l=linux-parisc&m=126835038716389&q=p3|minifail9.cpp] from [http://article.gmane.org/gmane.linux.ports.parisc/2685 JDA]
* Other version [[http://marc.info/?l=linux-parisc&m=126919558329853&q=p3|minifail12.cpp]] from [[http://article.gmane.org/gmane.linux.ports.parisc/2693|JDA]]
+
* Other version [http://marc.info/?l=linux-parisc&m=126919558329853&q=p3 minifail12.cpp] from [http://article.gmane.org/gmane.linux.ports.parisc/2693 JDA]
* '''Final''' (?) version [[http://marc.info/?l=linux-parisc&m=127275273129566&q=p3|minifail_dave.cpp]] from [[http://article.gmane.org/gmane.linux.ports.parisc/2824|Helge Deller]]
+
* '''Final''' (?) version [http://marc.info/?l=linux-parisc&m=127275273129566&q=p3 minifail_dave.cpp] from [http://article.gmane.org/gmane.linux.ports.parisc/2824 Helge Deller]
  
 
----
 
----
  
Other testcase from [[http://article.gmane.org/gmane.linux.ports.parisc/2774|JDA]]:
+
Other testcase from [http://article.gmane.org/gmane.linux.ports.parisc/2774 JDA]:
  
Compile with `-static` to link with libc.a. Testcase prints incorrect parent pid.:
+
Compile with <code>-static</code> to link with libc.a. Testcase prints incorrect parent pid.:
  
 
  <nowiki>
 
  <nowiki>
Line 114: Line 114:
 
=== Patches ===
 
=== Patches ===
  
* [[https://patchwork.kernel.org/patch/76829/|parisc_lock_v2.patch]] from Helge Deller - Not Applicable (not-upstream)
+
* [https://patchwork.kernel.org/patch/76829/ parisc_lock_v2.patch] from Helge Deller - Not Applicable (not-upstream)
* [[https://patchwork.kernel.org/patch/85865/|entry.S.patch]] from JDA (not-upstream)
+
* [https://patchwork.kernel.org/patch/85865/ entry.S.patch] from JDA (not-upstream)
* [[https://patchwork.kernel.org/patch/90467/|patch1]] from JDA - Superseded by patch2 (not-upstream)
+
* [https://patchwork.kernel.org/patch/90467/ patch1] from JDA - Superseded by patch2 (not-upstream)
* [[https://patchwork.kernel.org/patch/90596/|patch2]] from JDA - Included in patch3 (not-upstream)
+
* [https://patchwork.kernel.org/patch/90596/ patch2] from JDA - Included in patch3 (not-upstream)
* [[https://patchwork.kernel.org/patch/91525/|bundle patch3]] from JDA - Partially split into
+
* [https://patchwork.kernel.org/patch/91525/ bundle patch3] from JDA - Partially split into
** [[https://patchwork.kernel.org/patch/91916/|Call pagefault_disable/pagefault_enable in kmap_atomic/kunmap_atomic]] (on-buildds)
+
** [https://patchwork.kernel.org/patch/91916/ Call pagefault_disable/pagefault_enable in kmap_atomic/kunmap_atomic] (on-buildds)
** [[https://patchwork.kernel.org/patch/91918/|Remove unnecessary macros from entry.S]] (on-buildds)
+
** [https://patchwork.kernel.org/patch/91918/ Remove unnecessary macros from entry.S] (on-buildds)
** [[https://patchwork.kernel.org/patch/91919/|Delete unnecessary nop's in entry.S]] (on-buildds)
+
** [https://patchwork.kernel.org/patch/91919/ Delete unnecessary nop's in entry.S] (on-buildds)
** [[https://patchwork.kernel.org/patch/91922/|Avoid interruption in critical region in entry.S]] (on-buildds)
+
** [https://patchwork.kernel.org/patch/91922/ Avoid interruption in critical region in entry.S] (on-buildds)
** [[https://patchwork.kernel.org/patch/91924/|LWS fixes for syscall.S]] (on-buildds)
+
** [https://patchwork.kernel.org/patch/91924/ LWS fixes for syscall.S] (on-buildds)
 
** '''Note:''' some bits from patch3 have not be separately submitted (futex.h, etc) - Needs review
 
** '''Note:''' some bits from patch3 have not be separately submitted (futex.h, etc) - Needs review
* [[https://patchwork.kernel.org/patch/91933/|pgtable.h patch update]], initially found in patch3 from JDA (not-upstream)
+
* [https://patchwork.kernel.org/patch/91933/ pgtable.h patch update], initially found in patch3 from JDA (not-upstream)
* [[https://patchwork.kernel.org/patch/93520/|bundle patch4]] aka `pte.2.d` from JDA, updating parts of patch3 (not-upstream)
+
* [https://patchwork.kernel.org/patch/93520/ bundle patch4] aka <tt>pte.2.d</tt> from JDA, updating parts of patch3 (not-upstream)
* [[https://patchwork.kernel.org/patch/95969/|patch]] from James Bottomley for kmap issues fixing '''minifail6.cpp''' (not-upstream)
+
* [https://patchwork.kernel.org/patch/95969/ patch]] from James Bottomley for kmap issues fixing '''minifail6.cpp''' (not-upstream)
* [[https://patchwork.kernel.org/patch/97971/|bundle patch5]] from JDA with a slightly modified version of James' patch (not-upstream)
+
* [https://patchwork.kernel.org/patch/97971/ bundle patch5] from JDA with a slightly modified version of James' patch (not-upstream)
* [[https://patchwork.kernel.org/patch/99861/|bundle patch6]] from JDA, with apparently good results both on pa8800 and previous CPUs (not-upstream)
+
* [https://patchwork.kernel.org/patch/99861/ bundle patch6] from JDA, with apparently good results both on pa8800 and previous CPUs (not-upstream)
* [[https://patchwork.kernel.org/patch/101741/|bundle patch7]] from JDA, with reworked pacache.s and cache.c (not-upstream)
+
* [https://patchwork.kernel.org/patch/101741/ bundle patch7] from JDA, with reworked pacache.s and cache.c (not-upstream)
  
 
== vfork/execve ==
 
== vfork/execve ==
  
* Affects [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=558905|#558905]]
+
* Affects [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=558905 #558905]
* Discussed by Carlos O'Donell in [[http://thread.gmane.org/gmane.linux.ports.parisc/2403|this thread]]:
+
* Discussed by Carlos O'Donell in [http://thread.gmane.org/gmane.linux.ports.parisc/2403 this thread]:
  
 
''I have constructed a vfork test case which shows some of the problems
 
''I have constructed a vfork test case which shows some of the problems
Line 177: Line 177:
  
 
Compile this test case twice:
 
Compile this test case twice:
# gcc -O1 -g -o vfork-O1 vfork.c
+
# <code>gcc -O1 -g -o vfork-O1 vfork.c</code>
# gcc -O0 -g -o vfork-O0 vfork.c
+
# <code>gcc -O0 -g -o vfork-O0 vfork.c</code>
  
  
Line 185: Line 185:
  
 
To remove the C library from the loop I attach a complete vfork
 
To remove the C library from the loop I attach a complete vfork
implementation as used by glibc. [[http://marc.info/?l=linux-parisc&m=126013436326095&q=p3|pt-vfork.s]]
+
implementation as used by glibc. [http://marc.info/?l=linux-parisc&m=126013436326095&q=p3 pt-vfork.s]
  
You can compile the test case using: `cc -O1 -g -o vfork-O1 vfork.c pt-vfork.s`
+
You can compile the test case using: <code>cc -O1 -g -o vfork-O1 vfork.c pt-vfork.s</code>
  
 
In summary:
 
In summary:
Line 194: Line 194:
 
* Test case works on hppa under strace.
 
* Test case works on hppa under strace.
  
More discussion by Carlos O'Donell in [[http://thread.gmane.org/gmane.linux.ports.parisc/2725|this thread]]
+
More discussion by Carlos O'Donell in [http://thread.gmane.org/gmane.linux.ports.parisc/2725 this thread]
  
* Other testcase [[http://marc.info/?l=linux-parisc&m=126979720816005&q=p3|vforktest.tgz]] by Carlos O'Donell
+
* Other testcase [http://marc.info/?l=linux-parisc&m=126979720816005&q=p3 vforktest.tgz] by Carlos O'Donell
* Updated (?) testcase [[http://marc.info/?l=linux-parisc&m=126980206121937&q=p3|vforktest.tgz]] by Carlos O'Donell
+
* Updated (?) testcase [http://marc.info/?l=linux-parisc&m=126980206121937&q=p3 vforktest.tgz] by Carlos O'Donell
  
 
=== Patches ===
 
=== Patches ===
  
* [[https://patchwork.kernel.org/patch/90144/|Patch]] from JDA (not-upstream)
+
* [https://patchwork.kernel.org/patch/90144/ Patch] from JDA (not-upstream)
* [[https://patchwork.kernel.org/patch/90018/|Patch]] from Carlos O'Donell - Comments/cleanup (on-buildds)
+
* [https://patchwork.kernel.org/patch/90018/ Patch] from Carlos O'Donell - Comments/cleanup (on-buildds)
  
  
 
== floating point SIGFPE not trapped ==
 
== floating point SIGFPE not trapped ==
  
* Affects [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=559406|#559406]]
+
* Affects [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=559406 #559406]
* Testcase [[http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=33;filename=fputest.c;att=1;bug=559406|fputest.c]]
+
* Testcase [http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=33;filename=fputest.c;att=1;bug=559406 fputest.c]
  
 
=== Patches ===
 
=== Patches ===
  
* [[https://patchwork.kernel.org/patch/96558/|Patch]] from Helge Deller (in-debian, on-buildds)
+
* [https://patchwork.kernel.org/patch/96558/ Patch] from Helge Deller (in-debian, on-buildds)
  
 
= GCC TestCases =
 
= GCC TestCases =
Line 218: Line 218:
 
== MMAP ==
 
== MMAP ==
  
* Affects [[http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40505|PR40505]].
+
* Affects [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40505 PR40505].
* Discussed by Carlos O'Donell on [[http://thread.gmane.org/gmane.linux.debian.devel.release/30830/focus=31039|this thread]].
+
* Discussed by Carlos O'Donell on [http://thread.gmane.org/gmane.linux.debian.devel.release/30830/focus=31039 this thread].
* Testcase [[http://marc.info/?l=linux-parisc&m=124689818116647&q=p3|test-mmap.c]] from Carlos O'Donell
+
* Testcase [http://marc.info/?l=linux-parisc&m=124689818116647&q=p3 test-mmap.c] from Carlos O'Donell
  
  
Line 227: Line 227:
 
== Segmentation fault in __libc_start_main with -static ==
 
== Segmentation fault in __libc_start_main with -static ==
  
Discussed in [[http://thread.gmane.org/gmane.linux.ports.parisc/2585|this thread]]
+
Discussed in [http://thread.gmane.org/gmane.linux.ports.parisc/2585 this thread]
  
Testcase from [[http://marc.info/?l=linux-parisc&m=126477688209053|JDA]]: Compile with `g++ -o xx -static -pthread xx.C`
+
Testcase from [http://marc.info/?l=linux-parisc&m=126477688209053 JDA]: Compile with <code>g++ -o xx -static -pthread xx.C</code>
 
  <nowiki>
 
  <nowiki>
 
// This test only applies to glibc (NPTL) targets.
 
// This test only applies to glibc (NPTL) targets.

Latest revision as of 21:11, 31 May 2014

Contents

[edit] Kernel Testcases

[edit] Math test case

should return 0.0: (hppa floating point error)

#include <stdio.h>
#include <math.h>
int
main (void) {
 double result = exp (-4.3682654441477153e+19);
 printf ("%g\n", result);
 if (result != 0.0)
  return 1;
 return 0;
}


[edit] Futex wait failure

No testcase.

[edit] Threads and fork on VIPT-WB machines

Summary from JDA:

The minifail bug is a "Threads and fork" problem arising from cache corruption. Mainly, copy_user_page is broken when copying memory shared by more than one process. There are also issues in PTE/TLB management on SMP systems. Probably, the vfork/execve bug is caused by the same problem.

Initial patch syscall.S.d.1 from JDA

First testcase minifail.cpp

Build with:

g++ -I/usr/include/qt4 -lQtCore minifail.cpp -o minifail -O0 -g

Fails occasionally with:

$ i=0; while true; do i=$(($i+1)); echo Run $i; ./minifail; done;
$ i=0; while true; do i=$(($i+1)); echo Run $i; ./minifail qt; done;
 

Typical observed failure:

Run 21
Segmentation fault
Run 22
Child OK.
Thread OK.
Run 23
Thread OK.
Segmentation fault
 

Other testcase from JDA:

Compile with -static to link with libc.a. Testcase prints incorrect parent pid.:

#!cplusplus
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>

#define CALL_EXIT 0

int main (void)
{
  pid_t child;
  pid_t parent;
  char *cmd[] = { "bash", "-c", "echo In child $$;", (char *)0 };
  char *env[] = { "HOME=/tmp", (char *)0 };
  int ret;

  child = vfork();

  if (child == 0)
    {
      ret = execve("/bin/bash", cmd, env);
      // printf ("ret = %d\n", ret);
      _exit(1);
    }
  else
    {
      // printf("child != 0\n");
    }

  parent = getpid();
  printf("parent is %d\n", (unsigned int)parent);
  printf("child is %d\n", (unsigned int)child);

  return 0;
}
 

[edit] Patches

[edit] vfork/execve

I have constructed a vfork test case which shows some of the problems I have using vfork reliably. This fails every time on my PA8700 system running 2.6.32-rc6. It appears as though r28 (ret0) in the parent is being corrupted.

The intent of the testcase is to do the following:

  1. vfork
  2. Launch "ls -l" in the vfork'd child.
  3. Print some information in the parent.
/* vfork.c */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main (void)
{
  pid_t child;
  char *cmd[] = { "ls", "-l", (char *)0 };
  char *env[] = { "HOME=/tmp", (char *)0 };

  child = vfork();

  if (child == 0)
    {
      execve("/bin/ls", cmd, env);
    }
  else
    {
      printf("child != 0\n");
    }

  printf("child is 0x%x\n", (unsigned int)child);

  return 0;
}
 

Compile this test case twice:

  1. gcc -O1 -g -o vfork-O1 vfork.c
  2. gcc -O0 -g -o vfork-O0 vfork.c


The return from vfork is corrupted in the parent. This gets worse at -O0.

To remove the C library from the loop I attach a complete vfork implementation as used by glibc. pt-vfork.s

You can compile the test case using: cc -O1 -g -o vfork-O1 vfork.c pt-vfork.s

In summary:

  • Test case works on x86.
  • Test case fails on hppa.
  • Test case works on hppa under strace.

More discussion by Carlos O'Donell in this thread

[edit] Patches

  • Patch from JDA (not-upstream)
  • Patch from Carlos O'Donell - Comments/cleanup (on-buildds)


[edit] floating point SIGFPE not trapped

[edit] Patches

  • Patch from Helge Deller (in-debian, on-buildds)

[edit] GCC TestCases

[edit] MMAP


[edit] GLIBC TestCases

[edit] Segmentation fault in __libc_start_main with -static

Discussed in this thread

Testcase from JDA: Compile with g++ -o xx -static -pthread xx.C

// This test only applies to glibc (NPTL) targets.
// { dg-do run { target *-*-linux* } }
// { dg-options "-pthread" }

#include <pthread.h>
#include <cxxabi.h>
extern "C" int printf (const char *, ...);

int main()
{
  try
    {
      pthread_exit (0);
    }
  catch (abi::__forced_unwind &)
    {
      printf ("caught forced unwind\n");
      throw;
    }
  catch (...)
    {
      printf ("caught ...\n");
      return 1;
    }
}
 
Personal tools