diff --git a/lib/driver/FreeBSD/freebsd_cam.c b/lib/driver/FreeBSD/freebsd_cam.c index 2e032ea4..5ff439e7 100644 --- a/lib/driver/FreeBSD/freebsd_cam.c +++ b/lib/driver/FreeBSD/freebsd_cam.c @@ -122,8 +122,9 @@ init_freebsd_cam (_img_private_t *p_env) return false; } - (void)ioctl(p_env->gen.fd, CDIOCALLOW); - + if (ioctl(p_env->gen.fd, CDIOCALLOW) == -1) { + cdio_warn("ioctl(fd, CDIOCALLOW) failed: %s\n", strerror(errno)); + } if (ioctl (p_env->gen.fd, CAMGETPASSTHRU, &p_env->ccb) < 0) { cdio_warn ("open: %s", strerror (errno)); diff --git a/test/.gitignore b/test/.gitignore index 97d52b74..856658d9 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -19,6 +19,7 @@ /check_sizeof /test_lib_driver_util /testassert +/testassert.core /testbincue /testbincue.c /testdefault diff --git a/test/driver/.gitignore b/test/driver/.gitignore index aeaec0f7..dd7db036 100644 --- a/test/driver/.gitignore +++ b/test/driver/.gitignore @@ -1 +1,17 @@ /*~ +/.deps +/.libs +/Makefile +/Makefile.in +/freebsd +/freebsd-freebsd.o +/gnu_linux +/gnu_linux-gnu_linux.o +/mmc +/mmc-mmc.o +/osx +/osx-osx.o +/solaris +/solaris-solaris.o +/win32 +/win32-win32.o diff --git a/test/driver/Makefile.am b/test/driver/Makefile.am index 13fecfd8..f6ae6c99 100644 --- a/test/driver/Makefile.am +++ b/test/driver/Makefile.am @@ -15,6 +15,9 @@ INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS) $(LIBISO9660_CFLAGS) +freebsd_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) +freebsd_CFLAGS = -DTEST_DIR=\"$(srcdir)\" + gnu_linux_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) gnu_linux_CFLAGS = -DTEST_DIR=\"$(srcdir)\" @@ -30,7 +33,7 @@ solaris_CFLAGS = -DTEST_DIR=\"$(srcdir)\" win32_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) win32_CFLAGS = -DTEST_DIR=\"$(srcdir)\" -check_PROGRAMS = gnu_linux mmc osx solaris win32 +check_PROGRAMS = freebsd gnu_linux mmc osx solaris win32 TESTS = $(check_PROGRAMS) diff --git a/test/driver/freebsd.c b/test/driver/freebsd.c new file mode 100644 index 00000000..5c95a7a7 --- /dev/null +++ b/test/driver/freebsd.c @@ -0,0 +1,93 @@ +/* -*- C -*- + Copyright (C) 2010 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 lib/driver/freebsd.c +*/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#include +#include + +#ifdef HAVE_STDIO_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#include + +int +main(int argc, const char *argv[]) +{ + CdIo_t *p_cdio; + char **ppsz_drives=NULL; + + cdio_loglevel_default = (argc > 1) ? CDIO_LOG_DEBUG : CDIO_LOG_INFO; + /* snprintf(psz_nrgfile, sizeof(psz_nrgfile)-1, + "%s/%s", TEST_DIR, cue_file[i]); + */ + if (!cdio_have_driver(DRIVER_FREEBSD)) return(77); + ppsz_drives = cdio_get_devices(DRIVER_DEVICE); + if (!ppsz_drives) { + printf("Can't find a CD-ROM drive. Skipping test.\n"); + exit(77); + } + + p_cdio = cdio_open_freebsd(ppsz_drives[0]); + if (p_cdio) { + const char *psz_source = cdio_get_arg(p_cdio, "source"); + if (0 != strncmp(psz_source, ppsz_drives[0], + strlen(ppsz_drives[0]))) { + fprintf(stderr, + "Got %s; should get back %s, the name we opened.\n", + psz_source, ppsz_drives[0]); + exit(1); + } + } + + + cdio_destroy(p_cdio); + { + const char *access_mode[2] = {"ioctl", "CAM"}; + unsigned int i; + for (i=0; i<=1; i++) { + p_cdio = cdio_open_am_freebsd(ppsz_drives[0], access_mode[i]); + if (p_cdio) { + const char *psz_access_mode = cdio_get_arg(p_cdio, "access-mode"); + if (0 != strncmp(psz_access_mode, access_mode[i], + strlen(access_mode[i]))) { + fprintf(stderr, + "Got %s; Should get back %s, the access mode requested.\n", + psz_access_mode, access_mode[i]); + exit(2); + } + } + } + } + + + + cdio_destroy(p_cdio); + cdio_free_device_list(ppsz_drives); + + return 0; +}