Rename DEBUG_OSX to a more local CDIO_DEBUG_OSX.
Add real tests for osx, maybe be useful in a more general way? Don't return on any test fail, wait until all are done (they're not mutually exclusive).
This commit is contained in:
@@ -117,14 +117,14 @@ typedef enum {
|
||||
#endif
|
||||
|
||||
// Define to get verbose debug output in stdout
|
||||
//#define DEBUG_OSX 1
|
||||
//#define CDIO_DEBUG_OSX 1
|
||||
|
||||
// Carbon.h is defining DPRINTF, but in an incompatible way
|
||||
#ifdef DPRINTF
|
||||
#undef DPRINTF
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_OSX
|
||||
#ifdef CDIO_DEBUG_OSX
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { printf("osx-driver: " fmt , ## __VA_ARGS__); } while (0)
|
||||
#else
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* -*- C -*-
|
||||
Copyright (C) 2009, 2011 Rocky Bernstein <rocky@gnu.org>
|
||||
Copyright (C) 2012 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
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
|
||||
@@ -44,12 +45,15 @@ main(int argc, const char *argv[])
|
||||
{
|
||||
CdIo_t *p_cdio;
|
||||
char **ppsz_drives=NULL;
|
||||
int ret_err = 0;
|
||||
|
||||
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_OSX)) return(77);
|
||||
|
||||
printf("Starting OS X driver test.\n");
|
||||
ppsz_drives = cdio_get_devices(DRIVER_DEVICE);
|
||||
if (!ppsz_drives) {
|
||||
printf("Can't find a CD-ROM drive. Skipping test.\n");
|
||||
@@ -73,10 +77,133 @@ main(int argc, const char *argv[])
|
||||
psz_access_mode, "OS X");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
printf("Getting default device.\n");
|
||||
const char *default_device = cdio_get_default_device(p_cdio);
|
||||
if(default_device == NULL)
|
||||
{
|
||||
fprintf(stderr, "Got no default device.\n");
|
||||
exit(3);
|
||||
}
|
||||
else
|
||||
printf("Got default device: \"%s\".\n", default_device);
|
||||
|
||||
printf("Getting device capabilities.\n");
|
||||
cdio_drive_read_cap_t i_read_cap;
|
||||
cdio_drive_write_cap_t i_write_cap;
|
||||
cdio_drive_misc_cap_t i_misc_cap;
|
||||
cdio_get_drive_cap(p_cdio, &i_read_cap, &i_write_cap, &i_misc_cap);
|
||||
if((i_read_cap & CDIO_DRIVE_CAP_ERROR) == CDIO_DRIVE_CAP_ERROR ||
|
||||
(i_read_cap & CDIO_DRIVE_CAP_UNKNOWN) == CDIO_DRIVE_CAP_ERROR ||
|
||||
(i_write_cap & CDIO_DRIVE_CAP_ERROR) == CDIO_DRIVE_CAP_ERROR ||
|
||||
(i_write_cap & CDIO_DRIVE_CAP_UNKNOWN) == CDIO_DRIVE_CAP_ERROR ||
|
||||
(i_misc_cap & CDIO_DRIVE_CAP_ERROR) == CDIO_DRIVE_CAP_ERROR ||
|
||||
(i_misc_cap & CDIO_DRIVE_CAP_UNKNOWN) == CDIO_DRIVE_CAP_ERROR)
|
||||
{
|
||||
fprintf(stderr, "Error getting capatibilites.\n");
|
||||
ret_err = 4;
|
||||
}
|
||||
printf("Capabilities: 0x%08X (READ), 0x%08X (WRITE), 0x%08X (MISC)\n",
|
||||
i_read_cap, i_write_cap, i_misc_cap);
|
||||
|
||||
printf("Getting hardware information.\n");
|
||||
cdio_hwinfo_t hwinfo;
|
||||
if(!cdio_get_hwinfo(p_cdio, &hwinfo))
|
||||
{
|
||||
fprintf(stderr, "Error getting hardware infomation.\n");
|
||||
ret_err = 5;
|
||||
}
|
||||
else
|
||||
printf("Vendor \"%s\", model \"%s\", revision \"%s\".\n",
|
||||
hwinfo.psz_vendor, hwinfo.psz_model, hwinfo.psz_revision);
|
||||
|
||||
printf("Getting disc mode.\n");
|
||||
discmode_t i_discmode;
|
||||
i_discmode = cdio_get_discmode(p_cdio);
|
||||
if(i_discmode == CDIO_DISC_MODE_ERROR)
|
||||
{
|
||||
fprintf(stderr, "Error getting disc mode.\n");
|
||||
ret_err = 6;
|
||||
}
|
||||
else
|
||||
printf("Disc mode: 0x%08X.\n", i_discmode);
|
||||
|
||||
printf("Getting disc MCN.\n");
|
||||
const char *disc_mcn = cdio_get_mcn(p_cdio);
|
||||
if(disc_mcn == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error getting MCN, enable driver DEBUG for more information.\n");
|
||||
ret_err = 7;
|
||||
}
|
||||
else
|
||||
printf("MCN: \"%s\".\n", disc_mcn);
|
||||
|
||||
printf("Setting drive speed (to an absurd high value).\n");
|
||||
driver_return_code_t i_return = cdio_set_speed(p_cdio, 1000000);
|
||||
if(i_return != DRIVER_OP_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Error setting speed.\n");
|
||||
ret_err = 8;
|
||||
}
|
||||
else
|
||||
printf("Speed set to maximum (or 1,000,000x)");
|
||||
|
||||
printf("Getting disc last LSN.\n");
|
||||
lsn_t i_lsn = cdio_get_disc_last_lsn(p_cdio);
|
||||
if(i_lsn == 0 || i_lsn == CDIO_INVALID_LSN)
|
||||
{
|
||||
fprintf(stderr, "Error getting disc lst LSN.\n");
|
||||
ret_err = 9;
|
||||
}
|
||||
else
|
||||
printf("Disc last LSN: %d.\n", i_lsn);
|
||||
|
||||
printf("Getting first track format.\n");
|
||||
track_format_t i_track_format = cdio_get_track_format(p_cdio, 1);
|
||||
if(i_track_format == TRACK_FORMAT_ERROR)
|
||||
{
|
||||
fprintf(stderr, "Error getting track format.\n");
|
||||
ret_err = 10;
|
||||
}
|
||||
else
|
||||
printf("Track format: 0x%08X.\n", i_track_format);
|
||||
|
||||
printf("Getting first track lba.\n");
|
||||
lba_t i_lba = cdio_get_track_lba(p_cdio, 1);
|
||||
if(i_lba == CDIO_INVALID_LBA)
|
||||
{
|
||||
fprintf(stderr, "Error getting track lba.\n");
|
||||
exit(11);
|
||||
}
|
||||
else
|
||||
printf("Track LBA: %d.\n", i_lba);
|
||||
|
||||
if(i_track_format != TRACK_FORMAT_ERROR)
|
||||
{
|
||||
if(i_track_format == TRACK_FORMAT_AUDIO)
|
||||
printf("Going to read 1 AUDIO sector.\n");
|
||||
else
|
||||
printf("Going to read 1 DATA sector.\n");
|
||||
|
||||
void *p_buf;
|
||||
p_buf = malloc(CDIO_CD_FRAMESIZE_RAW);
|
||||
if(i_track_format == TRACK_FORMAT_AUDIO)
|
||||
i_return = cdio_read_audio_sectors(p_cdio, p_buf, i_lba, 1);
|
||||
else
|
||||
i_return = cdio_read_data_sectors(p_cdio, p_buf, i_lba, CDIO_CD_FRAMESIZE, 1);
|
||||
|
||||
if(i_return != DRIVER_OP_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Error reading sector.\n");
|
||||
ret_err = 12;
|
||||
}
|
||||
else
|
||||
printf("Sector read correctly.\n");
|
||||
}
|
||||
}
|
||||
|
||||
cdio_destroy(p_cdio);
|
||||
cdio_free_device_list(ppsz_drives);
|
||||
|
||||
return 0;
|
||||
return ret_err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user