use the standard AROS cause
[AROS.git] / test / dos / nil.c
blob2aaddaf81ea21eeb28846187313678eb42362f89
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/dos.h>
7 #include <stdio.h>
8 #include "test.h"
11 BPTR nilfh = BNULL;
12 BPTR nillock = BNULL;
14 static void closehandles()
16 if (nilfh != BNULL) Close(nilfh);
17 if (nillock != BNULL) UnLock(nillock);
18 nilfh = BNULL;
19 nillock = BNULL;
21 int main()
23 TEXT buffer[20];
24 LONG result = 0;
25 BPTR bresult = BNULL;
27 /* Open */
28 nilfh = Open("NIL:", MODE_OLDFILE);
29 TEST((nilfh !=BNULL));
30 closehandles();
32 nilfh = Open("NIL:", MODE_NEWFILE);
33 TEST((nilfh !=BNULL));
34 closehandles();
36 nilfh = Open("NIL:", MODE_READWRITE);
37 TEST((nilfh !=BNULL));
38 closehandles();
41 /* Lock */
42 nillock = Lock("NIL:", SHARED_LOCK);
43 TEST((nillock == BNULL));
44 closehandles();
46 nillock = Lock("NIL:", EXCLUSIVE_LOCK);
47 TEST((nillock == BNULL));
48 closehandles();
50 /* DupLockFromFH */
51 nilfh = Open("NIL:", MODE_OLDFILE);
52 nillock = DupLockFromFH(nilfh);
53 Close(nilfh);
54 nilfh = BNULL;
55 TEST((nillock != BNULL));
57 /* OpenFromLock */
58 nilfh = OpenFromLock(nillock);
59 nillock = BNULL; /* Lock was consumed when opening */
60 TEST((nilfh != BNULL));
61 closehandles();
63 /* Write */
64 nilfh = Open("NIL:", MODE_OLDFILE);
65 result = Write(nilfh, buffer, sizeof(buffer));
66 TEST ((result == sizeof(buffer)));
67 closehandles();
69 /* Info */
70 nilfh = Open("NIL:", MODE_OLDFILE);
71 nillock = DupLockFromFH(nilfh);
72 result = Info(nillock, NULL);
73 TEST((result == 0));
74 closehandles();
76 /* ParentOfFH */
77 nilfh = Open("NIL:", MODE_OLDFILE);
78 bresult = ParentOfFH(nilfh);
79 TEST((bresult == BNULL));
80 closehandles();
82 cleanup();
84 return OK;
87 void cleanup()
89 closehandles();