Expand driver test framework a little and the tests we do.
This commit is contained in:
@@ -36,8 +36,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
|
||||||
#include <cdio/logging.h>
|
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -46,6 +44,7 @@ main(int argc, const char *argv[])
|
|||||||
CdIo_t *p_cdio;
|
CdIo_t *p_cdio;
|
||||||
char **ppsz_drives=NULL;
|
char **ppsz_drives=NULL;
|
||||||
|
|
||||||
|
cdio_log_set_handler(log_handler);
|
||||||
cdio_loglevel_default = (argc > 1) ? CDIO_LOG_DEBUG : CDIO_LOG_INFO;
|
cdio_loglevel_default = (argc > 1) ? CDIO_LOG_DEBUG : CDIO_LOG_INFO;
|
||||||
/* snprintf(psz_nrgfile, sizeof(psz_nrgfile)-1,
|
/* snprintf(psz_nrgfile, sizeof(psz_nrgfile)-1,
|
||||||
"%s/%s", TEST_DIR, cue_file[i]);
|
"%s/%s", TEST_DIR, cue_file[i]);
|
||||||
@@ -60,6 +59,13 @@ main(int argc, const char *argv[])
|
|||||||
p_cdio = cdio_open_linux(ppsz_drives[0]);
|
p_cdio = cdio_open_linux(ppsz_drives[0]);
|
||||||
if (p_cdio) {
|
if (p_cdio) {
|
||||||
const char *psz_source = NULL, *psz_scsi_tuple;
|
const char *psz_source = NULL, *psz_scsi_tuple;
|
||||||
|
lsn_t lsn;
|
||||||
|
|
||||||
|
reset_counts();
|
||||||
|
lsn = cdio_get_track_lsn(p_cdio, CDIO_CD_MAX_TRACKS+1);
|
||||||
|
assert_equal_int(CDIO_INVALID_LSN, lsn,
|
||||||
|
"cdio_get_track_lsn with too large of a track number");
|
||||||
|
reset_counts();
|
||||||
|
|
||||||
check_get_arg_source(p_cdio, ppsz_drives[0]);
|
check_get_arg_source(p_cdio, ppsz_drives[0]);
|
||||||
check_mmc_supported(p_cdio, 3);
|
check_mmc_supported(p_cdio, 3);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#define __CDIO_CONFIG_H__ 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STDIO_H
|
#ifdef HAVE_STDIO_H
|
||||||
@@ -29,9 +28,51 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
|
||||||
#include "helper.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)
|
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");
|
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);
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* -*- C -*-
|
/* -*- C -*-
|
||||||
Copyright (C) 2010 Rocky Bernstein <rocky@gnu.org>
|
Copyright (C) 2010, 2012 Rocky Bernstein <rocky@gnu.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,8 +14,23 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cdio/cdio.h>
|
||||||
|
|
||||||
void check_access_mode(CdIo_t *p_cdio, const char *psz_expected_access_mode);
|
void check_access_mode(CdIo_t *p_cdio, const char *psz_expected_access_mode);
|
||||||
void check_get_arg_source(CdIo_t *p_cdio, const char *psz_expected_source);
|
void check_get_arg_source(CdIo_t *p_cdio, const char *psz_expected_source);
|
||||||
void check_mmc_supported(CdIo_t *p_cdio, int i_expected);
|
void check_mmc_supported(CdIo_t *p_cdio, int i_expected);
|
||||||
|
|
||||||
|
#include <cdio/logging.h>
|
||||||
|
void log_handler(cdio_log_level_t level, const char message[]);
|
||||||
|
|
||||||
|
extern unsigned int info_msg_count;
|
||||||
|
extern unsigned int debug_msg_count;
|
||||||
|
extern unsigned int warn_msg_count;
|
||||||
|
extern const char *info_messages[6];
|
||||||
|
extern const char *debug_messages[6];
|
||||||
|
extern const char *warn_messages[6];
|
||||||
|
extern void assert_equal_int(int expect, int got, const char *msg);
|
||||||
|
extern void reset_counts(void);
|
||||||
|
extern void assert_warn(const char *msg);
|
||||||
|
extern void assert_no_warn(const char *msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user