1 /* -*- C -*-
2 Copyright (C) 2009, 2010, 2012 Rocky Bernstein <rocky@gnu.org>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /*
19 Unit test for lib/driver/gnu_linux.c
20 */
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #ifdef HAVE_STDIO_H
26 #include <stdio.h>
27 #endif
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
30 #endif
31 #ifdef HAVE_STDLIB_H
32 #include <stdlib.h>
33 #endif
34 #ifdef HAVE_STRING_H
35 #include <string.h>
36 #endif
37
38 #include "helper.h"
39
40 int
main(int argc,const char * argv[])41 main(int argc, const char *argv[])
42 {
43 CdIo_t *p_cdio;
44 char **ppsz_drives=NULL;
45
46 cdio_log_set_handler(log_handler);
47 cdio_loglevel_default = (argc > 1) ? CDIO_LOG_DEBUG : CDIO_LOG_INFO;
48 /* snprintf(psz_nrgfile, sizeof(psz_nrgfile)-1,
49 "%s/%s", TEST_DIR, cue_file[i]);
50 */
51 if (!cdio_have_driver(DRIVER_LINUX)) return(77);
52 ppsz_drives = cdio_get_devices(DRIVER_DEVICE);
53 if (!ppsz_drives) {
54 printf("Can't find a CD-ROM drive. Skipping test.\n");
55 exit(77);
56 }
57
58 p_cdio = cdio_open_linux(ppsz_drives[0]);
59 if (p_cdio) {
60 const char *psz_source = NULL, *psz_scsi_tuple;
61 lsn_t lsn;
62
63 reset_counts();
64 lsn = cdio_get_track_lsn(p_cdio, CDIO_CD_MAX_TRACKS+1);
65 assert_equal_int(CDIO_INVALID_LSN, lsn,
66 "cdio_get_track_lsn with too large of a track number");
67 reset_counts();
68
69 check_get_arg_source(p_cdio, ppsz_drives[0]);
70 check_mmc_supported(p_cdio, 3);
71
72 psz_scsi_tuple = cdio_get_arg(p_cdio, "scsi-tuple");
73 if (psz_scsi_tuple == NULL) {
74 fprintf(stderr, "cdio_get_arg(\"scsi-tuple\") returns NULL.\n");
75 cdio_destroy(p_cdio);
76 exit(3);
77 }
78 if (cdio_loglevel_default == CDIO_LOG_DEBUG)
79 printf("Drive '%s' has cdio_get_arg(\"scsi-tuple\") = '%s'\n",
80 psz_source, psz_scsi_tuple);
81 cdio_destroy(p_cdio);
82 }
83
84 p_cdio = cdio_open_am_linux(ppsz_drives[0], "MMC_RDWR");
85 if (p_cdio) {
86 check_access_mode(p_cdio, "MMC_RDWR");
87 }
88
89 cdio_destroy(p_cdio);
90 cdio_free_device_list(ppsz_drives);
91
92 return 0;
93 }
94