clean up some tests
This commit is contained in:
@@ -19,8 +19,6 @@ void sig_handler(int signo)
|
||||
void child_proc(int signum)
|
||||
{
|
||||
|
||||
int sig;
|
||||
(void) sig;
|
||||
sigset_t sig_set;
|
||||
int status;
|
||||
|
||||
@@ -41,11 +39,7 @@ void child_proc(int signum)
|
||||
status = sleep(10);
|
||||
ERROR_IF(sleep, status, == 0);
|
||||
|
||||
if (sig_handled == 0)
|
||||
{
|
||||
printf("signal handler was not called");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(kill, sig_handled, == 0 );
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -88,13 +82,14 @@ void kill_child(int signum)
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int i = 1; i < N_SIGNALS; i++)
|
||||
for (int i = 1; i < sizeof(signals_list)/sizeof(signals_list[0]); i++)
|
||||
{
|
||||
if (i == SIGKILL || i == SIGSTOP)
|
||||
int sig = signals_list[i].signal;
|
||||
if (sig == SIGKILL || i == SIGSTOP)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
kill_child(i);
|
||||
kill_child(sig);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <sys/types.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
//this test ensures that sending an invalid signal will set errno to esrch
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// test killing a child process
|
||||
|
||||
void sig_handler (int signo) {
|
||||
(void) signo;
|
||||
exit(1);
|
||||
@@ -36,21 +38,16 @@ int killpg_test2(int signum)
|
||||
sigignore(signum);
|
||||
|
||||
sleep(1);
|
||||
if ((child_pgid = getpgid(child_pid)) == -1) {
|
||||
printf("Could not get pgid of child\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
child_pgid = getpgid(child_pid);
|
||||
ERROR_IF(getpgid, child_pgid, == -1);
|
||||
|
||||
int status;
|
||||
status = killpg(child_pgid, signum);
|
||||
ERROR_IF(killpg, status, != 0);
|
||||
|
||||
if (killpg(child_pgid, signum) != 0) {
|
||||
printf("Could not raise signal being tested\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (wait(&i) == -1) {
|
||||
perror("Error waiting for child to exit\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = wait(&i);
|
||||
ERROR_IF(wait, status, == -1);
|
||||
|
||||
if (WEXITSTATUS(i)) {
|
||||
printf("Child exited normally\n");
|
||||
@@ -63,8 +60,6 @@ int killpg_test2(int signum)
|
||||
}
|
||||
}
|
||||
|
||||
printf("Should have exited from parent\n");
|
||||
printf("Test FAILED\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -7,6 +5,7 @@
|
||||
#include <errno.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// if a user tries to kill a process that does not exist the esrch error will be returned
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -7,6 +5,7 @@
|
||||
#include <errno.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// the test makes sure that if an invalid signal is passed it will return the EINVAL error
|
||||
int main()
|
||||
{
|
||||
int pgrp;
|
||||
|
||||
@@ -5,10 +5,13 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// Test that the killpg() function shall send signal sig to the process
|
||||
// group specified by prgp.
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
printf("Caught signal %d being tested!\n", signo);
|
||||
printf("Test PASSED\n");
|
||||
// printf("Caught signal %d being tested!\n", signo);
|
||||
// printf("Test PASSED\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +28,7 @@ int killpg_test1(int signum)
|
||||
status = sigaction(signum, &act, 0);
|
||||
ERROR_IF(sigaction, status, == -1);
|
||||
|
||||
pgrp = getpgrp()
|
||||
pgrp = getpgrp();
|
||||
ERROR_IF(getpgrp, pgrp, == -1);
|
||||
|
||||
status = killpg(pgrp, signum);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// test sending signal 0 to self will killpg
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -16,7 +17,5 @@ int main()
|
||||
status = killpg(pgrp, 0);
|
||||
ERROR_IF(killpg, status, != 0);
|
||||
|
||||
|
||||
printf("Test PASSED\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -5,6 +5,9 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
//test with pthread_kill to kill a child process
|
||||
|
||||
void * thread_function(void *arg)
|
||||
{
|
||||
@@ -25,32 +28,19 @@ int main()
|
||||
|
||||
rc = pthread_create(&child_thread, NULL,
|
||||
thread_function, NULL);
|
||||
if (rc != 0)
|
||||
{
|
||||
printf("Error at pthread_create()\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(pthread_create, rc, != 0);
|
||||
|
||||
rc = pthread_join(child_thread, NULL);
|
||||
if (rc != 0)
|
||||
{
|
||||
printf("Error at pthread_join()\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(pthread_join, rc, != 0);
|
||||
|
||||
/* Now the child_thread exited, it is an invalid tid */
|
||||
// Now the child_thread exited, it is an invalid tid
|
||||
memcpy(&invalid_tid, &child_thread,
|
||||
sizeof(pthread_t));
|
||||
// int i = pthread_kill(invalid_tid, 0);
|
||||
sleep(3);
|
||||
// printf("%d\n", i);
|
||||
// printf("esrch is %d\n", ESRCH);
|
||||
|
||||
if (pthread_kill(invalid_tid, 0) == ESRCH) {
|
||||
printf("pthread_kill() returns ESRCH.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Test Fail\n");
|
||||
exit(1);
|
||||
int status;
|
||||
status = pthread_kill(invalid_tid, 0);
|
||||
ERROR_IF(pthread_kill, status, != ESRCH);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -5,6 +5,9 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
//test with pthread_kill making sure sending an invalid signal returns einval
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
//test pthread_kill on self
|
||||
|
||||
# define INTHREAD 0
|
||||
# define INMAIN 1
|
||||
# define SIGTOTEST SIGABRT
|
||||
@@ -20,7 +22,6 @@ struct signal {
|
||||
};
|
||||
|
||||
void handler() {
|
||||
printf("signal was called\n");
|
||||
handler_called = 1;
|
||||
return;
|
||||
}
|
||||
@@ -55,37 +56,27 @@ int pthread_kill_test1(int signum)
|
||||
struct signal arg;
|
||||
arg.signum = signum;
|
||||
|
||||
if(pthread_create(&new_th, NULL, a_thread_func, &arg) != 0)
|
||||
{
|
||||
perror("Error creating thread\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status;
|
||||
status = pthread_create(&new_th, NULL, a_thread_func, &arg);
|
||||
ERROR_IF(pthread_create, status, != 0);
|
||||
|
||||
while(sem1==INTHREAD)
|
||||
sleep(1);
|
||||
|
||||
if(pthread_kill(new_th, signum) != 0)
|
||||
{
|
||||
printf("Test FAILED: Couldn't send signal to thread\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = pthread_kill(new_th, signum);
|
||||
ERROR_IF(pthread_kill, status, != 0);
|
||||
|
||||
sleep(2);
|
||||
sem1=INTHREAD;
|
||||
|
||||
while(handler_called==0)
|
||||
sleep(1);
|
||||
|
||||
if(handler_called == -1) {
|
||||
printf("Test FAILED: Kill request timed out\n");
|
||||
exit(EXIT_FAILURE);
|
||||
} else if (handler_called == 0) {
|
||||
printf("Test FAILED: Thread did not recieve or handle\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Test PASSED for signal %d\n", signum);
|
||||
handler_called = 0;
|
||||
return 0;
|
||||
ERROR_IF(pthread_kill, handler_called, == -1);
|
||||
ERROR_IF(pthread_kill, handler_called, == 0);
|
||||
|
||||
handler_called = 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// test sending 0 with pthread_kill to self
|
||||
|
||||
int main()
|
||||
{
|
||||
pthread_t main_thread;
|
||||
|
||||
main_thread=pthread_self();
|
||||
main_thread = pthread_self();
|
||||
|
||||
int status;
|
||||
status = pthread_kill(main_thread, 0);
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
// The raise() function shall send the signal sig to the executing [CX] [Option Start] thread or process. [Option End] If a signal handler is called, the raise() function shall not return until after the signal handler does.
|
||||
|
||||
// [CX] [Option Start] The effect of the raise() function shall be equivalent to calling: pthread_kill(pthread_self(), sig);
|
||||
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// The raise() function shall send the signal sig to the executing [CX] [Option Start] thread or process. [Option End] If a signal handler is called, the raise() function shall not return until after the signal handler does.
|
||||
|
||||
// [CX] [Option Start] The effect of the raise() function shall be equivalent to calling: pthread_kill(pthread_self(), sig);
|
||||
|
||||
void sig_hand(int i)
|
||||
|
||||
{
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
|
||||
|
||||
// The sigaddset() function adds the individual signal specified by the signo to the signal set pointed to by set.
|
||||
|
||||
// Applications shall call either sigemptyset() or sigfillset() at least once for each object of type sigset_t prior to any other use of that object. If such an object is not initialized in this way, but is nonetheless supplied as an argument to any of pthread_sigmask(), sigaction(), sigaddset(), sigdelset(), sigismember(), sigpending(), sigprocmask(), sigsuspend(), sigtimedwait(), sigwait(), or sigwaitinfo(), the results are undefined.
|
||||
|
||||
#define _OPEN_SYS
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
@@ -11,13 +6,18 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// The sigaddset() function adds the individual signal specified by the signo to the signal set pointed to by set.
|
||||
|
||||
// Applications shall call either sigemptyset() or sigfillset() at least once for each object of type sigset_t prior to any other use of that object. If such an object is not initialized in this way, but is nonetheless supplied as an argument to any of pthread_sigmask(), sigaction(), sigaddset(), sigdelset(), sigismember(), sigpending(), sigprocmask(), sigsuspend(), sigtimedwait(), sigwait(), or sigwaitinfo(), the results are undefined.
|
||||
|
||||
void addset_test(sigset_t *sigset, int signal){
|
||||
int status;
|
||||
int status;
|
||||
|
||||
status = sigismember(sigset, signal);
|
||||
ERROR_IF(sigismember, status, != 0);
|
||||
sigaddset(sigset, signal);
|
||||
|
||||
status = sigaddset(sigset, signal);
|
||||
ERROR_IF(sigaddset, status, != 0);
|
||||
|
||||
status = sigismember(sigset, signal);
|
||||
ERROR_IF(sigismember, status, != 1);
|
||||
@@ -30,7 +30,9 @@ int main() {
|
||||
sigemptyset(&sigset);
|
||||
|
||||
for (int i = 1; i < N_SIGNALS; i++){
|
||||
addset_test(&sigset, i);
|
||||
int sig = signals_list[i-1].signal;
|
||||
|
||||
addset_test(&sigset, sig);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
|
||||
|
||||
// The sigdelset() function deletes the individual signal specified by signo from the signal set pointed to by set.
|
||||
|
||||
// Applications should call either sigemptyset() or sigfillset() at least once for each object of type sigset_t prior to any other use of that object. If such an object is not initialized in this way, but is nonetheless supplied as an argument to any of pthread_sigmask(), sigaction(), sigaddset(), sigdelset(), sigismember(), sigpending(), sigprocmask(), sigsuspend(), sigtimedwait(), sigwait(), or sigwaitinfo(), the results are undefined.
|
||||
|
||||
|
||||
#define _OPEN_SYS
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
@@ -12,6 +5,9 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// The sigdelset() function deletes the individual signal specified by signo from the signal set pointed to by set.
|
||||
|
||||
// Applications should call either sigemptyset() or sigfillset() at least once for each object of type sigset_t prior to any other use of that object. If such an object is not initialized in this way, but is nonetheless supplied as an argument to any of pthread_sigmask(), sigaction(), sigaddset(), sigdelset(), sigismember(), sigpending(), sigprocmask(), sigsuspend(), sigtimedwait(), sigwait(), or sigwaitinfo(), the results are undefined.
|
||||
|
||||
|
||||
void delset_test(sigset_t *sigset, int signal){
|
||||
@@ -19,7 +15,9 @@ void delset_test(sigset_t *sigset, int signal){
|
||||
status = sigismember(sigset, signal);
|
||||
ERROR_IF(sigismember, status, != 1);
|
||||
|
||||
sigdelset(sigset, signal);
|
||||
status = sigdelset(sigset, signal);
|
||||
ERROR_IF(sigdelset, status, != 0);
|
||||
|
||||
status = sigismember(sigset, signal);
|
||||
ERROR_IF(sigismember, status, != 0);
|
||||
|
||||
@@ -31,7 +29,8 @@ int main() {
|
||||
sigfillset(&sigset);
|
||||
|
||||
for (int i = 1; i < N_SIGNALS; i++){
|
||||
delset_test(&sigset, i);
|
||||
int sig = signals_list[i-1].signal;
|
||||
delset_test(&sigset, sig);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
|
||||
|
||||
// test to make sure that if you pass an invalid signal to sigismember it will return EINVAL
|
||||
|
||||
int main() {
|
||||
sigset_t sigset;
|
||||
|
||||
@@ -1,27 +1,22 @@
|
||||
// The sigismember() function shall test whether the signal specified by signo is a member of the set pointed to by set.
|
||||
|
||||
// Applications should call either sigemptyset() or sigfillset() at least once for each object of type sigset_t prior to any other use of that object. If such an object is not initialized in this way, but is nonetheless supplied as an argument to any of pthread_sigmask(), sigaction(), sigaddset(), sigdelset(), sigismember(), sigpending(), sigprocmask(), sigsuspend(), sigtimedwait(), sigwait(), or sigwaitinfo(), the results are undefined.
|
||||
|
||||
|
||||
|
||||
#define _OPEN_SYS
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// The sigismember() function shall test whether the signal specified by signo is a member of the set pointed to by set.
|
||||
|
||||
// Applications should call either sigemptyset() or sigfillset() at least once for each object of type sigset_t prior to any other use of that object. If such an object is not initialized in this way, but is nonetheless supplied as an argument to any of pthread_sigmask(), sigaction(), sigaddset(), sigdelset(), sigismember(), sigpending(), sigprocmask(), sigsuspend(), sigtimedwait(), sigwait(), or sigwaitinfo(), the results are undefined.
|
||||
|
||||
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("%d was not removed from the set", signum);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -34,12 +29,14 @@ int main() {
|
||||
|
||||
sigfillset(&sigset);
|
||||
for (int i=1; i<N_SIGNALS; i++){
|
||||
check_full(sigset, i);
|
||||
int sig = signals_list[i-1].signal;
|
||||
check_full(sigset, sig);
|
||||
}
|
||||
|
||||
sigemptyset(&sigset);
|
||||
for (int i=1; i<N_SIGNALS; i++){
|
||||
check_empty(sigset, i);
|
||||
int sig = signals_list[i-1].signal;
|
||||
check_empty(sigset, sig);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// This program verifies that sigpause() returns -1 and sets errno to EINTR
|
||||
// when it returns.
|
||||
|
||||
#define INMAIN 0
|
||||
#define INTHREAD 1
|
||||
|
||||
@@ -28,7 +31,7 @@ void *d_thread_func(void *sig)
|
||||
{
|
||||
|
||||
int signum = *(int *)sig;
|
||||
printf("%d !!!\n", signum);
|
||||
printf("%d Pausing signal \n", signum);
|
||||
int return_value = 0;
|
||||
struct sigaction act;
|
||||
act.sa_flags = 0;
|
||||
@@ -36,6 +39,9 @@ void *d_thread_func(void *sig)
|
||||
sigemptyset(&act.sa_mask);
|
||||
sigaction(signum, &act, 0);
|
||||
return_value = sigpause(signum);
|
||||
ERROR_IF(sigpause, return_value, != -1);
|
||||
ERROR_IF(sigpause, errno, != EINTR);
|
||||
result = 0;
|
||||
if (return_value == -1) {
|
||||
if (errno == EINTR) {
|
||||
printf ("Test PASSED: sigpause returned -1 and set errno to EINTR\n");
|
||||
@@ -59,21 +65,16 @@ void *d_thread_func(void *sig)
|
||||
|
||||
|
||||
int sigpause_error(int signum){
|
||||
pthread_t new_th;
|
||||
pthread_t new_th;
|
||||
|
||||
if ((pthread_create(&new_th, NULL, d_thread_func, (void *)&signum)) != 0)
|
||||
{
|
||||
perror("Error creating thread\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status;
|
||||
status = pthread_create(&new_th, NULL, d_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);
|
||||
|
||||
sem = INTHREAD;
|
||||
while (sem == INTHREAD)
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// This program verifies that sigpause() returns -1 and sets errno to EINVAL
|
||||
// if passed an invalid signal number.
|
||||
|
||||
#define INMAIN 0
|
||||
#define INTHREAD 1
|
||||
|
||||
@@ -26,6 +29,8 @@ int sigpause_invalid(){
|
||||
int return_value = 0;
|
||||
|
||||
return_value = sigpause(-1);
|
||||
ERROR_IF(sigpause, return_value, != -1);
|
||||
ERROR_IF(sigpause, errno, != EINVAL);
|
||||
if (return_value == -1) {
|
||||
if (errno == EINVAL) {
|
||||
printf ("Test PASSED: sigpause returned -1 and set errno to EINVAL\n");
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#define _XOPEN_SOURCE 700
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
@@ -9,25 +7,31 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// This program verifies that sigpause() removes sig from the signal mask.
|
||||
|
||||
int handler_called = 0;
|
||||
|
||||
void handler() {
|
||||
// printf("signal was called\n");
|
||||
handler_called = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
void *a_thread_func(void *sig)
|
||||
{
|
||||
int status;
|
||||
int signum = *(int *)sig;
|
||||
printf("%d !!!\n", signum);
|
||||
printf("Pausing signal %s\n", signum);
|
||||
struct sigaction act;
|
||||
act.sa_flags = 0;
|
||||
act.sa_handler = handler;
|
||||
sigemptyset(&act.sa_mask);
|
||||
sigaction(signum, &act, 0);
|
||||
sighold(signum);
|
||||
sigpause(signum);
|
||||
status = sigemptyset(&act.sa_mask);
|
||||
ERROR_IF(sigemptyset, status, != 0);
|
||||
status = sigaction(signum, &act, 0);
|
||||
ERROR_IF(sigaction, status, != 0);
|
||||
status = sighold(signum);
|
||||
ERROR_IF(sighold, status, != 0);
|
||||
status = sigpause(signum);
|
||||
ERROR_IF(sigpause, status, != 0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -48,7 +52,10 @@ int sigpause_basic(int signum)
|
||||
|
||||
sleep(1);
|
||||
|
||||
ERROR_IF(pthread_kill, handler_called,, != 1);
|
||||
if (handler_called != 1){
|
||||
prinft("handler wasn't called\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
handler_called = 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
@@ -58,10 +65,11 @@ int sigpause_basic(int signum)
|
||||
|
||||
int main(){
|
||||
for (int i=1; i<N_SIGNALS; i++){
|
||||
if (i == SIGKILL || i == SIGSTOP){
|
||||
int sig = signals_list[i].signal;
|
||||
if (sig == SIGKILL || sig == SIGSTOP){
|
||||
continue;
|
||||
}
|
||||
sigpause_basic(i);
|
||||
sigpause_basic(sig);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// This program verifies that sigpause() restores sig to the signal mask before
|
||||
// returning.
|
||||
|
||||
#define INMAIN 0
|
||||
#define INTHREAD 1
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#define _XOPEN_SOURCE 700
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
@@ -9,6 +7,9 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// This program verifies that sigpause() suspends the calling process
|
||||
// until it receives a signal.
|
||||
|
||||
#define INMAIN 0
|
||||
#define INTHREAD 1
|
||||
|
||||
@@ -19,14 +20,13 @@ int result = 2;
|
||||
int sem = INMAIN;
|
||||
|
||||
void handler() {
|
||||
// printf("signal was called\n");
|
||||
handler_called = 1;
|
||||
return;
|
||||
}
|
||||
void *b_thread_func(void *sig)
|
||||
{
|
||||
int signum = *(int *)sig;
|
||||
printf("%d !!!\n", signum);
|
||||
printf("Pausing signal %s\n", signum);
|
||||
struct sigaction act;
|
||||
act.sa_flags = 0;
|
||||
act.sa_handler = handler;
|
||||
@@ -50,7 +50,6 @@ int sigpause_suspend(int signum)
|
||||
|
||||
for (j=0; j<10; j++) {
|
||||
sleep(1);
|
||||
ERROR_IF(sigpuase, returned, == 1);
|
||||
}
|
||||
|
||||
status = pthread_kill(new_th, signum);
|
||||
@@ -59,6 +58,10 @@ int sigpause_suspend(int signum)
|
||||
sleep(1);
|
||||
|
||||
ERROR_IF(sigpuase, returned, != 1);
|
||||
if (returned != 1){
|
||||
printf("returned != 1 \n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
returned = 0;
|
||||
|
||||
@@ -68,10 +71,11 @@ int sigpause_suspend(int signum)
|
||||
|
||||
int main(){
|
||||
for (int i=1; i<N_SIGNALS; i++){
|
||||
if (i == SIGKILL || i == SIGSTOP){
|
||||
int sig = signals_list[i].signal;
|
||||
if (sig == SIGKILL || sig == SIGSTOP){
|
||||
continue;
|
||||
}
|
||||
sigpause_suspend(i);
|
||||
sigpause_suspend(sig);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// The thread's signal mask shall not be changed, if sigprocmask( ) fails.
|
||||
|
||||
#define NUMSIGNALS 24
|
||||
|
||||
@@ -43,23 +46,18 @@ int main() {
|
||||
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");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int status;
|
||||
status = sigprocmask(r, &actl, NULL);
|
||||
ERROR_IF(sigprocmask, status, != -1);
|
||||
|
||||
sigprocmask(SIG_SETMASK, NULL, &oactl);
|
||||
|
||||
if (sigismember(&oactl, SIGABRT) != 1) {
|
||||
printf("FAIL: signal mask was changed. \n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigismember(&oactl, SIGABRT);
|
||||
ERROR_IF(sigismember, status, != -1);
|
||||
|
||||
if (is_changed(oactl)) {
|
||||
printf("FAIL: signal mask was changed. \n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("PASS: signal mask was not changed.\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -4,8 +4,10 @@
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// I don't understand this test
|
||||
// sigprocmask( ) shall return 0, Upon successful completion; otherwise, it shall return -1
|
||||
// and errno shall be set to indicate the error, and the process' signal mask shall be unchanged.
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// An errno value of [EINVAL] shall be returned and the sigprocmask() function shall fail, if the value of
|
||||
// the how argument is not equal to one of the defined values.
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -41,16 +45,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
sigaddset(&set, SIGABRT);
|
||||
|
||||
if (sigprocmask(r, &set, NULL) == -1) {
|
||||
if (EINVAL == errno) {
|
||||
printf ("errno set to EINVAL\n");
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
printf ("errno not set to EINVAL\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
int status;
|
||||
status = sigprocmask(r, &set, NULL);
|
||||
ERROR_IF(sigprocmask, status, != -1);
|
||||
ERROR_IF(sigprocmask, errno, != EINVAL);
|
||||
// if (sigprocmask(r, &set, NULL) == -1) {
|
||||
// if (EINVAL == errno) {
|
||||
// printf ("errno set to EINVAL\n");
|
||||
// return EXIT_SUCCESS;
|
||||
// } else {
|
||||
// printf ("errno not set to EINVAL\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
// }
|
||||
|
||||
printf("sighold did not return -1\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -4,6 +4,9 @@
|
||||
#include "signals_list.h"
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// The resulting set shall be the union of the current set and the signal
|
||||
// set pointed to by set, if the value of the argument how is SIG_BLOCK.
|
||||
|
||||
int handler_called = 0;
|
||||
|
||||
void sig_handler(int signo)
|
||||
@@ -34,7 +37,7 @@ int sigprocmask_block(int signum)
|
||||
ERROR_IF(sigaction, status, == -1);
|
||||
|
||||
status = sigaction(defaultsig, &act, 0);
|
||||
ERROR_IF(sigaction, status, == -1);
|
||||
ERROR_IF(sigaction, status, == -1);
|
||||
|
||||
status = sigprocmask(SIG_SETMASK, &set1, NULL);
|
||||
ERROR_IF(sigprocmask, status, == -1);
|
||||
@@ -49,7 +52,7 @@ int sigprocmask_block(int signum)
|
||||
handler_called = 0;
|
||||
|
||||
status = raise(defaultsig);
|
||||
ERROR_IF(raise, defualtsig, == -1);
|
||||
ERROR_IF(raise, defaultsig, == -1);
|
||||
|
||||
ERROR_IF(raise, handler_called, == 1);
|
||||
|
||||
@@ -62,7 +65,7 @@ int sigprocmask_block(int signum)
|
||||
status = sigismember(&pending_set, signum);
|
||||
ERROR_IF(sigismemeber, status, != 0);
|
||||
|
||||
printf("Test PASSED: signal was added to the process's signal mask\n");
|
||||
// printf("Test PASSED: signal was added to the process's signal mask\n");
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(signum, &act, 0);
|
||||
sigaction(defaultsig, &act, 0);
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// The previous mask shall be stored in the location pointed to by oset, if the argument oset is not a null pointer.
|
||||
|
||||
|
||||
#define NUMSIGNALS 26
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// The value of the argument how is not significant and the process's signal mask shall be unchanged, and
|
||||
// thus the call can be used to enquire about currently blocked signals, if the argument set is a null
|
||||
// pointer.
|
||||
|
||||
#define NUMSIGNALS 25
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
#include <stdlib.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
// After the call to sigprocmask(), if there are any pending unblocked signals, at least one of those
|
||||
// signals shall be delivered before the call to sigprocmask() returns.
|
||||
|
||||
int handler_called = 0;
|
||||
int sigprocmask_return_val = 1; /* some value that's not a 1 or 0 */
|
||||
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Attempt to add SIGKILL and SIGSTOP to the process's signal mask and
|
||||
// verify that:
|
||||
// - They do not get added.
|
||||
// - sigprocmask() does not return -1.
|
||||
|
||||
int main() {
|
||||
|
||||
sigset_t set1, set2;
|
||||
|
||||
@@ -29,51 +29,35 @@ 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, &blocked_set1, NULL);
|
||||
ERROR_IF(sigprocmask, status, == -1);
|
||||
|
||||
if (sigprocmask(SIG_SETMASK, &blocked_set1, NULL) == -1) {
|
||||
perror("Unexpected error while attempting to use sigprocmask.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigprocmask(SIG_BLOCK, &blocked_set2, NULL);
|
||||
ERROR_IF(sigprocmask, status, == -1);
|
||||
|
||||
if (sigprocmask(SIG_BLOCK, &blocked_set2, NULL) == -1) {
|
||||
perror("Unexpected error while attempting to use sigprocmask.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if ((raise(signum) == -1) | (raise(defaultsig) == -1)) {
|
||||
perror("Unexpected error while attempting to setup test "
|
||||
"pre-conditions");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(raise, signum, == -1);
|
||||
ERROR_IF(raise, defaultsig, == -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) | (sigismember(&pending_set, defaultsig) != 1)) {
|
||||
perror("FAIL: sigismember did not return 1\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = sigismember(&pending_set, signum);
|
||||
ERROR_IF(sigismember, status, != 1);
|
||||
status = sigismember(&pending_set, defaultsig);
|
||||
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);
|
||||
sigaction(defaultsig, &act, 0);
|
||||
|
||||
@@ -14,11 +14,6 @@ void sig_handler(int signo)
|
||||
|
||||
int sigprocmask_block(int signum)
|
||||
{
|
||||
int defaultsig = SIGALRM;
|
||||
(void) defaultsig;
|
||||
if (signum == SIGALRM) {
|
||||
defaultsig = SIGHUP;
|
||||
}
|
||||
struct sigaction act;
|
||||
sigset_t blocked_set, pending_set;
|
||||
sigemptyset(&blocked_set);
|
||||
@@ -38,11 +33,10 @@ int sigprocmask_block(int signum)
|
||||
status = raise(signum);
|
||||
ERROR_IF(raise, status, == -1);
|
||||
|
||||
ERROR_IF(raise, handler_called, == 1);
|
||||
// if (handler_called) {
|
||||
// printf("FAIL: Signal was not blocked\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
if (handler_called) {
|
||||
printf("FAIL: Signal was not blocked\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
status = sigpending(&pending_set);
|
||||
ERROR_IF(sigpending, status, == -1);
|
||||
@@ -58,10 +52,11 @@ int sigprocmask_block(int signum)
|
||||
|
||||
int main(){
|
||||
for (int i=1; i<N_SIGNALS; i++){
|
||||
if (i == SIGKILL || i == SIGSTOP){
|
||||
int sig = signals_list[i-1].signal;
|
||||
if (sig == SIGKILL || sig == SIGSTOP){
|
||||
continue;
|
||||
}
|
||||
sigprocmask_block(i);
|
||||
sigprocmask_block(sig);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+23
-27
@@ -25,40 +25,36 @@ int sigrelse_test(int signum)
|
||||
act.sa_handler = sig_handler;
|
||||
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);
|
||||
|
||||
sighold(signum);
|
||||
|
||||
if (raise(signum) == -1) {
|
||||
perror("Unexpected error while attempting to setup test "
|
||||
"pre-conditions");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (handler_called) {
|
||||
printf("UNRESOLVED. possible problem in sigrelse\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
status = raise(signum);
|
||||
ERROR_IF(raise, status, == -1);
|
||||
|
||||
if (sigrelse(signum) == -1) {
|
||||
printf("UNRESOLVED. possible problem in sigrelse\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ERROR_IF(raise, handler_called, == 1);
|
||||
// if (handler_called) {
|
||||
// printf("UNRESOLVED. possible problem in sigrelse\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
|
||||
status = sigrelse(signum);
|
||||
ERROR_IF(sigrelse, status, == -1);
|
||||
|
||||
sleep(1);
|
||||
|
||||
if (handler_called) {
|
||||
printf("PASS: %d successfully removed from signal mask\n", signum);
|
||||
handler_called = 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
printf("FAIL\n");
|
||||
exit(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
ERROR_IF(sigrelse, handler_called, != 1);
|
||||
// if (handler_called) {
|
||||
// printf("PASS: %d successfully removed from signal mask\n", signum);
|
||||
// handler_called = 0;
|
||||
// return EXIT_SUCCESS;
|
||||
// }
|
||||
// printf("FAIL\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#define _XOPEN_SOURCE 700
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include "../test_helpers.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user