diff options
author | Leon Merten Lohse <leon@green-side.de> | 2012-03-27 17:46:43 +0200 |
---|---|---|
committer | Leon Merten Lohse <leon@green-side.de> | 2012-03-27 17:46:43 +0200 |
commit | 662c41ef60169d003c6de37455639e10cacb3f29 (patch) | |
tree | e45c6dbefce2c6c472c8c44ee3c3fd578c945527 /test/driver/helper.c | |
parent | 3940726aa77d102096117fb2f47aa2bb41c8abdc (diff) | |
parent | b052c43389f8e028211595d6f352200f7c30149a (diff) |
Merge branch 'master' of ssh://git.sv.gnu.org/srv/git/libcdio
Diffstat (limited to 'test/driver/helper.c')
-rw-r--r-- | test/driver/helper.c | 74 |
1 files changed, 72 insertions, 2 deletions
diff --git a/test/driver/helper.c b/test/driver/helper.c index b000de40..37aecfb4 100644 --- a/test/driver/helper.c +++ b/test/driver/helper.c @@ -16,7 +16,6 @@ */ #ifdef HAVE_CONFIG_H #include "config.h" -#define __CDIO_CONFIG_H__ 1 #endif #ifdef HAVE_STDIO_H @@ -29,9 +28,51 @@ #include <stdlib.h> #endif -#include <cdio/cdio.h> #include "helper.h" +unsigned int info_msg_count=0; +unsigned int debug_msg_count=0; +unsigned int warn_msg_count=0; +unsigned int error_msg_count=0; +const char *info_messages[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; +const char *debug_messages[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; +const char *warn_messages[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; +const char *error_messages[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; + +void +assert_equal_int(int expect, int got, const char *msg) +{ + if (expect != got) { + fprintf(stderr, "ERROR: Expected %d, got %d\n", expect, got); + if (NULL != msg) fprintf(stderr, "%s\n", msg); + exit(1); + } +} + +void +assert_no_warn(const char *msg) +{ + if (warn_msg_count != 0) { + unsigned int i; + fprintf(stderr, "ERROR: got unexpected warnings:\n"); + for (i=0; i<warn_msg_count; i++) { + fprintf(stderr, "%s\n", warn_messages[i]); + } + exit(1); + } +} + +void +assert_warn(const char *msg) +{ + if (warn_msg_count == 0) { + fprintf(stderr, + "ERROR: should have gotten a warning message:\n%s\n", + msg); + exit(1); + } +} + void check_access_mode(CdIo_t *p_cdio, const char *psz_expected_access_mode) { const char *psz_access_mode = cdio_get_arg(p_cdio, "access-mode"); @@ -78,3 +119,32 @@ void check_mmc_supported(CdIo_t *p_cdio, int i_expected) { exit(32); } } + +void +log_handler(cdio_log_level_t level, const char message[]) +{ + switch(level) { + case CDIO_LOG_DEBUG: + debug_messages[debug_msg_count] = message; + debug_msg_count++; + return; + case CDIO_LOG_INFO: + info_messages[info_msg_count] = message; + info_msg_count++; + return; + case CDIO_LOG_ERROR: + error_messages[info_msg_count] = message; + error_msg_count++; + return; + default: + warn_messages[warn_msg_count] = message; + warn_msg_count++; + return; + } +} + +void +reset_counts(void) +{ + info_msg_count = debug_msg_count = warn_msg_count = 0; +} |