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 {
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 */
39 } s_TestCaseContext_t, *TestCaseContext_t;
41 /* Output checking is disabled by default*/
42 #define DEFAULT_OUTPUT_CHECKING_MODE false
44 /* Post output checking mode is disabled by default*/
45 #define DEFAULT_POST_OUTPUT_CHECKING_MODE false
47 /* The default timeout value is 5 seconds*/
48 #define DEFAULT_TIMEOUT_VALUE ((int)120000)
50 /* Invalid exit code value (default value)*/
51 #define INVALID_EXIT_CODE ((int)0xFFFFFF)
54 * s_TestCaseContext struct connected functions.
58 * Create a new s_TestCaseContext and returns a pointer to self.
60 TestCaseContext_t TestCaseContext_new(void);
63 * Destroy the s_TestCaseContext referenced by context.
65 void TestCaseContext_free(TestCaseContext_t context);
68 * Clear the s_TestCaseContext referenced by context.
70 void TestCaseContext_clear(TestCaseContext_t context);
73 * Set the timeout of the test case context.
75 void TestCaseContext_setTimeout(TestCaseContext_t context, int timeout);
78 * Enable the output checking of the test case context.
80 void TestCaseContext_enableOutputChecking(TestCaseContext_t context);
83 * Disable the output checking of the test case context.
85 void TestCaseContext_disableOutputChecking(TestCaseContext_t context);
88 * Enable the post output checking of the test case context.
90 void TestCaseContext_enable_post_output_checking(TestCaseContext_t
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,
105 * Return true if the output checking mode is enabled for this
106 * test case context. Otherwise the functions returns false.
108 bool TestCaseContext_isOutputCheckingEnabled(TestCaseContext_t context);
111 * Append a child output to check in the
114 void TestCaseContext_appendExpectedOutput(TestCaseContext_t context,
115 char *expected_output);
118 * Append a child output to check in the
121 void TestCaseContext_appendChildInput(TestCaseContext_t context,
125 * Set the name of the test case name.
127 void TestCaseContext_setName(TestCaseContext_t context, char *name);
129 void TestCaseContext_createConsole(TestCaseContext_t context);
131 void TestCaseContext_createNoConsole(TestCaseContext_t context);
133 void TestCaseContext_enableExitCodeChecking(TestCaseContext_t context);
135 void TestCaseContext_disableExitCodeChecking(TestCaseContext_t context);
138 void TestCaseContext_setCommandLine(TestCaseContext_t context,
144 #endif /* #ifndef __TestCaseContext_H__ */