clean up more tests

This commit is contained in:
Josh Williams
2025-01-23 19:34:51 -08:00
committed by 4lDO2
parent 6f787d20e5
commit a7e9135bc9
5 changed files with 17 additions and 22 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ int main()
for (int i = 1; i < sizeof(signals_list)/sizeof(signals_list[0]); i++)
{
int sig = signals_list[i].signal;
if (sig == SIGKILL || i == SIGSTOP)
if (sig == SIGKILL || sig == SIGSTOP)
{
continue;
}
+10 -6
View File
@@ -5,10 +5,12 @@
#include "signals_list.h"
#include "../test_helpers.h"
// this test is to make sure that when a negative pid is supplied to kill, all the processes in that group will be killed
int handler_called = 0;
void sig_handler(int signo)
{
printf("Caught signal %d being tested!\n", signo);
printf("Test PASSED\n");
handler_called = 1;
return;
}
@@ -24,18 +26,20 @@ int kill_group(int signum)
ERROR_IF(sigemptyset, status, == -1);
status = sigaction(signum, &act, 0);
ERROR_IF(sigaction, staus, == -1);
ERROR_IF(sigaction, status, == -1);
staus = getpgrp();
status = getpgrp();
ERROR_IF(getpgrp, status, == -1);
status = kill(-pgrp, signum);
ERROR_IF(kill, staus, != 0);
ERROR_IF(kill, status, != 0);
ERROR_IF(kill, handler_called, !=1);
handler_called = 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++)
+4 -2
View File
@@ -6,13 +6,15 @@
#include <sys/types.h>
#include "../test_helpers.h"
// makes sure that a process is not killed if the user doesn't have permission to kill the process
int main(void)
{
int status;
// This is added incase user is root. If user is normal user, then it has no effect on the tests
// This is added in case 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);
ERROR_IF(kill, errno, != EPERM);
return EXIT_SUCCESS;
}
+1 -1
View File
@@ -68,7 +68,7 @@ int main(){
for (unsigned int i = 1; i < sizeof(signals_list)/sizeof(signals_list[0]); i++)
{
int sig = signals_list[i].signal;
if (sig == SIGKILL || sig == SIGSTOP || sig == SIGCHLD)
if (sig == SIGKILL || sig == SIGSTOP || sig == SIGCHLD || sig == SIGINT || sig == SIGQUIT)
{
continue;
}
+1 -12
View File
@@ -1,9 +1,8 @@
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <errno.h>
#include "../test_helpers.h"
int main()
{
@@ -12,14 +11,4 @@ int main()
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);
// }
// }
}