Logo AND Algorithmique Numérique Distribuée

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