Start FreeBSD driver test. Not currently working though.

freebsd.cam: check for error in ioctl.
This commit is contained in:
R. Bernstein
2010-01-06 02:15:32 -05:00
parent d675551d19
commit f7d11d586c
5 changed files with 117 additions and 3 deletions

View File

@@ -122,8 +122,9 @@ init_freebsd_cam (_img_private_t *p_env)
return false; 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) if (ioctl (p_env->gen.fd, CAMGETPASSTHRU, &p_env->ccb) < 0)
{ {
cdio_warn ("open: %s", strerror (errno)); cdio_warn ("open: %s", strerror (errno));

1
test/.gitignore vendored
View File

@@ -19,6 +19,7 @@
/check_sizeof /check_sizeof
/test_lib_driver_util /test_lib_driver_util
/testassert /testassert
/testassert.core
/testbincue /testbincue
/testbincue.c /testbincue.c
/testdefault /testdefault

View File

@@ -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

View File

@@ -15,6 +15,9 @@
INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS) $(LIBISO9660_CFLAGS) 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_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
gnu_linux_CFLAGS = -DTEST_DIR=\"$(srcdir)\" gnu_linux_CFLAGS = -DTEST_DIR=\"$(srcdir)\"
@@ -30,7 +33,7 @@ solaris_CFLAGS = -DTEST_DIR=\"$(srcdir)\"
win32_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) win32_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
win32_CFLAGS = -DTEST_DIR=\"$(srcdir)\" 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) TESTS = $(check_PROGRAMS)

93
test/driver/freebsd.c Normal file
View File

@@ -0,0 +1,93 @@
/* -*- C -*-
Copyright (C) 2010 Rocky Bernstein <rocky@gnu.org>
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 <http://www.gnu.org/licenses/>.
*/
/*
Unit test for lib/driver/freebsd.c
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio/cdio.h>
#include <cdio/logging.h>
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <string.h>
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;
}