Regression tests for RAS. Tests the basic functionality including

forking and execing.
This commit is contained in:
gmcgarry 2002-08-28 07:47:18 +00:00
parent 2468902b58
commit 3ee9d48c4d
7 changed files with 213 additions and 0 deletions

View File

@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2002/08/28 07:47:18 gmcgarry Exp $
SUBDIR+= ras1 ras2 ras3
.include <bsd.subdir.mk>

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2002/08/28 07:47:20 gmcgarry Exp $
PROG= ras1
NOMAN= #defined
WARNS= 2
regress:
@if ./${PROG} ; then \
echo "PASSED"; \
else \
echo "FAILED"; \
fi
.include <bsd.prog.mk>

View File

@ -0,0 +1,48 @@
#include <stdio.h>
#include <signal.h>
#include <sys/ras.h>
#include <sys/time.h>
#define COUNT 10
__volatile int handled = 0;
__volatile int count = 0;
struct itimerval itv;
void handler(int);
void
handler(int sig)
{
handled++;
}
int
main(void)
{
signal(SIGVTALRM, handler);
itv.it_interval.tv_sec = 0;
itv.it_interval.tv_usec = 0;
itv.it_value.tv_sec = 10;
itv.it_value.tv_usec = 0;
setitimer(ITIMER_VIRTUAL, &itv, NULL);
if (rasctl((caddr_t)&&start, (caddr_t)&&end - (caddr_t)&&start,
RAS_INSTALL) < 0)
return (1);
start:
count++;
if (count > COUNT)
goto end;
while (!handled) {
continue;
}
end:
return (handled != 0);
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2002/08/28 07:47:24 gmcgarry Exp $
PROG= ras2
NOMAN= #defined
WARNS= 2
regress:
@if ./${PROG} ; then \
echo "PASSED"; \
else \
echo "FAILED"; \
fi
.include <bsd.prog.mk>

View File

@ -0,0 +1,56 @@
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/ras.h>
#include <sys/time.h>
#include <sys/wait.h>
#define COUNT 10
__volatile int handled = 0;
__volatile int count = 0;
struct itimerval itv;
void handler(int);
void
handler(int sig)
{
handled++;
}
int
main(void)
{
int rv;
signal(SIGVTALRM, handler);
itv.it_interval.tv_sec = 0;
itv.it_interval.tv_usec = 0;
itv.it_value.tv_sec = 10;
itv.it_value.tv_usec = 0;
setitimer(ITIMER_VIRTUAL, &itv, NULL);
if (rasctl((caddr_t)&&start, (caddr_t)&&end - (caddr_t)&&start,
RAS_INSTALL) < 0)
return (1);
if (fork() != 0) {
wait(&rv);
return (rv);
}
start:
count++;
if (count > COUNT)
goto end;
while (!handled) {
continue;
}
end:
return (handled != 0);
}

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2002/08/28 07:47:27 gmcgarry Exp $
PROG= ras3
NOMAN= #defined
WARNS= 2
regress:
@if ./${PROG} ; then \
echo "PASSED"; \
else \
echo "FAILED"; \
fi
.include <bsd.prog.mk>

View File

@ -0,0 +1,62 @@
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/ras.h>
#include <sys/time.h>
#include <sys/wait.h>
#define COUNT 10
__volatile int handled = 0;
__volatile int count = 0;
struct itimerval itv;
void handler(int);
void
handler(int sig)
{
handled++;
}
int
main(int argc, char *argv[])
{
int rv;
char *const args[] = { argv[0], "1", NULL };
signal(SIGVTALRM, handler);
itv.it_interval.tv_sec = 0;
itv.it_interval.tv_usec = 0;
itv.it_value.tv_sec = 10;
itv.it_value.tv_usec = 0;
setitimer(ITIMER_VIRTUAL, &itv, NULL);
if (argc != 2) {
if (rasctl((caddr_t)&&start, (caddr_t)&&end - (caddr_t)&&start,
RAS_INSTALL) < 0)
return (1);
if (fork() != 0) {
wait(&rv);
return (rv == 0);
}
if (execvp(argv[0],args) < 0) {
printf("exec failed\n");
return (0);
}
}
start:
count++;
if (count > COUNT)
goto end;
while (!handled) {
continue;
}
end:
return (handled != 0);
}