2004-07-09 20:47:08 +00:00
|
|
|
/*
|
2006-02-12 09:38:36 +00:00
|
|
|
$Id: testbincue.c,v 1.7 2006/02/12 09:38:36 rocky Exp $
|
2004-07-09 20:47:08 +00:00
|
|
|
|
2006-02-12 09:38:36 +00:00
|
|
|
Copyright (C) 2004, 2006 Rocky Bernstein <rocky@panix.com>
|
2004-07-09 20:47:08 +00:00
|
|
|
|
|
|
|
|
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 2 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, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Regression test for cdio_binfile().
|
|
|
|
|
*/
|
|
|
|
|
#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>
|
|
|
|
|
|
2004-09-05 13:03:46 +00:00
|
|
|
#ifndef TEST_DIR
|
|
|
|
|
#define TEST_DIR "."
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-07-09 20:47:08 +00:00
|
|
|
#define NUM_GOOD_CUES 2
|
2004-07-10 01:18:02 +00:00
|
|
|
#define NUM_BAD_CUES 7
|
2004-07-09 20:47:08 +00:00
|
|
|
int
|
|
|
|
|
main(int argc, const char *argv[])
|
|
|
|
|
{
|
|
|
|
|
const char *cue_file[NUM_GOOD_CUES] = {
|
|
|
|
|
"cdda.cue",
|
|
|
|
|
"isofs-m1.cue",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const char *badcue_file[NUM_BAD_CUES] = {
|
|
|
|
|
"bad-cat1.cue",
|
|
|
|
|
"bad-cat2.cue",
|
|
|
|
|
"bad-cat3.cue",
|
2004-07-10 01:18:02 +00:00
|
|
|
"bad-mode1.cue",
|
|
|
|
|
"bad-msf-1.cue",
|
|
|
|
|
"bad-msf-2.cue",
|
|
|
|
|
"bad-msf-3.cue",
|
2004-07-09 20:47:08 +00:00
|
|
|
};
|
|
|
|
|
int ret=0;
|
|
|
|
|
unsigned int i;
|
2004-09-05 13:03:46 +00:00
|
|
|
char psz_cuefile[500];
|
2004-07-09 20:47:08 +00:00
|
|
|
|
2004-09-05 13:03:46 +00:00
|
|
|
psz_cuefile[sizeof(psz_cuefile)-1] = '\0';
|
2004-07-09 20:47:08 +00:00
|
|
|
cdio_loglevel_default = (argc > 1) ? CDIO_LOG_DEBUG : CDIO_LOG_INFO;
|
|
|
|
|
for (i=0; i<NUM_GOOD_CUES; i++) {
|
2004-10-26 01:21:05 +00:00
|
|
|
char *psz_binfile;
|
2004-09-05 13:03:46 +00:00
|
|
|
snprintf(psz_cuefile, sizeof(psz_cuefile)-1,
|
|
|
|
|
"%s/%s", TEST_DIR, cue_file[i]);
|
2004-10-26 01:21:05 +00:00
|
|
|
psz_binfile = cdio_is_cuefile(psz_cuefile);
|
|
|
|
|
if (!psz_binfile) {
|
2004-07-09 20:47:08 +00:00
|
|
|
printf("Incorrect: %s doesn't parse as a CDRWin CUE file.\n",
|
|
|
|
|
cue_file[i]);
|
|
|
|
|
ret=i+1;
|
|
|
|
|
} else {
|
|
|
|
|
printf("Correct: %s parses as a CDRWin CUE file.\n",
|
|
|
|
|
cue_file[i]);
|
2004-10-26 01:21:05 +00:00
|
|
|
free(psz_binfile);
|
2004-07-09 20:47:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i=0; i<NUM_BAD_CUES; i++) {
|
2004-10-26 01:21:05 +00:00
|
|
|
char *psz_binfile;
|
2004-09-05 13:03:46 +00:00
|
|
|
snprintf(psz_cuefile, sizeof(psz_cuefile)-1,
|
|
|
|
|
"%s/%s", TEST_DIR, badcue_file[i]);
|
2004-10-26 01:21:05 +00:00
|
|
|
psz_binfile=cdio_is_cuefile(psz_cuefile);
|
|
|
|
|
if (!psz_binfile) {
|
2004-07-09 20:47:08 +00:00
|
|
|
printf("Correct: %s doesn't parse as a CDRWin CUE file.\n",
|
|
|
|
|
badcue_file[i]);
|
|
|
|
|
} else {
|
|
|
|
|
printf("Incorrect: %s parses as a CDRWin CUE file.\n",
|
|
|
|
|
badcue_file[i]);
|
2004-10-26 01:21:05 +00:00
|
|
|
free(psz_binfile);
|
2004-07-09 20:47:08 +00:00
|
|
|
ret+=50*i+1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-21 11:05:00 +00:00
|
|
|
{
|
|
|
|
|
CdIo_t *p_cdio = cdio_open ("cdda.cue", DRIVER_UNKNOWN);
|
|
|
|
|
if (!p_cdio) {
|
|
|
|
|
printf("Can't open cdda.cue\n");
|
|
|
|
|
ret = -1;
|
|
|
|
|
} else {
|
|
|
|
|
/* Just test performing some operations. */
|
|
|
|
|
driver_return_code_t drc = cdio_set_blocksize(p_cdio, 2048);
|
2006-02-12 09:38:36 +00:00
|
|
|
char *psz_device = cdio_get_default_device(p_cdio);
|
|
|
|
|
if (psz_device)
|
|
|
|
|
free(psz_device);
|
|
|
|
|
else
|
|
|
|
|
ret = -2;
|
2006-01-21 11:05:00 +00:00
|
|
|
drc = cdio_set_speed(p_cdio, 5);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-09 20:47:08 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|