testharness: removed some warnings

This commit is contained in:
Peter Andersson
2017-05-27 09:46:35 +02:00
parent 4b520a03ed
commit a96baf5bc7
4 changed files with 29 additions and 27 deletions
-16
View File
@@ -27,15 +27,10 @@
#define AREA(x) _area[(x) - addr_offset] #define AREA(x) _area[(x) - addr_offset]
#define ERREXIT() if (abort_on_error) abort(); else error_count++
static u32_t _area_sz; static u32_t _area_sz;
static unsigned char *_area = NULL; static unsigned char *_area = NULL;
static u32_t addr_offset = 0; static u32_t addr_offset = 0;
static u32_t abort_on_error = 0;
static int error_count = 0;
static int *_erases; static int *_erases;
static char _path[256]; static char _path[256];
static u32_t bytes_rd = 0; static u32_t bytes_rd = 0;
@@ -117,17 +112,6 @@ static int mkpath(const char *path, mode_t mode) {
// end take // end take
// //
// //
int get_error_count() {
return error_count;
}
u32_t set_abort_on_error(u32_t val) {
u32_t old_val = abort_on_error;
abort_on_error = val;
return old_val;
}
char *make_test_fname(const char *name) { char *make_test_fname(const char *name) {
sprintf(_path, "%s/%s", TEST_PATH, name); sprintf(_path, "%s/%s", TEST_PATH, name);
return _path; return _path;
+1 -3
View File
@@ -55,9 +55,6 @@ typedef struct {
char name[32]; char name[32];
} tfile; } tfile;
u32_t set_abort_on_error(u32_t val);
int get_error_count();
void fs_reset(); void fs_reset();
void fs_reset_specific(u32_t addr_offset, u32_t phys_addr, u32_t phys_size, void fs_reset_specific(u32_t addr_offset, u32_t phys_addr, u32_t phys_size,
u32_t phys_sector_size, u32_t phys_sector_size,
@@ -92,6 +89,7 @@ u32_t get_flash_ops_log_write_bytes();
void invoke_error_after_read_bytes(u32_t b, char once_only); void invoke_error_after_read_bytes(u32_t b, char once_only);
void invoke_error_after_write_bytes(u32_t b, char once_only); void invoke_error_after_write_bytes(u32_t b, char once_only);
void fs_set_validate_flashing(int i); void fs_set_validate_flashing(int i);
int get_error_count();
void memrand(u8_t *b, int len); void memrand(u8_t *b, int len);
int test_create_file(char *name); int test_create_file(char *name);
+11
View File
@@ -108,6 +108,17 @@ static void dump_res(test_res **head) {
} }
} }
int get_error_count() {
return error_count;
}
int set_abort_on_error(int val) {
int old_val = abort_on_error;
abort_on_error = val;
return old_val;
}
int run_tests(int argc, char **args) { int run_tests(int argc, char **args) {
memset(&test_main, 0, sizeof(test_main)); memset(&test_main, 0, sizeof(test_main));
int arg; int arg;
+17 -8
View File
@@ -65,6 +65,12 @@ void add_suites() {
#define TEST_RES_FAIL -1 #define TEST_RES_FAIL -1
#define TEST_RES_ASSERT -2 #define TEST_RES_ASSERT -2
#define ERREXIT() if (abort_on_error) abort(); else error_count++
static int abort_on_error = 0;
static int error_count = 0;
struct test_s; struct test_s;
typedef int (*test_f)(struct test_s *t); typedef int (*test_f)(struct test_s *t);
@@ -85,35 +91,35 @@ typedef struct test_res_s {
} test_res; } test_res;
#define TEST_CHECK(x) if (!(x)) { \ #define TEST_CHECK(x) if (!(x)) { \
printf(" TEST FAIL %s:%i\n", __FILE__, __LINE__); \ printf(" TEST FAIL %s:%d\n", __FILE__, __LINE__); \
goto __fail_stop; \ goto __fail_stop; \
} }
#define TEST_CHECK_EQ(x, y) if ((x) != (y)) { \ #define TEST_CHECK_EQ(x, y) if ((x) != (y)) { \
printf(" TEST FAIL %s:%i, %i != %i\n", __FILE__, __LINE__, (x), (y)); \ printf(" TEST FAIL %s:%d, %d != %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \ goto __fail_stop; \
} }
#define TEST_CHECK_NEQ(x, y) if ((x) == (y)) { \ #define TEST_CHECK_NEQ(x, y) if ((x) == (y)) { \
printf(" TEST FAIL %s:%i, %i == %i\n", __FILE__, __LINE__, (x), (y)); \ printf(" TEST FAIL %s:%d, %d == %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \ goto __fail_stop; \
} }
#define TEST_CHECK_GT(x, y) if ((x) <= (y)) { \ #define TEST_CHECK_GT(x, y) if ((x) <= (y)) { \
printf(" TEST FAIL %s:%i, %i <= %i\n", __FILE__, __LINE__, (x), (y)); \ printf(" TEST FAIL %s:%d, %d <= %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \ goto __fail_stop; \
} }
#define TEST_CHECK_LT(x, y) if ((x) >= (y)) { \ #define TEST_CHECK_LT(x, y) if ((x) >= (y)) { \
printf(" TEST FAIL %s:%i, %i >= %i\n", __FILE__, __LINE__, (x), (y)); \ printf(" TEST FAIL %s:%d, %d >= %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \ goto __fail_stop; \
} }
#define TEST_CHECK_GE(x, y) if ((x) < (y)) { \ #define TEST_CHECK_GE(x, y) if ((x) < (y)) { \
printf(" TEST FAIL %s:%i, %i < %i\n", __FILE__, __LINE__, (x), (y)); \ printf(" TEST FAIL %s:%d, %d < %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \ goto __fail_stop; \
} }
#define TEST_CHECK_LE(x, y) if ((x) > (y)) { \ #define TEST_CHECK_LE(x, y) if ((x) > (y)) { \
printf(" TEST FAIL %s:%i, %i > %i\n", __FILE__, __LINE__, (x), (y)); \ printf(" TEST FAIL %s:%d, %d > %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \ goto __fail_stop; \
} }
#define TEST_ASSERT(x) if (!(x)) { \ #define TEST_ASSERT(x) if (!(x)) { \
printf(" TEST ASSERT %s:%i\n", __FILE__, __LINE__); \ printf(" TEST ASSERT %s:%d\n", __FILE__, __LINE__); \
goto __fail_assert; \ goto __fail_assert; \
} }
@@ -148,6 +154,9 @@ typedef struct test_res_s {
__fail_assert: return TEST_RES_ASSERT; \ __fail_assert: return TEST_RES_ASSERT; \
} }
int set_abort_on_error(int val);
int get_error_count();
void add_suites(); void add_suites();
void test_init(void (*on_stop)(test *t)); void test_init(void (*on_stop)(test *t));
// returns 0 if all tests ok, -1 if any test failed, -2 on badness // returns 0 if all tests ok, -1 if any test failed, -2 on badness