Make test3 fail on the first error.
[minix.git] / test / kernel / sys_vumap / vumaprelay.c
blob9702dc1ce2735d831748067d62794039aaa0908f
1 /* Test for sys_vumap() - by D.C. van Moolenbroek */
2 #include <minix/drivers.h>
3 #include <assert.h>
5 #include "com.h"
7 static int do_request(message *m)
9 struct vumap_vir vvec[MAPVEC_NR + 3];
10 struct vumap_phys pvec[MAPVEC_NR + 3];
11 int r, r2, access, vcount, pcount;
12 size_t offset;
14 assert(m->m_type == VTR_RELAY);
16 vcount = m->VTR_VCOUNT;
17 pcount = m->VTR_PCOUNT;
18 offset = m->VTR_OFFSET;
19 access = m->VTR_ACCESS;
21 r2 = sys_safecopyfrom(m->m_source, m->VTR_VGRANT, 0, (vir_bytes) vvec,
22 sizeof(vvec[0]) * vcount);
23 assert(r2 == OK);
25 r = sys_vumap(m->m_source, vvec, vcount, offset, access, pvec,
26 &pcount);
28 if (pcount >= 1 && pcount <= MAPVEC_NR + 3) {
29 r2 = sys_safecopyto(m->m_source, m->VTR_PGRANT, 0,
30 (vir_bytes) pvec, sizeof(pvec[0]) * pcount);
31 assert(r2 == OK);
34 m->VTR_PCOUNT = pcount;
36 return r;
39 static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
41 return OK;
44 static void sef_cb_signal_handler(int sig)
46 if (sig == SIGTERM)
47 exit(0);
50 static void sef_local_startup(void)
52 sef_setcb_init_fresh(sef_cb_init_fresh);
53 sef_setcb_signal_handler(sef_cb_signal_handler);
55 sef_startup();
58 int main(int argc, char **argv)
60 message m;
61 int r;
63 env_setargs(argc, argv);
65 sef_local_startup();
67 for (;;) {
68 if ((r = sef_receive(ANY, &m)) != OK)
69 panic("sef_receive failed (%d)\n", r);
71 m.m_type = do_request(&m);
73 send(m.m_source, &m);
76 return 0;