correctly split the ipi into source/msg components.
[AROS.git] / test / runtests.c
blobf861b38f3d2658a3c61884aafda3c4f2fb0d39b4
1 /*
2 Copyright (C) 2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /******************************************************************************
8 NAME
10 runtests
12 SYNOPSIS
14 scriptname
16 LOCATION
18 SYS:Tests
20 FUNCTION
22 Executes all commands given by an input script. Reports memory loss
23 and summarizes the return codes. The commands shouldn't do any
24 output on success to avoid increasing of the shell's buffer.
25 The result is printed to the debugging console.
27 INPUTS
29 scriptname -- script with the programs to be executed. Defaults to
30 "testscript".
32 RESULT
34 NOTES
36 EXAMPLE
38 BUGS
40 SEE ALSO
42 INTERNALS
44 HISTORY
46 ******************************************************************************/
48 #include <aros/debug.h>
49 #include <proto/dos.h>
50 #include <proto/exec.h>
52 BPTR scripthandle;
53 CONST_STRPTR scriptname;
54 UBYTE command[200];
55 LONG error;
56 LONG failcnt;
57 LONG errorcnt;
58 LONG warncnt;
59 LONG okcnt;
60 LONG noshellcnt;
61 LONG rubbishcnt;
63 static ULONG checkmem(void)
65 FreeVec(AllocVec((ULONG)(~0ul/2), MEMF_ANY)); // trigger expunges
66 return AvailMem(MEMF_ANY);
69 int main(int argc, char **argv)
71 ULONG mem_old, mem;
73 if (argc == 1)
75 scriptname = "testscript";
77 else if (argc == 2)
79 scriptname = argv[1];
81 else
83 PutStr("Usage runtest [scriptfile]\n");
86 scripthandle = Open(scriptname, MODE_OLDFILE);
87 if (!scripthandle)
89 PutStr("Can't open file\n");
90 return 0;
93 PutStr("Reading commands from file ");
94 PutStr(scriptname);
95 PutStr("\nOutput will be sent to the debugging console\n\n");
97 while (FGets(scripthandle, command, sizeof command))
99 if (command[0] != '#' && command[0] != '\n')
101 bug("====================================\n");
102 bug("Running command: %s", command);
104 mem_old = checkmem();
105 error = SystemTagList(command, NULL);
106 mem = checkmem();
108 bug("returns: %d\n", error);
110 if (mem != mem_old)
112 bug("Memory loss %ul Bytes\n", mem_old - mem);
115 if (error == -1)
116 noshellcnt++;
117 else if (error > 100 || error < 0)
118 rubbishcnt++;
119 else if (error >= RETURN_FAIL)
120 failcnt++;
121 else if (error >= RETURN_ERROR)
122 errorcnt++;
123 else if (error >= RETURN_WARN)
124 warncnt++;
125 else
126 okcnt++;
129 bug("====================================\n");
130 bug("Summary: ok %d, warn %d, error %d, fail %d, no Shell %d, rubbish %d\n",
131 okcnt, warncnt, errorcnt, failcnt, noshellcnt, rubbishcnt);
133 Close(scripthandle);
135 return 0;