Add a ucontext test from Nathan's testsuite.

This commit is contained in:
thorpej 2003-01-30 19:47:00 +00:00
parent a1c259efd5
commit 8139d13ab9
3 changed files with 51 additions and 2 deletions

View File

@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.20 2002/11/30 09:31:31 jdolecek Exp $
# $NetBSD: Makefile,v 1.21 2003/01/30 19:47:00 thorpej Exp $
SUBDIR+= execve extent getcwd ipf kqueue lock lockf pipe poll ras \
sigtramp sysvmsg sysvsem sysvshm unfdpass writev
sigtramp sysvmsg sysvsem sysvshm ucontext unfdpass writev
.include <bsd.subdir.mk>

View File

@ -0,0 +1,13 @@
# $NetBSD: Makefile,v 1.1 2003/01/30 19:47:00 thorpej Exp $
WARNS=1
PROG= context
SRCS= context.c
NOMAN=
regress:
./context
.include <bsd.prog.mk>

View File

@ -0,0 +1,36 @@
/* $NetBSD: context.c,v 1.1 2003/01/30 19:47:00 thorpej Exp $ */
#include <assert.h>
#include <stdio.h>
#include <ucontext.h>
int
main(int argc, char *argv[])
{
ucontext_t u, v, w;
volatile int x, y;
x = 0;
y = 0;
printf("Start\n");
getcontext(&u);
y++;
printf(" X is %d\n", x);
getcontext(&v);
if ( x < 20 ) {
x++;
getcontext(&w);
printf("Adding one and going around.\n");
setcontext(&u);
}
printf("End, y = %d\n", y);
assert(y == 21);
return 0;
}