Added some (default) icons for files/dirs used by boot floppies.
[cake.git] / test / devicetest.c
blob02eb8d5b193ef3b4e2425069e95bf468e45ca363
1 /*
2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
7 #include <exec/resident.h>
8 #include <exec/execbase.h>
9 #include <exec/io.h>
10 #include <aros/libcall.h>
11 #include <clib/exec_protos.h>
12 #include <stdio.h>
13 #include "dummydev_gcc.h"
15 extern const struct Resident resident;
17 int main(void)
19 int r1=0,r2=0,r3=0,e1=0,e2=0,e31=0,e32=0;
20 struct dummybase *dummy;
22 if(!(resident.rt_Flags&RTF_AUTOINIT))
23 return 20;
24 dummy=(struct dummybase *)MakeLibrary(((APTR *)resident.rt_Init)[1],
25 ((APTR *)resident.rt_Init)[2],
26 ((APTR *)resident.rt_Init)[3],
27 (IPTR)((APTR *)resident.rt_Init)[0],1);
28 if(dummy!=NULL)
30 Forbid();
31 if(FindName(&SysBase->DeviceList,(STRPTR)&dummy->device.dd_Library.lib_Node.ln_Name)==NULL)
33 AddDevice(&dummy->device);
35 struct MsgPort *port;
36 struct dummyrequest *dr;
38 port=CreateMsgPort();
39 if(port!=NULL)
41 dr=(struct dummyrequest *)CreateIORequest(port,sizeof(struct dummyrequest));
42 if(dr!=NULL)
44 if(!OpenDevice("dummy.device",0,(struct IORequest *)dr,0))
46 dr->iorequest.io_Command=0x1;
47 DoIO((struct IORequest *)dr);
48 r1=dr->id;
49 e1=dr->iorequest.io_Error;
50 dr->iorequest.io_Command=0x1;
51 SendIO((struct IORequest *)dr);
52 WaitIO((struct IORequest *)dr);
53 r2=dr->id;
54 e2=dr->iorequest.io_Error;
55 dr->iorequest.io_Command=0x1;
56 SendIO((struct IORequest *)dr);
57 e31=AbortIO((struct IORequest *)dr);
58 WaitIO((struct IORequest *)dr);
59 r3=dr->id;
60 e32=dr->iorequest.io_Error;
62 CloseDevice((struct IORequest *)dr);
64 DeleteIORequest((struct IORequest *)dr);
66 DeleteMsgPort(port);
69 /* Don't use RemLibrary() - it calls UnLoadSeg(). */
70 Remove(&dummy->device.dd_Library.lib_Node);
72 Permit();
73 FreeMem((char *)dummy-dummy->device.dd_Library.lib_NegSize,
74 dummy->device.dd_Library.lib_NegSize+dummy->device.dd_Library.lib_PosSize);
76 printf("Synchronous:\t%d (%d)\n",r1,e1);
77 printf("Asynchronous:\t%d (%d)\n",r2,e2);
78 printf("Aborted:\t%d (%d,%d)\n",r3,e31,e32);
80 return 0;