Usermode/GUI Terminal - Fixed title support, added a unit test
[tpg/acess2.git] / Usermode / Applications / gui_terminal_src / UTEST / test_common.c
1 /*
2  */
3 #include "test_common.h"
4 #include <stdio.h>
5 #include <setjmp.h>
6 #include <stdarg.h>
7
8 // === GLOBALS ===
9 int     gbDebugEnabled = 0;
10 jmp_buf gTest_FailJump;
11
12 // === CODE ===
13 int main(int argc, char *argv[])
14 {
15          int    nFail = 0;
16         for( int i = 0; i < giNumTests; i ++ )
17         {
18                 tTEST   *test = &gaTests[i];
19                 fprintf(stderr, "Test [%i] \"%s\": ", i, test->Name);
20                 if( test->Setup && test->Setup() != 0 ) {
21                         fprintf(stderr, "ERROR\n");
22                 }
23                 else {
24                         int res = setjmp(gTest_FailJump);
25                         if( res == 0 )
26                                 test->Run();
27                         
28                         if(test->Teardown)
29                                 test->Teardown();
30                         if( res == 0 )
31                                 fprintf(stderr, "PASS\n");
32                         else
33                                 nFail ++;
34                 }
35         }
36         return nFail;
37 }
38
39 void TestFailure(const char *ReasonFmt, ...)
40 {
41         va_list args;
42         va_start(args, ReasonFmt);
43         fprintf(stderr, "FAILURE: ");
44         vfprintf(stderr, ReasonFmt, args);
45         fprintf(stderr, "\n");
46         va_end(args);
47         longjmp(gTest_FailJump, 1);
48 }
49
50 void _SysDebug(const char *Format, ...)
51 {
52         if( gbDebugEnabled )
53         {
54                 va_list args;
55                 va_start(args, Format);
56                 printf("_SysDebug: ");
57                 vprintf(Format, args);
58                 printf("\n");
59                 va_end(args);
60         }
61 }

UCC git Repository :: git.ucc.asn.au