Start Solaris driver test. Driver MMC sets cdio return codes better.

This commit is contained in:
rocky
2009-12-24 03:52:50 +01:00
parent 16c22fa550
commit d62c732082
5 changed files with 117 additions and 5 deletions

View File

@@ -284,6 +284,7 @@ run_mmc_cmd_solaris( void *p_user_data, unsigned int i_timeout_ms,
{ {
const _img_private_t *p_env = p_user_data; const _img_private_t *p_env = p_user_data;
struct uscsi_cmd cgc; struct uscsi_cmd cgc;
int i_rc;
memset (&cgc, 0, sizeof (struct uscsi_cmd)); memset (&cgc, 0, sizeof (struct uscsi_cmd));
cgc.uscsi_cdb = (caddr_t) p_cdb; cgc.uscsi_cdb = (caddr_t) p_cdb;
@@ -296,7 +297,29 @@ run_mmc_cmd_solaris( void *p_user_data, unsigned int i_timeout_ms,
cgc.uscsi_buflen = i_buf; cgc.uscsi_buflen = i_buf;
cgc.uscsi_cdblen = i_cdb; cgc.uscsi_cdblen = i_cdb;
return ioctl(p_env->gen.fd, USCSICMD, &cgc); i_rc = ioctl(p_env->gen.fd, USCSICMD, &cgc);
if (0 == i_rc) return DRIVER_OP_SUCCESS;
if (-1 == i_rc) {
cdio_info ("ioctl USCSICMD failed: %s", strerror(errno));
switch (errno) {
case EPERM:
return DRIVER_OP_NOT_PERMITTED;
break;
case EINVAL:
return DRIVER_OP_BAD_PARAMETER;
break;
case EFAULT:
return DRIVER_OP_BAD_POINTER;
break;
case EIO:
default:
return DRIVER_OP_ERROR;
break;
}
return DRIVER_OP_ERROR;
}
/*Not sure if this the best thing, but we'll use anyway. */
return DRIVER_OP_SUCCESS;
} }
/*! /*!

View File

@@ -81,7 +81,7 @@ timegm(struct tm *tm)
char *tz; char *tz;
tz = getenv("TZ"); tz = getenv("TZ");
setenv("TZ", "UTC", 1); setenv("TZ", "", 1);
tzset(); tzset();
ret = mktime(tm); ret = mktime(tm);
if (tz) if (tz)
@@ -344,7 +344,7 @@ iso9660_set_dtime (const struct tm *p_tm, /*out*/ iso9660_dtime_t *p_idr_date)
/* Convert seconds to minutes */ /* Convert seconds to minutes */
timezone = p_tm->tm_gmtoff / 60; timezone = p_tm->tm_gmtoff / 60;
#else #else
timezone = (p_tm->tm_isdst > 0) ? 0 : -60; timezone = (p_tm->tm_isdst > 0) ? -60 : 0;
#endif #endif
iso9660_set_dtime_with_timezone (p_tm, timezone, p_idr_date); iso9660_set_dtime_with_timezone (p_tm, timezone, p_idr_date);
} }
@@ -397,7 +397,7 @@ iso9660_set_ltime (const struct tm *p_tm, /*out*/ iso9660_ltime_t *pvd_date)
/* Set time zone in 15-minute interval encoding. */ /* Set time zone in 15-minute interval encoding. */
timezone = p_tm->tm_gmtoff / 60; timezone = p_tm->tm_gmtoff / 60;
#else #else
timezone = (p_tm->tm_isdst > 0) ? 0 : -60; timezone = (p_tm->tm_isdst > 0) ? -60 : 0;
#endif #endif
iso9660_set_ltime_with_timezone (p_tm, timezone, pvd_date); iso9660_set_ltime_with_timezone (p_tm, timezone, pvd_date);
} }

1
test/.gitignore vendored
View File

@@ -34,4 +34,5 @@
/testparanoia /testparanoia
/testpregap /testpregap
/testpregap.c /testpregap.c
/testsolaris
/testtoc /testtoc

View File

@@ -28,7 +28,7 @@ endif
hack = check_sizeof testassert testbincue testgetdevices testischar \ hack = check_sizeof testassert testbincue testgetdevices testischar \
testisocd testisocd2 testiso9660 testlinux \ testisocd testisocd2 testiso9660 testlinux \
testnrg $(testparanoia) testtoc testpregap testnrg $(testparanoia) testtoc testpregap testsolaris
EXTRA_PROGRAMS = testdefault EXTRA_PROGRAMS = testdefault
@@ -50,6 +50,9 @@ testtoc_CFLAGS = -DTEST_DIR=\"$(srcdir)\"
testlinux_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) testlinux_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
testlinux_CFLAGS = -DTEST_DIR=\"$(srcdir)\" testlinux_CFLAGS = -DTEST_DIR=\"$(srcdir)\"
testsolaris_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
testsolaris_CFLAGS = -DTEST_DIR=\"$(srcdir)\"
testpregap_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) testpregap_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
testpregap_CFLAGS = -DTEST_DIR=\"$(srcdir)\" testpregap_CFLAGS = -DTEST_DIR=\"$(srcdir)\"

85
test/testsolaris.c Normal file
View File

@@ -0,0 +1,85 @@
/* -*- C -*-
Copyright (C) 2009 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/>.
*/
/*
Regression test for cdio_nrgfile().
*/
#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_SOLARIS)) 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_linux(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);
p_cdio = cdio_open_am_linux(ppsz_drives[0], "SCSI");
if (p_cdio) {
const char *psz_access_mode = cdio_get_arg(p_cdio, "access-mode");
if (0 != strncmp(psz_access_mode, "SCSI", strlen("SCSI"))) {
fprintf(stderr,
"Got %s; Should get back %s, the access mode requested.\n",
psz_access_mode, "SCSI");
exit(2);
}
}
cdio_destroy(p_cdio);
cdio_free_device_list(ppsz_drives);
return 0;
}