12 #ifndef COMMAND_OUTPUT_H
13 #define COMMAND_OUTPUT_H
16 #error currently only used inside unittest-code. need refactoring to be used generally
25 #ifndef UT_VALGRINDED_H
43 if (!error) error = err;
47 char *readAndUnlink(
const char *file) {
65 expect_failure(expect_failure_)
84 stdoutput = readAndUnlink(stdout_log);
85 stderrput = readAndUnlink(stderr_log);
91 printf(
"command '%s'\n"
92 "escaped command '%s'\n"
95 command, escaped, stdoutput, stderrput);
113 return all().ofgroup(expected);
120 return all().ofgroup(expected);
125 uint32_t checksum = css^cse;
130 return all().ofgroup(expected);
136 #define TEST_OUTPUT_EQUALS(cmd, expected_std, expected_err) \
138 bool try_valgrind = false; \
139 TEST_EXPECTATION(CommandOutput(cmd, try_valgrind).Equals(expected_std, expected_err)); \
142 #define TEST_OUTPUT_EQUALS__BROKEN(cmd, expected_std, expected_err) \
144 bool try_valgrind = false; \
145 TEST_EXPECTATION__BROKEN_SIMPLE(CommandOutput(cmd, try_valgrind).Equals(expected_std, expected_err)); \
148 #define TEST_OUTPUT_CONTAINS(cmd, expected_std, expected_err) \
150 bool try_valgrind = false; \
151 TEST_EXPECTATION(CommandOutput(cmd, try_valgrind).Contains(expected_std, expected_err)); \
154 #define TEST_OUTPUT_CONTAINS__BROKEN(cmd, expected_std, expected_err) \
156 bool try_valgrind = false; \
157 TEST_EXPECTATION__BROKEN_SIMPLE(CommandOutput(cmd, try_valgrind).Contains(expected_std, expected_err)); \
160 #define TEST_FAILURE_OUTPUT_CONTAINS(cmd, expected_std, expected_err) \
162 TEST_EXPECTATION(CommandOutput(cmd, false, true).Contains(expected_std, expected_err)); \
165 #define TEST_FAILURE_OUTPUT_CONTAINS__BROKEN(cmd, expected_std, expected_err) \
167 TEST_EXPECTATION__BROKEN_SIMPLE(CommandOutput(cmd, false, true).Contains(expected_std, expected_err)); \
171 #define TEST_OUTPUT_HAS_CHECKSUM(cmd,checksum) TEST_EXPECTATION (CommandOutput(cmd, false).has_checksum(checksum))
172 #define TEST_OUTPUT_HAS_CHECKSUM__BROKEN(cmd,checksum) TEST_EXPECTATION__BROKEN_SIMPLE(CommandOutput(cmd, false).has_checksum(checksum))
174 #define TEST_STDOUT_EQUALS(cmd, expected_std) TEST_OUTPUT_EQUALS(cmd, expected_std, (const char *)NULp)
175 #define TEST_STDERR_EQUALS(cmd, expected_err) TEST_OUTPUT_EQUALS(cmd, (const char *)NULp, expected_err)
177 #define TEST_STDOUT_CONTAINS(cmd, part) TEST_OUTPUT_CONTAINS(cmd, part, (const char *)NULp)
178 #define TEST_STDERR_CONTAINS(cmd, part) TEST_OUTPUT_CONTAINS(cmd, (const char *)NULp, part)
181 #error command_output.h included twice
182 #endif // COMMAND_OUTPUT_H
GB_ERROR GBK_system(const char *system_command)
const char * GBS_global_string(const char *templat,...)
char * GBS_string_eval(const char *insource, const char *icommand)
int GB_unlink(const char *path)
const char * get_stdoutput() const
arb_test::match_expectation has_checksum(uint32_t expected_checksum)
GB_ERROR GB_await_error()
#define is_equal_to_NULL()
expectation_group & add(const expectation &e)
arb_test::match_expectation Contains(const char *expected_std, const char *expected_err)
#define does_differ_from_NULL()
const char * get_stderrput() const
GB_ERROR get_error() const
#define does_contain(val)
#define make_valgrinded_call(command)
CommandOutput(const char *command, bool try_valgrind, bool expect_failure_=false)
uint32_t GBS_checksum(const char *seq, int ignore_case, const char *exclude)
arb_test::match_expectation Equals(const char *expected_std, const char *expected_err)
char * GBS_global_string_copy(const char *templat,...)
char * GB_read_file(const char *path)