TestCases

From Linux PARISC Wiki
Revision as of 21:11, 31 May 2014 by Thibaut Varene (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Kernel Testcases

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;
}


Futex wait failure

No testcase.

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;
}
 

Patches

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

Patches

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


floating point SIGFPE not trapped

Patches

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

GCC TestCases

MMAP


GLIBC TestCases

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