1 #ifndef __TestCaseContext_H__
2 #define __TestCaseContext_H__
8 * Declaration a the s_TestCaseContext structure
9 * which represents the context of a test case during his
12 typedef struct s_TestCaseContext
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 */
40 }s_TestCaseContext_t,* TestCaseContext_t;
42 /* Output checking is disabled by default*/
43 #define DEFAULT_OUTPUT_CHECKING_MODE false
45 /* Post output checking mode is disabled by default*/
46 #define DEFAULT_POST_OUTPUT_CHECKING_MODE false
48 /* The default timeout value is 5 seconds*/
49 #define DEFAULT_TIMEOUT_VALUE ((int)120000)
51 /* Invalid exit code value (default value)*/
52 #define INVALID_EXIT_CODE ((int)0xFFFFFF)
55 * s_TestCaseContext struct connected functions.
59 * Create a new s_TestCaseContext and returns a pointer to self.
61 TestCaseContext_t TestCaseContext_new(void);
64 * Destroy the s_TestCaseContext referenced by context.
66 void TestCaseContext_free(TestCaseContext_t context);
69 * Clear the s_TestCaseContext referenced by context.
71 void TestCaseContext_clear(TestCaseContext_t context);
74 * Set the timeout of the test case context.
76 void TestCaseContext_setTimeout(TestCaseContext_t context,int timeout);
79 * Enable the output checking of the test case context.
81 void TestCaseContext_enableOutputChecking(TestCaseContext_t context);
84 * Disable the output checking of the test case context.
86 void TestCaseContext_disableOutputChecking(TestCaseContext_t context);
89 * Enable the post output checking of the test case context.
91 void TestCaseContext_enable_post_output_checking(TestCaseContext_t context);
94 * Disable the post output checking of the test case context.
96 void TestCaseContext_disablePostOutputChecking(TestCaseContext_t context);
99 * Set the expected exit code of the test case context.
101 void TestCaseContext_setExpectedExitCode(TestCaseContext_t context,int expected_code);
104 * Return true if the output checking mode is enabled for this
105 * test case context. Otherwise the functions returns false.
107 bool TestCaseContext_isOutputCheckingEnabled(TestCaseContext_t context);
110 * Append a child output to check in the
113 void TestCaseContext_appendExpectedOutput(TestCaseContext_t context,char* expected_output);
116 * Append a child output to check in the
119 void TestCaseContext_appendChildInput(TestCaseContext_t context,char* input);
122 * Set the name of the test case name.
124 void TestCaseContext_setName(TestCaseContext_t context,char* name);
126 void TestCaseContext_createConsole(TestCaseContext_t context);
128 void TestCaseContext_createNoConsole(TestCaseContext_t context);
130 void TestCaseContext_enableExitCodeChecking(TestCaseContext_t context);
132 void TestCaseContext_disableExitCodeChecking(TestCaseContext_t context);
135 void TestCaseContext_setCommandLine(TestCaseContext_t context,char* cmdLine);
140 #endif /* #ifndef __TestCaseContext_H__ */