Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Slight clarification of variable names
[simgrid.git] / win32_test_app / src / TTestRunner.c
1 #include <TTestRunner.h>
2
3
4 /* 
5  * Create an new s_TestRunner struct and 
6  * returns a pointer to self.
7  */
8 TestRunner_t TestRunner_new(void)
9 {
10         TestRunner_t ptr = calloc(1,sizeof(s_TestRunner_t));
11         
12         if(NULL == ptr){
13                 setErrno(E_TEST_RUNNER_ALLOCATION_FAILED);
14                 return NULL;
15         }
16         
17         ptr->buffer = Buffer_new();
18         
19         if(NULL == ptr->buffer){
20                 TestRunner_free(ptr);
21                 return NULL;
22         }
23         
24         ptr->testSuite = TestSuite_new();
25         
26         if(NULL == ptr->testSuite){
27                 TestRunner_free(ptr);
28                 return NULL;
29         }
30                  
31         setErrno(E_SUCCESS);
32         return ptr;
33 }
34
35 /* 
36  * Initialize the s_TestRunner struct 
37  * by processing the command line.
38  */
39 errno_t TestRunner_initialize(TestRunner_t runner,int argc,char *argv[])
40 {
41         if(E_SUCCESS != TestSuite_initialize(runner->testSuite,argc,argv))
42                 return getErrno();
43                 
44         return E_SUCCESS;       
45 }
46
47 /* 
48  * Launch the test runner.
49  */
50 void TestRunner_run(TestRunner_t runner)
51 {
52         TestSuite_run(runner->testSuite);
53 }
54
55 /* 
56  * Free the s_TestRunner.
57  */
58 void TestRunner_free(TestRunner_t runner)
59 {
60         if(NULL == runner)
61                 return;
62         
63         if(NULL != runner->buffer)
64                 Buffer_free(runner->buffer);
65                 
66         if(NULL != runner->testSuite)
67                 TestSuite_free(runner->testSuite);
68 }
69
70