diff --git a/lib/driver/disc.c b/lib/driver/disc.c index 3c66ea95..ec09ad10 100644 --- a/lib/driver/disc.c +++ b/lib/driver/disc.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2003, 2004, 2005, 2008, 2011 + Copyright (C) 2003, 2004, 2005, 2008, 2011, 2012 Rocky Bernstein Copyright (C) 2001 Herbert Valerio Riedel @@ -124,7 +124,7 @@ cdio_get_discmode (CdIo_t *cd_obj) char * cdio_get_mcn (const CdIo_t *p_cdio) { - if (p_cdio->op.get_mcn) { + if (p_cdio && p_cdio->op.get_mcn) { return p_cdio->op.get_mcn (p_cdio->env); } else { return NULL; diff --git a/test/driver/.gitignore b/test/driver/.gitignore index 0c5a2ffa..50828daa 100644 --- a/test/driver/.gitignore +++ b/test/driver/.gitignore @@ -9,6 +9,7 @@ /bincue /bincue /bincue.c +/cdda /cdrdao /cdrdao.c /follow_symlink diff --git a/test/driver/Makefile.am b/test/driver/Makefile.am index 6f8b12c0..b55ab70d 100644 --- a/test/driver/Makefile.am +++ b/test/driver/Makefile.am @@ -24,6 +24,10 @@ bincue_SOURCES = helper.c bincue.c bincue_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) bincue_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\" +cdda_SOURCES = helper.c cdda.c +cdda_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) +cdda_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\" + cdrdao_SOURCES = helper.c cdrdao.c cdrdao_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) cdrdao_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\" @@ -58,7 +62,7 @@ win32_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) win32_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\" check_PROGRAMS = \ - abs_path bincue cdrdao freebsd gnu_linux \ + abs_path bincue cdda cdrdao freebsd gnu_linux \ mmc_read mmc_write nrg \ osx realpath solaris win32 diff --git a/test/driver/cdda.c b/test/driver/cdda.c new file mode 100644 index 00000000..6c38245e --- /dev/null +++ b/test/driver/cdda.c @@ -0,0 +1,56 @@ +/* -*- C -*- + Copyright (C) 2012 Rocky Bernstein + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* + Unit test for cdda-like things lib/driver/disc.c +*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_STDIO_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + +#include "helper.h" + +int +main(int argc, const char *argv[]) +{ + char *mcn = cdio_get_mcn(NULL); + + cdio_log_set_handler(log_handler); + cdio_loglevel_default = (argc > 1) ? CDIO_LOG_DEBUG : CDIO_LOG_INFO; + + /* Had a bug in not testing for null p_cdio with cdio_get_mcn. */ + mcn = cdio_get_mcn(NULL); + if (mcn != NULL) { + printf("Should have gotten NULL for MCN for cdio object\n"); + return 1; + } + + return 0; +} diff --git a/test/driver/gnu_linux.c b/test/driver/gnu_linux.c index f4571b3e..fabae3fa 100644 --- a/test/driver/gnu_linux.c +++ b/test/driver/gnu_linux.c @@ -1,5 +1,5 @@ /* -*- C -*- - Copyright (C) 2009, 2010 Rocky Bernstein + Copyright (C) 2009, 2010, 2012 Rocky Bernstein 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 @@ -20,7 +20,6 @@ */ #ifdef HAVE_CONFIG_H #include "config.h" -#define __CDIO_CONFIG_H__ 1 #endif #ifdef HAVE_STDIO_H