clean up a bunch of tests
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
printf("Caught signal %d being tested!\n", signo);
|
||||
printf("Test PASSED\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int kill_group(int signum)
|
||||
{
|
||||
int pgrp;
|
||||
struct sigaction act;
|
||||
int status;
|
||||
|
||||
act.sa_handler=sig_handler;
|
||||
act.sa_flags=0;
|
||||
status = sigemptyset(&act.sa_mask);
|
||||
ERROR_IF(sigemptyset, status, == -1);
|
||||
|
||||
status = sigaction(signum, &act, 0);
|
||||
ERROR_IF(sigaction, staus, == -1);
|
||||
|
||||
staus = getpgrp();
|
||||
ERROR_IF(getpgrp, status, == -1);
|
||||
|
||||
status = kill(-pgrp, signum);
|
||||
ERROR_IF(kill, staus, != 0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// If pid is negative, but not -1, sig shall be sent to all processes (excluding an unspecified set of system processes) whose process group ID is equal to the absolute value of pid, and for which the process has permission to send a signal.
|
||||
int main()
|
||||
{
|
||||
for (unsigned int i = 0; i < sizeof(signals_list)/sizeof(signals_list[0]); i++)
|
||||
{
|
||||
int sig = signals_list[i].signal;
|
||||
if (sig == SIGKILL || sig == SIGSTOP)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
kill_group(sig);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -12,18 +12,9 @@ int main()
|
||||
/*
|
||||
* ESRCH
|
||||
*/
|
||||
if (-1 == kill(999999, 0)) {
|
||||
if (ESRCH == errno) {
|
||||
printf("ESRCH error received\n");
|
||||
} else {
|
||||
printf("kill() failed on ESRCH errno not set correctly\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
printf("kill() did not fail on ESRCH\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
printf("test passed\n");
|
||||
int status;
|
||||
status = kill(999999, 0);
|
||||
ERROR_IF(kill, status, != -1);
|
||||
ERROR_IF(kill, errno, != ESRCH);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -6,22 +6,13 @@
|
||||
#include <sys/types.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
int main()
|
||||
int main(void)
|
||||
{
|
||||
setuid(1); /* this is added incase user is root. If user is normal user, then it has no effect on the tests*/
|
||||
|
||||
if (kill(1, 0) == -1) {
|
||||
if (EPERM == errno) {
|
||||
printf("EPERM error received\n");
|
||||
} else {
|
||||
printf("kill() failed on EPERM errno not set correctly\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
printf("kill() did not fail on EPERM\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("test passed\n");
|
||||
return 0;
|
||||
int status;
|
||||
// This is added incase user is root. If user is normal user, then it has no effect on the tests
|
||||
setuid(1000);
|
||||
status = kill(1, 0);
|
||||
ERROR_IF(kill, status, != -1);
|
||||
ERROR_IF(kill, errno, !=EPERM);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -34,11 +34,7 @@ int kill_self(int sig)
|
||||
status = kill(getpid(), sig);
|
||||
ERROR_IF(kill, status, != 0);
|
||||
|
||||
if (handler_called == 0)
|
||||
{
|
||||
printf("Handler was not called\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(kill, handler_called, == 0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -10,16 +10,11 @@
|
||||
int main()
|
||||
{
|
||||
|
||||
if (killpg(999999, 0) != -1) {
|
||||
printf("killpg did not return -1 even though it was passed an invalid process group id.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status;
|
||||
status = killpg(999999, 0);
|
||||
ERROR_IF(killpg, status, !=-1);
|
||||
|
||||
if (errno != ESRCH) {
|
||||
printf("killpg did not set errno to ESRCH even though it was passed an invalid signal number.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(killpg, errno, != ESRCH);
|
||||
|
||||
printf("Test PASSED\n");
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -11,21 +11,14 @@ int main()
|
||||
{
|
||||
int pgrp;
|
||||
|
||||
if ((pgrp = getpgrp()) == -1) {
|
||||
printf("Could not get process group number\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
pgrp = getpgrp();
|
||||
ERROR_IF(getpgrp, pgrp, == -1);
|
||||
|
||||
int status;
|
||||
status = killpg(pgrp, -1);
|
||||
ERROR_IF(killpg, status, != -1);
|
||||
|
||||
if (killpg(pgrp, -1) != -1) {
|
||||
printf("killpg did not return -1 even though it was passed an invalid signal number.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(killpg, errno, != EINVAL);
|
||||
|
||||
if (errno != EINVAL) {
|
||||
printf("killpg did not set errno to EINVAL even though it was passed an invalid signal number.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Test PASSED\n");
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+10
-17
@@ -19,26 +19,19 @@ int killpg_test1(int signum)
|
||||
|
||||
act.sa_handler=sig_handler;
|
||||
act.sa_flags=0;
|
||||
if (sigemptyset(&act.sa_mask) == -1) {
|
||||
perror("Error calling sigemptyset\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (sigaction(signum, &act, 0) == -1) {
|
||||
perror("Error calling sigaction\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status = sigemptyset(&act.sa_mask);
|
||||
ERROR_IF(sigemptyset, status, == -1);
|
||||
|
||||
if ((pgrp = getpgrp()) == -1) {
|
||||
printf("Could not get process group number\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigaction(signum, &act, 0);
|
||||
ERROR_IF(sigaction, status, == -1);
|
||||
|
||||
if (killpg(pgrp, signum) != 0) {
|
||||
printf("Could not raise signal being tested\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
pgrp = getpgrp()
|
||||
ERROR_IF(getpgrp, pgrp, == -1);
|
||||
|
||||
return 0;
|
||||
status = killpg(pgrp, signum);
|
||||
ERROR_IF(killpg, status, != 0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
@@ -9,16 +9,14 @@ int main()
|
||||
{
|
||||
int pgrp;
|
||||
|
||||
if ((pgrp = getpgrp()) == -1) {
|
||||
printf("Could not get process group number\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
pgrp = getpgrp();
|
||||
ERROR_IF(getpgrp, pgrp, == -1);
|
||||
|
||||
int status;
|
||||
status = killpg(pgrp, 0);
|
||||
ERROR_IF(killpg, status, != 0);
|
||||
|
||||
if (killpg(pgrp, 0) != 0) {
|
||||
printf("killpg did not return success.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Test PASSED\n");
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -12,10 +12,9 @@ int main()
|
||||
|
||||
main_thread = pthread_self();
|
||||
|
||||
if (EINVAL != pthread_kill(main_thread, -1)) {
|
||||
printf("pthread_kill() did not fail on EINVAL\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("test pass\n");
|
||||
return 0;
|
||||
int status;
|
||||
status = pthread_kill(main_thread, -1);
|
||||
ERROR_IF(pthread_kill, status, != EINVAL);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -10,11 +10,9 @@ int main()
|
||||
|
||||
main_thread=pthread_self();
|
||||
|
||||
if (pthread_kill(main_thread, 0) != 0) {
|
||||
printf("Could not call pthread_kill with sig = 0\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status;
|
||||
status = pthread_kill(main_thread, 0);
|
||||
ERROR_IF(pthread_kill, status, != 0);
|
||||
|
||||
printf("Test PASSED\n");
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -14,16 +14,13 @@
|
||||
|
||||
|
||||
void addset_test(sigset_t *sigset, int signal){
|
||||
if (sigismember(sigset, signal) !=0){
|
||||
printf("the signal is already in the set, %d\n", signal);
|
||||
}
|
||||
int status;
|
||||
status = sigismember(sigset, signal);
|
||||
ERROR_IF(sigismember, status, != 0);
|
||||
sigaddset(sigset, signal);
|
||||
if (sigismember(sigset, signal) ==1){
|
||||
printf("the signal was added successfully\n");
|
||||
}
|
||||
if (sigismember(sigset, signal) !=1){
|
||||
printf("the signal add failed\n");
|
||||
}
|
||||
|
||||
status = sigismember(sigset, signal);
|
||||
ERROR_IF(sigismember, status, != 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,16 +15,13 @@
|
||||
|
||||
|
||||
void delset_test(sigset_t *sigset, int signal){
|
||||
if (sigismember(sigset, signal) !=1){
|
||||
printf("the signal is already out of the set, %d\n", signal);
|
||||
}
|
||||
int status;
|
||||
status = sigismember(sigset, signal);
|
||||
ERROR_IF(sigismember, status, != 1);
|
||||
|
||||
sigdelset(sigset, signal);
|
||||
if (sigismember(sigset, signal) ==0){
|
||||
printf("the signal was deleted successfully\n");
|
||||
}
|
||||
if (sigismember(sigset, signal) !=0){
|
||||
printf("the signal remove failed\n");
|
||||
}
|
||||
status = sigismember(sigset, signal);
|
||||
ERROR_IF(sigismember, status, != 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,17 +9,13 @@
|
||||
|
||||
int main() {
|
||||
sigset_t sigset;
|
||||
int status;
|
||||
|
||||
sigfillset(&sigset);
|
||||
if (sigismember(&sigset, -1)!=-1){
|
||||
printf("sigismember didn't return -1");
|
||||
exit(EXIT_FAILURE);
|
||||
} else if (EINVAL != errno) {
|
||||
printf("errno was not set to EINVAL\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigismember(&sigset, -1);
|
||||
ERROR_IF(sigismember, status, != -1);
|
||||
ERROR_IF(sigismember, errno, != EINVAL);
|
||||
|
||||
printf ("errno set to EINVAL and sigismember returned -1\n");
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
@@ -10,11 +10,21 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
void check(sigset_t set, int signum) {
|
||||
void check_full(sigset_t set, int signum) {
|
||||
if (!sigismember(&set, signum)) {
|
||||
printf("%d was not added to the set", signum);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void check_empty(sigset_t set, int signum) {
|
||||
printf("%d is ", signum);
|
||||
if (!sigismember(&set, signum))
|
||||
printf("not ");
|
||||
puts("in the set");
|
||||
if (sigismember(&set, signum)) {
|
||||
printf("%d was not removed from the set", signum);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +34,12 @@ int main() {
|
||||
|
||||
sigfillset(&sigset);
|
||||
for (int i=1; i<N_SIGNALS; i++){
|
||||
check(sigset, i);
|
||||
check_full(sigset, i);
|
||||
}
|
||||
|
||||
sigemptyset(&sigset);
|
||||
for (int i=1; i<N_SIGNALS; i++){
|
||||
check(sigset, i);
|
||||
check_empty(sigset, i);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,30 +37,20 @@ void *a_thread_func(void *sig)
|
||||
int sigpause_basic(int signum)
|
||||
{
|
||||
pthread_t new_th;
|
||||
|
||||
if(pthread_create(&new_th, NULL, a_thread_func, (void *)&signum) != 0)
|
||||
{
|
||||
perror("Error creating thread\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status;
|
||||
status = pthread_create(&new_th, NULL, a_thread_func, (void *)&signum);
|
||||
ERROR_IF(pthread_create, status, != 0);
|
||||
|
||||
sleep(1);
|
||||
|
||||
if(pthread_kill(new_th, signum) != 0)
|
||||
{
|
||||
printf("Test UNRESOLVED: Couldn't send signal to thread\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = pthread_kill(new_th, signum);
|
||||
ERROR_IF(pthread_kill, status, != 0);
|
||||
|
||||
sleep(1);
|
||||
|
||||
if(handler_called != 1) {
|
||||
printf("Test FAILED: signal wasn't removed from signal mask\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(pthread_kill, handler_called,, != 1);
|
||||
handler_called = 0;
|
||||
|
||||
printf("Test PASSED\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,35 +44,24 @@ int sigpause_suspend(int signum)
|
||||
pthread_t new_th;
|
||||
int j;
|
||||
|
||||
if(pthread_create(&new_th, NULL, b_thread_func, (void *)&signum) != 0)
|
||||
{
|
||||
perror("Error creating thread\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status;
|
||||
status = pthread_create(&new_th, NULL, b_thread_func, (void *)&signum);
|
||||
ERROR_IF(pthread_create, status, != 0);
|
||||
|
||||
for (j=0; j<10; j++) {
|
||||
sleep(1);
|
||||
if (returned == 1) {
|
||||
printf ("Test FAILED: sigpause returned before it received a signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(sigpuase, returned, == 1);
|
||||
}
|
||||
|
||||
if(pthread_kill(new_th, signum) != 0)
|
||||
{
|
||||
printf("Test UNRESOLVED: Couldn't send signal to thread\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = pthread_kill(new_th, signum);
|
||||
ERROR_IF(pthread_kill, status, != 0);
|
||||
|
||||
sleep(1);
|
||||
|
||||
if(returned != 1) {
|
||||
printf("Test FAILED: signal was sent, but sigpause never returned.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(sigpuase, returned, != 1);
|
||||
|
||||
returned = 0;
|
||||
|
||||
printf("test passed\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,8 @@ int main()
|
||||
sigset_t set;
|
||||
sigaddset (&set, SIGABRT);
|
||||
|
||||
if (sigprocmask(SIG_SETMASK, &set, NULL) != 0) {
|
||||
perror("sigprocmask failed -- returned -- test aborted");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("sigignore passed\n");
|
||||
int status;
|
||||
status = sigprocmask(SIG_SETMASK, &set, NULL);
|
||||
ERROR_IF(sigprocmask, status, != 0);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -29,66 +29,38 @@ int sigprocmask_block(int signum)
|
||||
act.sa_flags = 0;
|
||||
sigemptyset(&act.sa_mask);
|
||||
|
||||
if (sigaction(signum, &act, 0) == -1) {
|
||||
perror("Unexpected error while attempting to setup test "
|
||||
"pre-conditions");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status;
|
||||
status = sigaction(signum, &act, 0);
|
||||
ERROR_IF(sigaction, status, == -1);
|
||||
|
||||
status = sigaction(defaultsig, &act, 0);
|
||||
ERROR_IF(sigaction, status, == -1);
|
||||
|
||||
if (sigaction(defaultsig, &act, 0) == -1) {
|
||||
perror("Unexpected error while attempting to setup test "
|
||||
"pre-conditions");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigprocmask(SIG_SETMASK, &set1, NULL);
|
||||
ERROR_IF(sigprocmask, status, == -1);
|
||||
|
||||
if (sigprocmask(SIG_SETMASK, &set1, NULL) == -1) {
|
||||
perror("Unexpected error while attempting to use sigprocmask.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigprocmask(SIG_UNBLOCK, &set2, NULL);
|
||||
ERROR_IF(sigprocmask, status, == -1);
|
||||
|
||||
if (sigprocmask(SIG_UNBLOCK, &set2, NULL) == -1) {
|
||||
perror("Unexpected error while attempting to use sigprocmask.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = raise(signum);
|
||||
ERROR_IF(raise, status, == -1);
|
||||
|
||||
if (raise(signum) == -1) {
|
||||
perror("Unexpected error while attempting to setup test "
|
||||
"pre-conditions");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!handler_called) {
|
||||
printf("FAIL: Handler was not called while it should have been\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(raise, handler_called, != 1);
|
||||
handler_called = 0;
|
||||
|
||||
if (raise(defaultsig) == -1) {
|
||||
perror("Unexpected error while attempting to setup test "
|
||||
"pre-conditions");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = raise(defaultsig);
|
||||
ERROR_IF(raise, defualtsig, == -1);
|
||||
|
||||
if (handler_called) {
|
||||
printf("FAIL: signal was not blocked\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(raise, handler_called, == 1);
|
||||
|
||||
if (sigpending(&pending_set) == -1) {
|
||||
perror("Unexpected error while attempting to use sigpending\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigpending(&pending_set);
|
||||
ERROR_IF(sigpending, status, == -1);
|
||||
|
||||
if (sigismember(&pending_set, defaultsig) != 1) {
|
||||
perror("FAIL: sigismember did not return 1\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigismember(&pending_set, defaultsig);
|
||||
ERROR_IF(sigismember, status, != 1);
|
||||
|
||||
if (sigismember(&pending_set, signum) != 0) {
|
||||
perror("FAIL: sigismember did not return 0\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigismember(&pending_set, signum);
|
||||
ERROR_IF(sigismemeber, status, != 0);
|
||||
|
||||
printf("Test PASSED: signal was added to the process's signal mask\n");
|
||||
act.sa_handler = SIG_IGN;
|
||||
|
||||
@@ -33,10 +33,8 @@ int main()
|
||||
}
|
||||
|
||||
if (test_failed != 0) {
|
||||
printf("Old set is missing a signal\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Test PASSED: oactl did contain all signals that were added to the signal mask.\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -42,6 +42,5 @@ int main() {
|
||||
if (is_changed(oactl, SIGABRT)) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("PASS: signal mask was not changed.\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -42,6 +42,5 @@ int main() {
|
||||
if (is_changed(oactl, SIGABRT)) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("PASS: signal mask was not changed.\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -41,6 +41,5 @@ int main() {
|
||||
if (is_changed(oactl, SIGABRT)) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("PASS: signal mask was not changed.\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
int handler_called = 0;
|
||||
int sigprocmask_return_val = 1; /* some value that's not a 1 or 0 */
|
||||
@@ -26,35 +27,22 @@ int main()
|
||||
act.sa_flags = 0;
|
||||
sigemptyset(&act.sa_mask);
|
||||
|
||||
if (sigaction(SIGABRT, &act, 0) == -1) {
|
||||
perror("Unexpected error while attempting to setup test "
|
||||
"pre-conditions");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status;
|
||||
|
||||
if (sigprocmask(SIG_SETMASK, &blocked_set1, NULL) == -1) {
|
||||
perror("Unexpected error while attempting to use sigprocmask.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigaction(SIGABRT, &act, 0);
|
||||
ERROR_IF(sigaction, status, == -1);
|
||||
|
||||
if ((raise(SIGABRT) == -1)) {
|
||||
perror("Unexpected error while attempting to setup test "
|
||||
"pre-conditions");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigprocmask(SIG_SETMASK, &blocked_set1, NULL);
|
||||
ERROR_IF(sigprocmask, status, == -1);
|
||||
|
||||
status = raise(SIGABRT);
|
||||
ERROR_IF(raise, status, == -1);
|
||||
|
||||
sigprocmask_return_val = sigprocmask(SIG_UNBLOCK, &blocked_set1, NULL);
|
||||
|
||||
if (sigprocmask_return_val != 0) {
|
||||
perror("Unexpected error while attempting to use sigprocmask.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (handler_called != 1) {
|
||||
perror("Handler wasn't called, implying signal was not delivered.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(sigprocmask, sigprocmask_return_val, != 0);
|
||||
|
||||
ERROR_IF(raise, handler_called, != 1);
|
||||
|
||||
printf("Test PASSED: signal was delivered before the call to sigprocmask returned.\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -14,19 +14,16 @@ int main() {
|
||||
sigprocmask_return_val = sigprocmask(SIG_SETMASK, &set1, NULL);
|
||||
sigprocmask(SIG_SETMASK, NULL, &set2);
|
||||
|
||||
|
||||
if (sigismember(&set2, SIGKILL)) {
|
||||
printf("FAIL: SIGKILL was added to the signal mask\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (sigismember(&set2, SIGSTOP)) {
|
||||
printf("FAIL: SIGSTOP was added to the signal mask\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (sigprocmask_return_val == -1) {
|
||||
printf("FAIL: sigprocmask returned -1. System should be able to enforce blocking un-ignorable signals without causing sigprocmask() to return -1.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Test PASSED\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -28,39 +28,28 @@ int sigprocmask_block(int signum)
|
||||
act.sa_flags = 0;
|
||||
sigemptyset(&act.sa_mask);
|
||||
|
||||
if (sigaction(signum, &act, 0) == -1) {
|
||||
perror("Unexpected error while attempting to setup test "
|
||||
"pre-conditions");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status;
|
||||
status = sigaction(signum, &act, 0);
|
||||
ERROR_IF(sigaction, status, == -1);
|
||||
|
||||
if (sigprocmask(SIG_SETMASK, &blocked_set, NULL) == -1) {
|
||||
perror("Unexpected error while attempting to use sigprocmask.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigprocmask(SIG_SETMASK, &blocked_set, NULL);
|
||||
ERROR_IF(sigprocmask, status, == -1);
|
||||
|
||||
if (raise(signum) == -1) {
|
||||
perror("Unexpected error while attempting to setup test "
|
||||
"pre-conditions");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = raise(signum);
|
||||
ERROR_IF(raise, status, == -1);
|
||||
|
||||
if (handler_called) {
|
||||
printf("FAIL: Signal was not blocked\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(raise, handler_called, == 1);
|
||||
// if (handler_called) {
|
||||
// printf("FAIL: Signal was not blocked\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
|
||||
if (sigpending(&pending_set) == -1) {
|
||||
perror("Unexpected error while attempting to use sigpending\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigpending(&pending_set);
|
||||
ERROR_IF(sigpending, status, == -1);
|
||||
|
||||
if (sigismember(&pending_set, signum) != 1) {
|
||||
perror("FAIL: sigismember did not return 1\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigismember(&pending_set, signum);
|
||||
ERROR_IF(sigismember, status, != 1);
|
||||
|
||||
printf("Test PASSED: signal was added to the process's signal mask\n");
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(signum, &act, 0);
|
||||
|
||||
|
||||
@@ -6,11 +6,8 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
if ((int)sigrelse(SIGABRT) != 0) {
|
||||
perror("sigrelse failed -- returned -- test aborted");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("sigrelse passed\n");
|
||||
int status;
|
||||
status = (int)sigrelse(SIGABRT);
|
||||
ERROR_IF(sigrelse, status, != 0);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -7,14 +7,19 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
if ((int)sigrelse(100000) == -1) {
|
||||
int status;
|
||||
status = (int)sigrelse(100000);
|
||||
ERROR_IF(sigrelse, status, != -1);
|
||||
ERROR_IF(sigrelse, errno, != EINVAL);
|
||||
return EXIT_SUCCESS;
|
||||
// if ((int)sigrelse(100000) == -1) {
|
||||
|
||||
if (EINVAL == errno) {
|
||||
printf ("errno set to EINVAL\n");
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
printf ("errno not set to EINVAL\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
// if (EINVAL == errno) {
|
||||
// printf ("errno set to EINVAL\n");
|
||||
// return EXIT_SUCCESS;
|
||||
// } else {
|
||||
// printf ("errno not set to EINVAL\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user