Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a special file used by builder compilers
[simgrid.git] / win32_test_app / include / TTestCaseContext.h
1 #ifndef __TestCaseContext_H__
2 #define __TestCaseContext_H__
3
4 #include <TBuffer.h>
5 #include <windows.h>
6
7 /* 
8  * Declaration a the s_TestCaseContext structure 
9  * which represents the context of a test case during his
10  * execution.
11  */
12 typedef struct s_TestCaseContext
13 {
14         char* name;                                                             /* the test case name                                                                   */
15         int timeoutValue;                                               /* the timeout value                                                                    */
16         bool isOutputCheckingEnabled;                   /* if true, output checking is enable                                   */
17         bool isPostOutputCheckingEnabled;               /* if true, the post output checking mode is enable             */
18         Buffer_t inputBuffer;                                   /* buffer that contains child input                                             */
19         Buffer_t outputBuffer;                                  /* the child output buffer                                                              */
20         Buffer_t expectedOutputBuffer;          /* buffer that contains child expected output                   */
21         int expectedExitCode;                                   /* the child expected exit code                                                 */
22         int threadExitCode;                                     /* the thread exit code                                                                                         */
23         int exitCode;                                                   /* the child process exit code                                                                          */
24     bool runThread;                                             /* false if the thread of the test case must terminate                          */      
25         HANDLE hThread;                                                 /* the handle of the thread                                                                                     */                      
26         HANDLE hOutputRead;                                             /* handle to the read pipe                                                                                      */
27         HANDLE hInputWrite;                                             /* handle to the write pipe                                                                                     */
28         HANDLE hChildStdInRead;                                 /* handle to the pipe used to read the child std input                          */ 
29         HANDLE hChildStdOutWrite;                               /* handle to the pipe used to write to the chil std output                      */
30         HANDLE hChildStderr;                                    /* handle to the pipe used to read the child std error                          */
31         PROCESS_INFORMATION pi;                                 /* this structure contains child process informations                           */ 
32         HANDLE hChildStdoutReadTmp;                             /* tempory handle                                                                                                       */
33         HANDLE hChildStdinWriteTmp;                             /* tempory handle                                                                                                       */
34     bool createConsole;                    /* true if we can create a console for the child process            */
35     bool exitCodeCheckingEnabled;         /* true if we want to check the child exit code                     */
36     HANDLE hConsole;                        /* handle to the console                                            */
37     bool started;                           /* true if the child process started                                */
38     Buffer_t commandLineBuffer;                 /* command line buffer                                              */
39
40 }s_TestCaseContext_t,* TestCaseContext_t;
41
42 /* Output checking is disabled by default*/
43 #define DEFAULT_OUTPUT_CHECKING_MODE            false
44
45 /* Post output checking mode is disabled by default*/
46 #define DEFAULT_POST_OUTPUT_CHECKING_MODE       false
47
48 /* The default timeout value is 5 seconds*/
49  #define DEFAULT_TIMEOUT_VALUE                          ((int)120000)
50  
51 /* Invalid exit code value (default value)*/
52 #define INVALID_EXIT_CODE                                       ((int)0xFFFFFF)
53
54 /* 
55  * s_TestCaseContext struct connected functions.
56  */
57
58 /* 
59  * Create a new s_TestCaseContext and returns a pointer to self.
60  */
61 TestCaseContext_t TestCaseContext_new(void);
62
63 /* 
64  * Destroy the s_TestCaseContext referenced by context. 
65  */
66 void TestCaseContext_free(TestCaseContext_t context);
67
68 /* 
69  * Clear the s_TestCaseContext referenced by context.
70  */
71 void TestCaseContext_clear(TestCaseContext_t context);
72
73 /* 
74  * Set the timeout of the test case context.
75  */
76 void TestCaseContext_setTimeout(TestCaseContext_t context,int timeout);
77
78 /*
79  * Enable the output checking of the test case context.
80  */
81 void TestCaseContext_enableOutputChecking(TestCaseContext_t context);
82
83 /*
84  * Disable the output checking of the test case context.
85  */
86 void TestCaseContext_disableOutputChecking(TestCaseContext_t context);
87
88 /*
89  * Enable the post output checking of the test case context.
90  */
91 void TestCaseContext_enable_post_output_checking(TestCaseContext_t context);
92
93 /*
94  * Disable the post output checking of the test case context.
95  */
96 void TestCaseContext_disablePostOutputChecking(TestCaseContext_t context);
97
98 /*
99  * Set the expected exit code of the test case context.
100  */
101 void TestCaseContext_setExpectedExitCode(TestCaseContext_t context,int expected_code);
102
103 /*
104  * Return true if the output checking mode is enabled for this
105  * test case context. Otherwise the functions returns false.
106  */
107 bool TestCaseContext_isOutputCheckingEnabled(TestCaseContext_t context);
108
109 /*
110  * Append a child output to check in the 
111  * test case context.
112  */
113 void TestCaseContext_appendExpectedOutput(TestCaseContext_t context,char* expected_output);
114
115 /*
116  * Append a child output to check in the 
117  * test case context.
118  */
119 void TestCaseContext_appendChildInput(TestCaseContext_t context,char* input);
120
121 /*
122  * Set the name of the test case name.
123  */
124 void TestCaseContext_setName(TestCaseContext_t context,char* name);
125
126 void TestCaseContext_createConsole(TestCaseContext_t context);
127
128 void TestCaseContext_createNoConsole(TestCaseContext_t context);
129
130 void TestCaseContext_enableExitCodeChecking(TestCaseContext_t context);
131
132 void TestCaseContext_disableExitCodeChecking(TestCaseContext_t context);
133
134
135 void TestCaseContext_setCommandLine(TestCaseContext_t context,char* cmdLine);
136
137
138  
139
140 #endif /* #ifndef __TestCaseContext_H__ */