Test set for sys_vumap()

Located in test/kernel. Invoke "run" to run tests.
This commit is contained in:
David van Moolenbroek 2012-03-18 02:07:18 +01:00
parent b91295a8d2
commit cf720a028a
8 changed files with 1551 additions and 0 deletions

5
test/kernel/run Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
tests="sys_vumap"
for i in $tests; do (cd $i && ./run); done

View file

@ -0,0 +1,14 @@
# Makefile for the sys_vumap test.
PROG= vumaptest vumaprelay
SRCS.vumaptest= vumaptest.c
SRCS.vumaprelay= vumaprelay.c
DPADD+= ${LIBSYS}
LDADD+= -lsys
MAN=
BINDIR?= /usr/sbin
.include "Makefile.inc"
.include <minix.service.mk>

View file

@ -0,0 +1,5 @@
# Copied from drivers/Makefile.inc
CPPFLAGS+= -D_MINIX -D_NETBSD_SOURCE
LDADD+= -lminlib -lcompat_minix
DPADD+= ${LIBMINLIB} ${LIBCOMPAT_MINIX}
BINDIR?=/usr/sbin

View file

@ -0,0 +1,13 @@
#ifndef _VUMAP_COM_H
#define _VUMAP_COM_H
#define VTR_RELAY 0x3000 /* SYS_VUMAP relay request */
#define VTR_VGRANT m10_l1 /* grant for virtual vector */
#define VTR_VCOUNT m10_i1 /* nr of elements in virtual vector */
#define VTR_OFFSET m10_l2 /* offset into first element */
#define VTR_ACCESS m10_i2 /* access flags (VUA_) */
#define VTR_PGRANT m10_l3 /* grant for physical vector */
#define VTR_PCOUNT m10_i3 /* nr of physical elements (in/out) */
#endif /* _VUMAP_COM_H */

16
test/kernel/sys_vumap/run Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh
make >/dev/null
echo -n "Kernel test (sys_vumap): "
service up `pwd`/vumaprelay -config system.conf -label vumaprelay -script /etc/rs.single
service up `pwd`/vumaptest -config system.conf -script /etc/rs.single 2>/dev/null
r=$?
service down vumaprelay
if [ $r -ne 0 ]; then
echo "failure"
exit 1
fi
echo "ok"

View file

@ -0,0 +1,12 @@
service vumaptest {
system
UMAP # 14
VUMAP # 18
;
};
service vumaprelay {
system
VUMAP # 18
;
};

View file

@ -0,0 +1,77 @@
/* Test for sys_vumap() - by D.C. van Moolenbroek */
#include <minix/drivers.h>
#include <assert.h>
#include "com.h"
PRIVATE int do_request(message *m)
{
struct vumap_vir vvec[MAPVEC_NR + 3];
struct vumap_phys pvec[MAPVEC_NR + 3];
int r, r2, access, vcount, pcount;
size_t offset;
assert(m->m_type == VTR_RELAY);
vcount = m->VTR_VCOUNT;
pcount = m->VTR_PCOUNT;
offset = m->VTR_OFFSET;
access = m->VTR_ACCESS;
r2 = sys_safecopyfrom(m->m_source, m->VTR_VGRANT, 0, (vir_bytes) vvec,
sizeof(vvec[0]) * vcount, D);
assert(r2 == OK);
r = sys_vumap(m->m_source, vvec, vcount, offset, access, pvec,
&pcount);
if (pcount >= 1 && pcount <= MAPVEC_NR + 3) {
r2 = sys_safecopyto(m->m_source, m->VTR_PGRANT, 0,
(vir_bytes) pvec, sizeof(pvec[0]) * pcount, D);
assert(r2 == OK);
}
m->VTR_PCOUNT = pcount;
return r;
}
PRIVATE int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
{
return OK;
}
PRIVATE void sef_cb_signal_handler(int sig)
{
if (sig == SIGTERM)
exit(0);
}
PRIVATE void sef_local_startup(void)
{
sef_setcb_init_fresh(sef_cb_init_fresh);
sef_setcb_signal_handler(sef_cb_signal_handler);
sef_startup();
}
PUBLIC int main(int argc, char **argv)
{
message m;
int r;
env_setargs(argc, argv);
sef_local_startup();
for (;;) {
if ((r = sef_receive(ANY, &m)) != OK)
panic("sef_receive failed (%d)\n", r);
m.m_type = do_request(&m);
send(m.m_source, &m);
}
return 0;
}

File diff suppressed because it is too large Load diff