static void sbuf_append(struct sbuf *buf, __unused const char *comment, const char *str, ...) { va_list ap; va_start(ap, str); sbuf_vprintf(buf, str, ap); va_end(ap); }
/* * Format the given arguments and append the resulting string to an sbuf. */ int sbuf_printf(struct sbuf *s, const char *fmt, ...) { __va_list ap; int result; __va_start(ap, fmt); result = sbuf_vprintf(s, fmt, ap); __va_end(ap); return (result); }
#include "sbuf_test_common.h" static char test_string[] = "this is a test string"; #define MESSAGE_FORMAT "message: %s\n" #define MESSAGE_SEPARATOR ';' static int sbuf_vprintf_helper(struct sbuf *sb, const char * restrict format, ...) { va_list ap; int rc; va_start(ap, format); rc = sbuf_vprintf(sb, format, ap); va_end(ap); return (rc); } ATF_TC_WITHOUT_HEAD(sbuf_printf_test); ATF_TC_BODY(sbuf_printf_test, tc) { struct sbuf *sb; char *test_string_tmp; asprintf(&test_string_tmp, "%s%c" MESSAGE_FORMAT, test_string, MESSAGE_SEPARATOR, test_string); ATF_REQUIRE_MSG(test_string_tmp != NULL, "asprintf failed");