1 /* -*- C -*-
2 Copyright (C) 2009, 2011 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/solaris.c
20 */
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #define __CDIO_CONFIG_H__ 1
24 #endif
25
26 #ifdef HAVE_STDIO_H
27 #include <stdio.h>
28 #endif
29 #ifdef HAVE_SYS_TYPES_H
30 #include <sys/types.h>
31 #endif
32 #ifdef HAVE_STDLIB_H
33 #include <stdlib.h>
34 #endif
35 #ifdef HAVE_STRING_H
36 #include <string.h>
37 #endif
38
39 #include <cdio/cdio.h>
40 #include <cdio/logging.h>
41
42 int
main(int argc,const char * argv[])43 main(int argc, const char *argv[])
44 {
45 CdIo_t *p_cdio;
46 char **ppsz_drives=NULL;
47
48 cdio_loglevel_default = (argc > 1) ? CDIO_LOG_DEBUG : CDIO_LOG_INFO;
49 /* snprintf(psz_nrgfile, sizeof(psz_nrgfile)-1,
50 "%s/%s", TEST_DIR, cue_file[i]);
51 */
52 if (!cdio_have_driver(DRIVER_SOLARIS)) return(77);
53 ppsz_drives = cdio_get_devices(DRIVER_DEVICE);
54 if (!ppsz_drives) {
55 printf("Can't find a CD-ROM drive. Skipping test.\n");
56 exit(77);
57 }
58
59 p_cdio = cdio_open_linux(ppsz_drives[0]);
60 if (p_cdio) {
61 const char *psz_source = cdio_get_arg(p_cdio, "source");
62 if (0 != strncmp(psz_source, ppsz_drives[0],
63 strlen(ppsz_drives[0]))) {
64 fprintf(stderr,
65 "Got %s; should get back %s, the name we opened.\n",
66 psz_source, ppsz_drives[0]);
67 exit(1);
68 }
69 }
70
71
72 cdio_destroy(p_cdio);
73 p_cdio = cdio_open_am_linux(ppsz_drives[0], "SCSI");
74 if (p_cdio) {
75 const char *psz_access_mode = cdio_get_arg(p_cdio, "access-mode");
76
77 if (0 != strncmp(psz_access_mode, "SCSI", strlen("SCSI"))) {
78 fprintf(stderr,
79 "Got %s; Should get back %s, the access mode requested.\n",
80 psz_access_mode, "SCSI");
81 exit(2);
82 }
83 }
84
85 cdio_destroy(p_cdio);
86 cdio_free_device_list(ppsz_drives);
87
88 return 0;
89 }
90