added some tests from posixtestsuite-1.5.1, these ones fail on Haiku

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17488 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2006-05-17 10:19:31 +00:00
parent a2a6a329e8
commit 2cb33db616
10 changed files with 312 additions and 0 deletions

View File

@ -25,3 +25,4 @@ SEARCH on [ FGristFiles
SubInclude HAIKU_TOP src tests system libroot posix bonnie ;
SubInclude HAIKU_TOP src tests system libroot posix math ;
SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite ;

View File

@ -0,0 +1,3 @@
SubDir HAIKU_TOP src tests system libroot posix posixtestsuite ;
SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance ;

View File

@ -0,0 +1,3 @@
SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance ;
SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces ;

View File

@ -0,0 +1,3 @@
SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces ;
SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigprocmask ;

View File

@ -0,0 +1,86 @@
/*
* 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 the signal mask to only having SIGABRT.
2. Call sigprocmask again, this time with a randomly generated value of
how that is checked to make sure it does not equal any of the three defined
values of how which are SIG_SETMASK, SIG_BLOCK, or SIG_UNBLOCK. This should
cause sigprocmask() to return -1. For the second parameter in the sigprocmask()
function, use a set which contains SIGABRT and SIGALRM.
3. Now verify using the is_changed() function that the only signal that is still
in the signal mask is SIGABRT. Neither SIGALRM nor any other signal should be
in the signal mask of the process.
*/
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include "posixtest.h"
#define NUMSIGNALS 25
int is_changed(sigset_t set) {
int i;
int siglist[] = {SIGALRM, SIGBUS, SIGCHLD,
SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT,
SIGPIPE, SIGQUIT, SIGSEGV,
SIGTERM, SIGTSTP, SIGTTIN, SIGTTOU,
SIGUSR1, SIGUSR2, SIGPOLL, SIGPROF, SIGSYS,
SIGTRAP, SIGURG, SIGVTALRM, SIGXCPU, SIGXFSZ };
for (i=0; i<NUMSIGNALS; i++) {
if (sigismember(&set, siglist[i]) != 0)
return 1;
}
return 0;
}
int get_rand() {
int r;
r=rand();
while ((r == SIG_BLOCK) || (r == SIG_SETMASK) || (r == SIG_UNBLOCK)) {
r = get_rand();
}
return r;
}
int main() {
int r=get_rand();
sigset_t actl, oactl;
sigemptyset(&actl);
sigemptyset(&oactl);
sigaddset(&actl, SIGABRT);
sigprocmask(SIG_SETMASK, &actl, NULL);
sigaddset(&actl, SIGALRM);
if (sigprocmask(r, &actl, NULL) != -1) {
perror("sigprocmask() did not fail even though invalid how parameter was passed to it.\n");
return PTS_UNRESOLVED;
}
sigprocmask(SIG_SETMASK, NULL, &oactl);
if (sigismember(&oactl, SIGABRT) != 1) {
printf("FAIL: signal mask was changed. \n");
return PTS_FAIL;
}
if (is_changed(oactl)) {
printf("FAIL: signal mask was changed. \n");
return PTS_FAIL;
}
printf("PASS: signal mask was not changed.\n");
return PTS_PASS;
}

View File

@ -0,0 +1,63 @@
/*
* 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. Add only SIGABRT to the signal mask.
2. Make a call such as this: sigprocmask(SIG_BLOCK, NULL, &oactl). At
this point, we have obtained the signal mask in oactl.
3. Now call is_changed to make sure that SIGABRT is still in oactl, and
that no other signal in the set is in oactl.
*/
#include <signal.h>
#include <stdio.h>
#include "posixtest.h"
#define NUMSIGNALS 26
int is_changed(sigset_t set, int sig) {
int i;
int siglist[] = {SIGABRT, SIGALRM, SIGBUS, SIGCHLD,
SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT,
SIGPIPE, SIGQUIT, SIGSEGV,
SIGTERM, SIGTSTP, SIGTTIN, SIGTTOU,
SIGUSR1, SIGUSR2, SIGPOLL, SIGPROF, SIGSYS,
SIGTRAP, SIGURG, SIGVTALRM, SIGXCPU, SIGXFSZ };
if (sigismember(&set, sig) != 1) {
return 1;
}
for (i=0; i<NUMSIGNALS; i++) {
if ((siglist[i] != sig)) {
if (sigismember(&set, siglist[i]) != 0) {
return 1;
}
}
}
return 0;
}
int main() {
sigset_t actl, oactl;
sigemptyset(&actl);
sigemptyset(&oactl);
sigaddset(&actl, SIGABRT);
sigprocmask(SIG_SETMASK, &actl, NULL);
sigprocmask(SIG_BLOCK, NULL, &oactl);
if (is_changed(oactl, SIGABRT)) {
return PTS_FAIL;
}
printf("PASS: signal mask was not changed.\n");
return PTS_PASS;
}

View File

@ -0,0 +1,64 @@
/*
* 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. Add only SIGABRT to the signal mask.
2. Make a call such as this: sigprocmask(SIG_SETMASK, NULL, &oactl).
At
this point, we have obtained the signal mask in oactl.
3. Now call is_changed to make sure that SIGABRT is still in oactl, and
that no other signal in the set is in oactl.
*/
#include <signal.h>
#include <stdio.h>
#include "posixtest.h"
#define NUMSIGNALS 26
int is_changed(sigset_t set, int sig) {
int i;
int siglist[] = {SIGABRT, SIGALRM, SIGBUS, SIGCHLD,
SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT,
SIGPIPE, SIGQUIT, SIGSEGV,
SIGTERM, SIGTSTP, SIGTTIN, SIGTTOU,
SIGUSR1, SIGUSR2, SIGPOLL, SIGPROF, SIGSYS,
SIGTRAP, SIGURG, SIGVTALRM, SIGXCPU, SIGXFSZ };
if (sigismember(&set, sig) != 1) {
return 1;
}
for (i=0; i<NUMSIGNALS; i++) {
if ((siglist[i] != sig)) {
if (sigismember(&set, siglist[i]) != 0) {
return 1;
}
}
}
return 0;
}
int main() {
sigset_t actl, oactl;
sigemptyset(&actl);
sigemptyset(&oactl);
sigaddset(&actl, SIGABRT);
sigprocmask(SIG_SETMASK, &actl, NULL);
sigprocmask(SIG_SETMASK, NULL, &oactl);
if (is_changed(oactl, SIGABRT)) {
return PTS_FAIL;
}
printf("PASS: signal mask was not changed.\n");
return PTS_PASS;
}

View File

@ -0,0 +1,63 @@
/*
* 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. Add only SIGABRT to the signal mask.
2. Make a call such as this: sigprocmask(SIG_UNBLOCK, NULL, &oactl). At
this point, we have obtained the signal mask in oactl.
3. Now call is_changed to make sure that SIGABRT is still in oactl, and
that no other signal in the set is in oactl.
*/
#include <signal.h>
#include <stdio.h>
#include "posixtest.h"
#define NUMSIGNALS 26
int is_changed(sigset_t set, int sig) {
int i;
int siglist[] = {SIGABRT, SIGALRM, SIGBUS, SIGCHLD,
SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT,
SIGPIPE, SIGQUIT, SIGSEGV,
SIGTERM, SIGTSTP, SIGTTIN, SIGTTOU,
SIGUSR1, SIGUSR2, SIGPOLL, SIGPROF, SIGSYS,
SIGTRAP, SIGURG, SIGVTALRM, SIGXCPU, SIGXFSZ };
if (sigismember(&set, sig) != 1) {
return 1;
}
for (i=0; i<NUMSIGNALS; i++) {
if ((siglist[i] != sig)) {
if (sigismember(&set, siglist[i]) != 0) {
return 1;
}
}
}
return 0;
}
int main() {
sigset_t actl, oactl;
sigemptyset(&actl);
sigemptyset(&oactl);
sigaddset(&actl, SIGABRT);
sigprocmask(SIG_SETMASK, &actl, NULL);
sigprocmask(SIG_UNBLOCK, NULL, &oactl);
if (is_changed(oactl, SIGABRT)) {
return PTS_FAIL;
}
printf("PASS: signal mask was not changed.\n");
return PTS_PASS;
}

View File

@ -0,0 +1,9 @@
SubDir HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigprocmask ;
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 ;

View File

@ -0,0 +1,17 @@
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: julie.n.fleischer 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.
*/
/*
* return codes
*/
#define PTS_PASS 0
#define PTS_FAIL 1
#define PTS_UNRESOLVED 2
#define PTS_UNSUPPORTED 4
#define PTS_UNTESTED 5