flexcat 2.15 is picky.
[AROS.git] / test / dos / isinteractive.c
blob8bc8551e70159a29e11e279efc81eafdaeed4c3f
1 /*
2 * Copyright (C) 2011, The AROS Development Team. All rights reserved.
3 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
5 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
6 */
8 #include <aros/debug.h>
9 #include <proto/alib.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
13 #include <dos/stdio.h>
14 #include <exec/lists.h>
16 #ifdef __mc68000
17 /* For compatability with AOS, our test reference */
18 static AROS_UFH2(VOID, _SPutC,
19 AROS_UFHA(BYTE, c, D0),
20 AROS_UFHA(BYTE **, ptr, A3))
22 AROS_USERFUNC_INIT
24 **ptr = c;
26 (*ptr)++;
28 AROS_USERFUNC_EXIT
31 VOID SPrintf( char *target, const char *format, ...)
33 RawDoFmt( format, (APTR)&(((ULONG *)&format)[1]), _SPutC, &target);
35 #else
36 #define SPrintf(buff,format,args...) __sprintf(buff,format ,##args )
37 #endif
39 #define TEST_START(name) do { \
40 CONST_STRPTR test_name = #name ; \
41 struct List expr_list; \
42 int failed = 0; \
43 tests++; \
44 NEWLIST(&expr_list);
46 #define VERIFY_EQ(retval, expected) \
47 do { \
48 __typeof__(retval) val = retval; \
49 if (val != (expected)) { \
50 static char buff[128]; \
51 static struct Node expr_node; \
52 SPrintf(buff, "%s (%ld) != %ld", #retval , (LONG)val, (LONG)expected); \
53 expr_node.ln_Name = buff; \
54 AddTail(&expr_list, &expr_node); \
55 failed |= 1; \
56 } \
57 } while (0)
59 #define VERIFY_RET(func, ret, reterr) \
60 do { \
61 SetIoErr(-1); \
62 VERIFY_EQ(func, ret); \
63 VERIFY_EQ(IoErr(), reterr); \
64 } while (0)
66 #define TEST_END() \
67 if (failed) { \
68 struct Node *node; \
69 tests_failed++; \
70 Printf("Test %ld: Failed (%s)\n", (LONG)tests, test_name); \
71 ForeachNode(&expr_list, node) { \
72 Printf("\t%s\n", node->ln_Name); \
73 } \
74 } \
75 } while (0)
77 int main(int argc, char **argv)
79 BPTR fd;
80 int tests = 0, tests_failed = 0;
82 TEST_START("fd = BNULL");
83 fd = BNULL;
84 VERIFY_RET(IsInteractive(fd), DOSFALSE, -1);
85 TEST_END();
87 TEST_START("fd = Open(\"NIL:\", MODE_OLDFILE)");
88 fd = Open("NIL:", MODE_OLDFILE);
89 VERIFY_RET(IsInteractive(fd), DOSFALSE, -1);
90 Close(fd);
91 TEST_END();
93 TEST_START("fd = Open(\"NIL:\", MODE_NEWFILE)");
94 fd = Open("NIL:", MODE_NEWFILE);
95 VERIFY_RET(IsInteractive(fd), DOSFALSE, -1);
96 Close(fd);
97 TEST_END();
99 TEST_START("fd = Open(\"CON:0/0/100/100/Test/CLOSE/AUTO\", MODE_OLDFILE)");
100 fd = Open("CON:0/0/100/100/Test/CLOSE/AUTO", MODE_OLDFILE);
101 VERIFY_RET(IsInteractive(fd), DOSTRUE, -1);
102 Close(fd);
103 TEST_END();
105 return 0;