Test: Fixed annoying warnings (and possible obscure bugs).

This commit is contained in:
Maria Matejka 2019-02-08 11:19:04 +01:00
parent 8bdb05edb2
commit 0a793ebc60
3 changed files with 5 additions and 6 deletions

View file

@ -35,7 +35,7 @@ parse_config_file(const void *argv)
const struct parse_config_file_arg *arg = argv; const struct parse_config_file_arg *arg = argv;
size_t fn_size = strlen(arg->filename) + 1; size_t fn_size = strlen(arg->filename) + 1;
char *filename = alloca(fn_size); char *filename = alloca(fn_size);
strncpy(filename, arg->filename, fn_size); memcpy(filename, arg->filename, fn_size);
*(arg->cp) = bt_config_file_parse(filename); *(arg->cp) = bt_config_file_parse(filename);
return !!*(arg->cp); return !!*(arg->cp);

View file

@ -155,10 +155,7 @@ int bt_run_test_fn(int (*fn)(const void *), const void *fn_arg, int timeout)
int result; int result;
alarm(timeout); alarm(timeout);
if (fn_arg)
result = fn(fn_arg); result = fn(fn_arg);
else
result = ((int (*)(void))fn)();
if (!bt_suite_result) if (!bt_suite_result)
result = 0; result = 0;

View file

@ -54,11 +54,13 @@ void bt_log_suite_case_result(int result, const char *fmt, ...);
#define BT_PROMPT_FAIL_NO_COLOR " [" "FAIL" "] " #define BT_PROMPT_FAIL_NO_COLOR " [" "FAIL" "] "
#define BT_PROMPT_OK_FAIL_STRLEN 8 /* strlen ' [FAIL] ' */ #define BT_PROMPT_OK_FAIL_STRLEN 8 /* strlen ' [FAIL] ' */
static inline int bt_test_fn_noarg(const void *cp) { return ((int (*)(void)) cp)(); }
#define bt_test_suite(fn, dsc, ...) \ #define bt_test_suite(fn, dsc, ...) \
bt_test_suite_extra(fn, BT_FORKING, BT_TIMEOUT, dsc, ##__VA_ARGS__) bt_test_suite_extra(fn, BT_FORKING, BT_TIMEOUT, dsc, ##__VA_ARGS__)
#define bt_test_suite_extra(fn, f, t, dsc, ...) \ #define bt_test_suite_extra(fn, f, t, dsc, ...) \
bt_test_suite_base((int (*)(const void *))fn, #fn, NULL, f, t, dsc, ##__VA_ARGS__) bt_test_suite_base(bt_test_fn_noarg, #fn, fn, f, t, dsc, ##__VA_ARGS__)
#define bt_test_suite_arg(fn, arg, dsc, ...) \ #define bt_test_suite_arg(fn, arg, dsc, ...) \
bt_test_suite_arg_extra(fn, arg, BT_FORKING, BT_TIMEOUT, dsc, ##__VA_ARGS__) bt_test_suite_arg_extra(fn, arg, BT_FORKING, BT_TIMEOUT, dsc, ##__VA_ARGS__)