openposix/.../timer_create/{10,11}-1.c: Fix for -O2

Add volatile to the signal_caught variable,
otherwise it's optimized out when tests are
compiled with -O2 and they never return
from main.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
lib: Add functions to ease pseudo fs read/write

This adds SAFE_FILE_SCANF() and SAFE_FILE_PRINTF()
safe functions that operate like scanf and printf
but works with a path instead of the FILE pointer.

The file is opened and closed automatically and
all possible error conditions are handled. With
this we can reduce the number of fopen, fscanf, fclose
sequencies (with possibly incomplete error handling).

This also adds SAFE_CP() which is intended replacement
for system("cp ...") code.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
syscalls/fork13: Make use of SAFE_FILE_* interface.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
syscalls/getsid02: Cleanup && use SAFE_FILE_*

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
numa01: fix the wrong method of getting numa nodes number

Fix the method of getting the number of numa nodes.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
syscalls/wait402: Cleanup && use SAFE_FILE_*

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
syscalls/wait402: Cleanup.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
syscalls/madvise03: Cleanup && use SAFE_FILE_*

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Merge ../ltp-dev
clone: increase stack size to 1M

16k is not enough for some LTP signal handlers:
http://article.gmane.org/gmane.linux.ltp/16992
1M should be plenty for all architectures.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
clone: wait until child completes

If parent doesn't wait for child to finish,
ltp-pan detects these as 'orpahns' and will try
to kill them, which can result in TBROK messages:
http://article.gmane.org/gmane.linux.ltp/16993

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
clone: code cleanup

cleanup the code style.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
numa01.sh: get the right numa node number

Signed-off-by: Peng Haitao <penght@cn.fujitsu.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
open_posix_testsuite/.../sigset/{6, 7}-1.c: fix error handling

int may not be large enough to hold return value from sigset():
  typedef void (*sighandler_t)(int);
  sighandler_t sigset(int sig, sighandler_t disp);

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Reviewed-by: Garrett Cooper <yanegomi@gmail.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
aio_read/7-1.c: fix race at exit

This testcase crashed in about 1/200 of runs on s390x system with 2 CPUs:

Core was generated by `./7-1.run-test'.
Program terminated with signal 11, Segmentation fault.
  #0  _dl_fini () at dl-fini.c:228
  228               if (l->l_init_called)
  (gdb) bt
  #0  _dl_fini () at dl-fini.c:228
  #1  0x000003fffd345c62 in __run_exit_handlers (status=<optimized out>, listp=0x3fffd4b4a78 <__exit_funcs>,
      run_list_atexit=run_list_atexit@entry=true) at exit.c:77
  #2  0x000003fffd345ca4 in __GI_exit (status=<optimized out>) at exit.c:99
  #3  0x000003fffd3294e6 in __libc_start_main (main=0x80000b18 <main>, argc=<optimized out>, ubp_av=0x3ffff970108,
      init=<optimized out>, fini=0x80000d4c <__libc_csu_fini>, rtld_fini=0x3fffd50821c <_dl_fini>, stack_end=0x3ffff970050)
      at libc-start.c:257
  #4  0x0000000080000a26 in _start ()
  (gdb) x/1x l
  0x9fd4f2918:    Cannot access memory at address 0x9fd4f2918

The crash was presumably caused by race, where variable defined in main()
got out of scope before operation started by aio_read() completed.

Patched version succesfully made 100000 iterations.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
aio_cancel: code cleanup

Cleanup the code indent.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
aio_error: code cleanup

Cleanup the code indent.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
aio_fsync: code cleanup

Cleanup the code indent.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
aio_read: code cleanup

Cleanup the code indent.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
aio_return: code cleanup

Cleanup the code indent.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>