Add cdio_dirname which I think should complete what we need. Also add test of abs_path and dirname
This commit is contained in:
1
test/driver/.gitignore
vendored
1
test/driver/.gitignore
vendored
@@ -5,6 +5,7 @@
|
||||
/.libs
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
/abs_path
|
||||
/bincue
|
||||
/bincue
|
||||
/bincue.c
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS) $(LIBISO9660_CFLAGS)
|
||||
DATA_DIR = $(abs_top_srcdir)/test/data
|
||||
|
||||
abs_path_SOURCES = abs_path.c
|
||||
abs_path_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
|
||||
abs_path_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\"
|
||||
|
||||
bincue_SOURCES = helper.c bincue.c
|
||||
bincue_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
|
||||
bincue_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\"
|
||||
@@ -54,7 +58,7 @@ win32_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
|
||||
win32_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\"
|
||||
|
||||
check_PROGRAMS = \
|
||||
bincue cdrdao freebsd gnu_linux \
|
||||
abs_path bincue cdrdao freebsd gnu_linux \
|
||||
mmc_read mmc_write nrg \
|
||||
osx realpath solaris win32
|
||||
|
||||
|
||||
46
test/driver/abs_path.c
Normal file
46
test/driver/abs_path.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
# define __CDIO_CONFIG_H__ 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
extern char * cdio_abspath(const char *cwd, const char *fname);
|
||||
const char * cdio_dirname(const char *fname);
|
||||
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
const char *cue_filename[] = {
|
||||
"/tmp/foo.bar",
|
||||
"foo.bar"
|
||||
};
|
||||
const char *expect[] = {
|
||||
"/tmp/baz",
|
||||
"./baz"
|
||||
};
|
||||
|
||||
int rc=0;
|
||||
char *dest;
|
||||
int i;
|
||||
|
||||
for (i=0; i<2; i++) {
|
||||
const char *dirname = cdio_dirname(cue_filename[i]);
|
||||
dest = cdio_abspath (dirname, "baz");
|
||||
if (0 != strcmp(expect[i], dest)) {
|
||||
fprintf(stderr,
|
||||
"Incorrect: expecting %s, got %s.\n",
|
||||
expect[i], dest);
|
||||
rc=i+1;
|
||||
}
|
||||
}
|
||||
exit(rc);
|
||||
}
|
||||
Reference in New Issue
Block a user