1 /* -*- C -*-
2 Copyright (C) 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/freebsd.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_FREEBSD)) return(77);
53 p_cdio = cdio_open_am (NULL, DRIVER_UNKNOWN, NULL);
54 if (p_cdio) {
55 const char *psz_access_mode = cdio_get_arg(p_cdio, "access-mode");
56 if (0 != strncmp(psz_access_mode, "ioctl", strlen("ioctl")) &&
57 0 != strncmp(psz_access_mode, "CAM", strlen("CAM"))) {
58 fprintf(stderr,
59 "Got %s; Should get back ioctl or CAM.\n",
60 psz_access_mode);
61 exit(2);
62 }
63 }
64 cdio_destroy(p_cdio);
65
66 ppsz_drives = cdio_get_devices(DRIVER_DEVICE);
67 if (!ppsz_drives) {
68 printf("Can't find a CD-ROM drive. Skipping test.\n");
69 exit(77);
70 }
71
72 p_cdio = cdio_open_freebsd(ppsz_drives[0]);
73 if (p_cdio) {
74 const char *psz_source = cdio_get_arg(p_cdio, "source");
75 if (0 != strncmp(psz_source, ppsz_drives[0],
76 strlen(ppsz_drives[0]))) {
77 fprintf(stderr,
78 "Got %s; should get back %s, the name we opened.\n",
79 psz_source, ppsz_drives[0]);
80 exit(1);
81 }
82 }
83 cdio_free_device_list(ppsz_drives);
84
85 return 0;
86 }
87