rfree(tmp);
if (res.type == T_RETURN && res.val.i >= F_REJECT)
- return BT_FAILURE;
+ return 0;
- return BT_SUCCESS;
+ return 1;
}
static void
bt_assert_filter(int result, struct f_inst *assert)
{
- int bt_suit_case_result = BT_SUCCESS;
+ int bt_suit_case_result = 1;
if (!result)
{
- bt_result = BT_FAILURE;
- bt_suite_result = BT_FAILURE;
- bt_suit_case_result = BT_FAILURE;
+ bt_result = 0;
+ bt_suite_result = 0;
+ bt_suit_case_result = 0;
}
bt_log_suite_case_result(bt_suit_case_result, "Assertion at line %d (%s)", assert->lineno, (char *) assert->a2.p);
bt_assert(same_tree(balanced_tree_from_simple, expected_balanced_tree));
}
- return BT_SUCCESS;
+ return 1;
}
}
}
- return BT_SUCCESS;
+ return 1;
}
static int
}
}
- return BT_SUCCESS;
+ return 1;
}
static uint
}
}
- return BT_SUCCESS;
+ return 1;
}
int
}
bt_bird_cleanup();
- return BT_SUCCESS;
+ return 1;
}
static int
}
}
- return BT_SUCCESS;
+ return 1;
}
int
bt_assert_msg(compute == expect, "u32_mkmask(%d) = 0x%08X, expected 0x%08X", i, compute, expect);
}
- return BT_SUCCESS;
+ return 1;
}
static int
for (i = 0; i <= MAX_NUM; i++)
check_mask(bt_random());
- return BT_SUCCESS;
+ return 1;
}
static void
for (i = 1; i < MAX_NUM; i++)
check_log2(((u32) bt_random()) % 0x0fffffff);
- return BT_SUCCESS;
+ return 1;
}
int
BUFFER_PUSH(buf) = expected[i];
is_buffer_as_expected(&buf);
- return BT_SUCCESS;
+ return 1;
}
static int
BUFFER_PUSH(buf) = expected[i];
is_buffer_as_expected(&buf);
- return BT_SUCCESS;
+ return 1;
}
static int
is_buffer_as_expected(&buf);
bt_assert(buf.size >= MAX_NUM);
- return BT_SUCCESS;
+ return 1;
}
static int
BUFFER_FLUSH(buf);
bt_assert(buf.used == 0);
- return BT_SUCCESS;
+ return 1;
}
int
bt_assert(sum_calculated == sum_expected);
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(ipsum_verify(a, sizeof(a), NULL));
- return BT_SUCCESS;
+ return 1;
}
for (i = 1; i < MAX_NUM; i++)
bt_assert(event_check_points[i]);
- return BT_SUCCESS;
+ return 1;
}
int
fletcher16_update(&ctxt, in, strlen(in));
put_u16(out, fletcher16_compute(&ctxt));
- return (*out == *expected_out) ? BT_SUCCESS : BT_FAILURE;
+ return *out == *expected_out;
}
static int
fletcher16_update(&ctxt, in, len);
put_u16(out, fletcher16_final(&ctxt, len, len));
- return (*out == *expected_out) ? BT_SUCCESS : BT_FAILURE;
+ return *out == *expected_out;
}
static int
fill_hash();
validate_filled_hash();
- return BT_SUCCESS;
+ return 1;
}
static int
validate_filled_hash();
- return BT_SUCCESS;
+ return 1;
}
static int
validate_filled_hash();
- return BT_SUCCESS;
+ return 1;
}
static int
for (i = 0; i < MAX_NUM; i++)
bt_assert(check[i] == 1);
- return BT_SUCCESS;
+ return 1;
}
static int
validate_empty_hash();
- return BT_SUCCESS;
+ return 1;
}
static int
validate_empty_hash();
- return BT_SUCCESS;
+ return 1;
}
static int
validate_empty_hash();
- return BT_SUCCESS;
+ return 1;
}
static int
validate_empty_hash();
- return BT_SUCCESS;
+ return 1;
}
static int
for (i = 0; i < MAX_NUM; i++)
bt_assert(check[i] == 1);
- return BT_SUCCESS;
+ return 1;
}
int
bt_assert(is_heap_valid(heap, num));
}
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(is_heap_valid(heap, num));
}
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(is_heap_valid(heap, num));
}
- return BT_SUCCESS;
+ return 1;
}
static int
t_heap_increase_decrease();
t_heap_delete();
- return (heap[0] == SPECIAL_KEY) ? BT_SUCCESS : BT_FAILURE;
+ return heap[0] == SPECIAL_KEY;
}
static int
bt_abort_msg("Did not find a number %d in heap.", expected[i]);
}
- return BT_SUCCESS;
+ return 1;
}
int
/* ip_addr == ip6_addr */
}
- return ipa_equal(*out, *expected_out) ? BT_SUCCESS : BT_FAILURE;
+ return ipa_equal(*out, *expected_out);
}
static int
ip6_ntop(ipa_to_ip6(*in), out);
int result = strncmp(out, expected_out, ipa_is_ip4(*in) ? IP4_MAX_TEXT_LENGTH : IP6_MAX_TEXT_LENGTH) == 0;
- return result ? BT_SUCCESS : BT_FAILURE;
+ return result;
}
static int
show_list();
bt_assert(is_filled_list_well_linked());
- return BT_SUCCESS;
+ return 1;
}
static int
show_list();
bt_assert(is_filled_list_well_linked());
- return BT_SUCCESS;
+ return 1;
}
static void
bt_debug("\n");
bt_assert(is_filled_list_well_linked());
- return BT_SUCCESS;
+ return 1;
}
static void
rem_node(&nodes[i]);
bt_assert(is_empty_list_well_unlinked());
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(tail.next == NODE &l.null);
bt_assert(nodes[MAX_NUM-2].next == &tail);
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(nodes2[0].prev == &nodes[MAX_NUM-1]);
bt_assert(l.tail == &nodes2[MAX_NUM-1]);
- return BT_SUCCESS;
+ return 1;
}
int
uint len = mac_type_length(id); \
bt_bytes_to_hex(out, out_bin, len); \
\
- return strncmp(out, expected_out, 2*len+1) == 0 ? BT_SUCCESS : BT_FAILURE; \
+ return strncmp(out, expected_out, 2*len+1) == 0; \
}
define_test_hash_fn(md5, ALG_MD5)
\
uint len = mac_type_length(id); \
bt_bytes_to_hex(out, out_bin, len); \
- \
- return strncmp(out, expected_out, 2*len+1) == 0 ? BT_SUCCESS : BT_FAILURE; \
+ \
+ return strncmp(out, expected_out, 2*len+1) == 0; \
}
define_test_hmac_fn(md5, ALG_HMAC_MD5)
int are_hash_a_b_equal = (strncmp(hash_a, hash_b, sizeof(hash_a)) == 0);
bt_assert_msg(are_hash_a_b_equal, "Hashes A: %s, B: %s should be same", hash_a, hash_b);
- return BT_SUCCESS;
+ return 1;
}
int are_hash_a_b_equal = (strncmp(hash_a, hash_b, sizeof(hash_a)) == 0);
bt_assert_msg(are_hash_a_b_equal, "Hashes A: %s, B: %s should be same", hash_a, hash_b);
- return BT_SUCCESS;
+ return 1;
}
int
*out = patmatch(in->pattern, in->data);
- return (*out == *expected_out) ? BT_SUCCESS : BT_FAILURE;
+ return *out == *expected_out;
}
static void
BSPRINTF(2, "-1", buf, "%d", -1);
BSPRINTF(11, "-2147483648", buf, "%d", -2147483648);
- return BT_SUCCESS;
+ return 1;
}
int
bt_assert(is_filled_list_well_linked());
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(is_filled_list_well_linked());
- return BT_SUCCESS;
+ return 1;
}
static void
bt_debug("\n");
bt_assert(is_filled_list_well_linked());
- return BT_SUCCESS;
+ return 1;
}
static void
s_rem_node(&nodes[i]);
bt_assert(is_empty_list_well_unlinked());
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(nodes2[0].prev == &nodes[MAX_NUM-1]);
bt_assert(lst.tail == &nodes2[MAX_NUM-1]);
- return BT_SUCCESS;
+ return 1;
}
void
i++;
}
- return BT_SUCCESS;
+ return 1;
}
static int
s_add_tail_list(&b, &a);
dump("8 (after merge)", &b);
- return BT_SUCCESS;
+ return 1;
}
static int
}
bt_assert(is_empty_list_well_unlinked());
- return BT_SUCCESS;
+ return 1;
}
int
rfree(lp);
}
- return BT_SUCCESS;
+ return 1;
}
static int
rfree(lp);
- return BT_SUCCESS;
+ return 1;
}
static int
rfree(lp);
- return BT_SUCCESS;
+ return 1;
}
static int
"\032\0310\030\039\030\038\030\037\030\036\030\035\030\034\030\033\030\032\030\031\030\030",
22));
- return BT_SUCCESS;
+ return 1;
}
int
bt_assert_msg(data[i] == i, "(data[i] = %d) == i = %d)", data[i], i);
rfree(lp);
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(int_set_format(set_union, 0, 2, buf, BUFFER_SIZE) == 0);
rfree(lp);
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(strcmp(buf, "(0,0) (0,1) (0,2) (0,3) (0,4) (0,5) (0,6) (0,7) (0,8) (0,9)") == 0);
rfree(lp);
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(int_set_get_size(set_sequence) == SET_SIZE);
- return BT_SUCCESS;
+ return 1;
}
/*
// bt_assert_msg(data[i] == (SET_SIZE-1-i), "(data[i] = %d) == ((SET_SIZE-1-i) = %d)", data[i], SET_SIZE-1-i);
rfree(lp);
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(ec_set_format(set_union, 0, buf, BUFFER_SIZE) == 0);
rfree(lp);
- return BT_SUCCESS;
+ return 1;
}
static int
"ec_set_format() returns '%s'", buf);
rfree(lp);
- return BT_SUCCESS;
+ return 1;
}
static int
bt_assert(ec_set_get_size(set_sequence) == SET_SIZE);
- return BT_SUCCESS;
+ return 1;
}
int
bt_verbose = 0;
bt_filename = argv[0];
- bt_result = BT_SUCCESS;
+ bt_result = 1;
bt_test_id = NULL;
is_terminal = isatty(fileno(stdout));
else
result = ((int (*)(void))fn)();
- if (bt_suite_result != BT_SUCCESS)
- result = BT_FAILURE;
+ if (!bt_suite_result)
+ result = 0;
return result;
}
/**
* bt_log_result - pretty print of test result
- * @result: BT_SUCCESS or BT_FAILURE
+ * @result: 1 or 0
* @fmt: a description message (could be long, over more lines)
* @argptr: variable argument list
*
putchar(' ');
const char *result_str = is_terminal ? BT_PROMPT_OK : BT_PROMPT_OK_NO_COLOR;
- if (result != BT_SUCCESS)
+ if (!result)
result_str = is_terminal ? BT_PROMPT_FAIL : BT_PROMPT_FAIL_NO_COLOR;
printf("%s\n", result_str);
/**
* bt_log_overall_result - pretty print of suite case result
- * @result: BT_SUCCESS or BT_FAILURE
+ * @result: 1 or 0
* @fmt: a description message (could be long, over more lines)
* ...: variable argument list
*
/**
* bt_log_suite_result - pretty print of suite case result
- * @result: BT_SUCCESS or BT_FAILURE
+ * @result: 1 or 0
* @fmt: a description message (could be long, over more lines)
* ...: variable argument list
*
void
bt_log_suite_result(int result, const char *fmt, ...)
{
- if(bt_verbose >= BT_VERBOSE_SUITE || result == BT_FAILURE)
+ if(bt_verbose >= BT_VERBOSE_SUITE || !result)
{
va_list argptr;
va_start(argptr, fmt);
/**
* bt_log_suite_case_result - pretty print of suite result
- * @result: BT_SUCCESS or BT_FAILURE
+ * @result: 1 or 0
* @fmt: a description message (could be long, over more lines)
* ...: variable argument list
*
vprintf(dsc, args);
va_end(args);
printf("\n");
- return BT_SUCCESS;
+ return 1;
}
if (no_fork)
timeout = 0;
if (request && strcmp(id, request))
- return BT_SUCCESS;
+ return 1;
- bt_suite_result = BT_SUCCESS;
+ bt_suite_result = 1;
bt_test_id = id;
if (bt_verbose >= BT_VERBOSE_ABSOLUTELY_ALL)
else if (WIFSIGNALED(s))
{
/* Stopped by signal */
- bt_suite_result = BT_FAILURE;
+ bt_suite_result = 0;
int sn = WTERMSIG(s);
if (sn == SIGALRM)
bt_log("Core dumped");
}
- if (bt_suite_result == BT_FAILURE)
- bt_result = BT_FAILURE;
+ if (!bt_suite_result)
+ bt_result = 0;
bt_log_suite_result(bt_suite_result, NULL);
bt_test_id = NULL;
int
bt_exit_value(void)
{
- if (!list_tests || (list_tests && bt_result != BT_SUCCESS))
+ if (!list_tests || (list_tests && !bt_result))
bt_log_overall_result(bt_result, "");
- return bt_result == BT_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
+ return bt_result ? EXIT_SUCCESS : EXIT_FAILURE;
}
/**
* @opts: includes all necessary data
*
* Should be called using macro bt_assert_batch().
- * Returns BT_SUCCESS or BT_FAILURE.
+ * Returns 1 or 0.
*/
int
bt_assert_batch__(struct bt_batch *opts)
{
int bt_suit_case_result = opts->test_fn(opts->out_buf, opts->data[i].in, opts->data[i].out);
- if (bt_suit_case_result == BT_FAILURE)
- bt_suite_result = BT_FAILURE;
+ if (bt_suit_case_result == 0)
+ bt_suite_result = 0;
char b[BT_BUFFER_SIZE];
snprintf(b, sizeof(b), "%s(", opts->test_fn_name);
sprintf_concat(b, ") gives ");
opts->out_fmt(b+strlen(b), sizeof(b)-strlen(b), opts->out_buf);
- if (bt_suit_case_result == BT_FAILURE)
+ if (bt_suit_case_result == 0)
{
sprintf_concat(b, ", but expecting is ");
opts->out_fmt(b+strlen(b), sizeof(b)-strlen(b), opts->data[i].out);
void bt_log_suite_result(int result, const char *fmt, ...);
void bt_log_suite_case_result(int result, const char *fmt, ...);
-#define BT_SUCCESS 42 /* 1 is too usual, filter quitbird returns 1 too */
-#define BT_FAILURE 0
-
#define BT_TIMEOUT 5 /* Default timeout in seconds */
#define BT_FORKING 1 /* Forking is enabled in default */
#define bt_assert_msg(test, format, ...) \
do \
{ \
- int bt_suit_case_result = BT_SUCCESS; \
+ int bt_suit_case_result = 1; \
if ((test) == 0) \
{ \
- bt_result = BT_FAILURE; \
- bt_suite_result = BT_FAILURE; \
- bt_suit_case_result = BT_FAILURE; \
+ bt_result = 0; \
+ bt_suite_result = 0; \
+ bt_suit_case_result = 0; \
} \
bt_log_suite_case_result(bt_suit_case_result, format, ##__VA_ARGS__); \
} while (0)
* @expected_out: expected data from tested function
*
* Input arguments should not be stringified using in_fmt() or out_fmt()
- * function already. This function should return only BT_SUCCESS or
- * BT_FAILURE */
+ * function already. This function should return only 0 or 1 */
int (*test_fn)(void *out, const void *in, const void *expected_out);
/* Name of testing function @test_fn */
const char *test_fn_name;
- /* Number of items in data*/
+ /* Number of items in data */
int ndata;
/* Array of input and expected output pairs */