size_t num_chips;
bool test_failed;
char *failed_msg;
+ char *custom_str;
struct event_thread event;
struct gpiotool_proc tool_proc;
bool running;
free(globals.test_ctx.chips);
+ if (globals.test_ctx.custom_str)
+ free(globals.test_ctx.custom_str);
+
if (mockup_loaded()) {
status = kmod_module_remove_module(globals.module, 0);
if (status)
return ret;
}
+
+const char *test_build_str(const char *fmt, ...)
+{
+ va_list va;
+ char *str;
+ int rv;
+
+ if (globals.test_ctx.custom_str)
+ free(globals.test_ctx.custom_str);
+
+ va_start(va, fmt);
+ rv = vasprintf(&str, fmt, va);
+ va_end(va);
+ if (rv < 0)
+ die_perr("error creating custom string");
+
+ globals.test_ctx.custom_str = str;
+
+ return str;
+}
bool test_regex_match(const char *str, const char *pattern);
+/*
+ * Return a custom string built according to printf() formatting rules. The
+ * returned string is valid until the next call to this routine.
+ */
+const char *test_build_str(const char *fmt, ...) TEST_PRINTF(1, 2);
+
#define TEST_ASSERT(statement) \
do { \
if (!(statement)) { \