Patch by Vasilis Kaoutsis:

* Added sigignore() tests.
* Renamed names of the test executables to avoid clashes in the build system.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22792 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2007-11-01 18:12:55 +00:00
parent 2d01adeaf4
commit 07ebcc2d2b
11 changed files with 239 additions and 10 deletions
@@ -7,5 +7,6 @@ SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance i
SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_key_delete ;
SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_getspecific ;
SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_setspecific ;
SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigignore ;
SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigprocmask ;
SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigsuspend ;
@@ -2,5 +2,5 @@ SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance inter
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ;
SimpleTest 1-1.test : 1-1.c ;
SimpleTest difftime_1-1 : 1-1.c ;
@@ -2,5 +2,4 @@ SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance inter
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ;
SimpleTest 2-1.test : 2-1.c ;
SimpleTest kill_2-1 : 2-1.c ;
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: salwan.searty REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
Steps:
1. Set up a handler for signal SIGABRT, such that it is called if
signal is ever raised.
2. Call sigignore on SIGABRT.
3. Raise a SIGABRT and verify that the signal handler was not called.
*/
#define _XOPEN_SOURCE 600
#include <signal.h>
#include <stdio.h>
#include "posixtest.h"
int handler_called = 0;
void handler(int signo)
{
handler_called = 1;
}
int main()
{
struct sigaction act;
act.sa_handler = handler;
act.sa_flags = 0;
sigemptyset(&act.sa_mask);
if (sigaction(SIGABRT, &act, 0) == -1) {
perror("Unexpected error while attempting to setup test "
"pre-conditions");
return PTS_UNRESOLVED;
}
sigignore(SIGABRT);
if (raise(SIGABRT) == -1) {
perror("Unexpected error while attempting to setup test "
"pre-conditions");
return PTS_UNRESOLVED;
}
if (handler_called) {
printf("FAIL: Signal was not ignored\n");
return PTS_FAIL;
}
printf("PASS\n");
return PTS_PASS;
}
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: salwan.searty REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
Simply, if sigignore returns a 0 here, test passes.
*/
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <signal.h>
#include "posixtest.h"
int main()
{
if (sigignore(SIGABRT) != 0) {
perror("sigignore failed -- returned -- test aborted");
return PTS_UNRESOLVED;
}
printf("sigignore passed\n");
return PTS_PASS;
}
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: salwan.searty REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
Testing passing an invalid signals to sighold().
After sighold is called on an invalid signal, sigignore() should
return -1 and set errno to EINVAL
The invalid signal passed to sigignore() depends on the argument
passed to this program. There are currently 4 invalid signals.
*/
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <stdint.h>
#include "posixtest.h"
int main(int argc, char *argv[])
{
int signo;
if (argc < 2) {
printf("Usage: %s [1|2|3|4]\n", argv[0]);
return PTS_UNRESOLVED;
}
/*
Various error conditions
*/
switch (argv[1][0]) {
case '1':
signo=-1;
break;
case '2':
signo=-10000;
break;
case '3':
signo=INT32_MIN+1;
break;
case '4':
signo=INT32_MIN;
break;
default:
printf("Usage: %s [1|2|3|4]\n", argv[0]);
return PTS_UNRESOLVED;
}
if (sigignore(signo) == -1) {
if (EINVAL == errno) {
printf ("errno set to EINVAL\n");
return PTS_PASS;
} else {
printf ("errno not set to EINVAL\n");
return PTS_FAIL;
}
}
printf("sighold did not return -1\n");
return PTS_FAIL;
}
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: salwan.searty REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
Testing trying to ignore a signal that cannot be ignored.
Line 1264 in Issue 6 of the Posix System Interfaces document says that
the system shall not allow the signals SIGKILL or SIGSTOP
to be ignored.
*/
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <stdint.h>
#include "posixtest.h"
int main()
{
if (sigignore(SIGKILL) == -1) {
if (EINVAL == errno) {
printf ("errno set to EINVAL\n");
return PTS_PASS;
} else {
printf ("errno not set to EINVAL\n");
return PTS_FAIL;
}
}
printf("sigignore did not return -1\n");
return PTS_FAIL;
}
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: salwan.searty REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
Testing trying to ignore a signal that cannot be ignored.
Line 1264 in Issue 6 of the Posix System Interfaces document says that
the system shall not allow the signals SIGKILL or SIGSTOP
to be ignored.
*/
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <stdint.h>
#include "posixtest.h"
int main()
{
if (sigignore(SIGSTOP) == -1) {
if (EINVAL == errno) {
printf ("errno set to EINVAL\n");
return PTS_PASS;
} else {
printf ("errno not set to EINVAL\n");
return PTS_FAIL;
}
}
printf("sigignore did not return -1\n");
return PTS_FAIL;
}
@@ -0,0 +1,9 @@
SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigignore ;
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ;
SimpleTest sigignore_1-1 : 1-1.c ;
SimpleTest sigignore_4-1 : 4-1.c ;
SimpleTest sigignore_5-core-buildonly : 5-core-buildonly.c ;
SimpleTest sigignore_6-1 : 6-1.c ;
SimpleTest sigignore_6-2 : 6-2.c ;
@@ -2,8 +2,7 @@ SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance inter
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ;
SimpleTest 8-1.test : 8-1.c ;
SimpleTest 8-2.test : 8-2.c ;
SimpleTest 8-3.test : 8-3.c ;
SimpleTest 12-1.test : 12-1.c ;
SimpleTest sigprocmask_8-1 : 8-1.c ;
SimpleTest sigprocmask_8-2 : 8-2.c ;
SimpleTest sigprocmask_8-3 : 8-3.c ;
SimpleTest sigprocmask_12-1 : 12-1.c ;
@@ -2,5 +2,4 @@ SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance inter
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) include ] ;
SimpleTest 6-1.test : 6-1.c ;
SimpleTest sigsuspend_6-1 : 6-1.c ;