Change runtest to not expect the program name on stderr (led to trouble with libtool runtime paths). Adapt add_from_file, and enable test that was disabled because of this problem. Add another test inspired by a problem report by Oliver Kaiser; the test works however, so something must be different. --HG-- branch : HEAD
diff --git a/regress/Makefile.am b/regress/Makefile.am index 855020c..9d3c2f6 100644 --- a/regress/Makefile.am +++ b/regress/Makefile.am
@@ -46,6 +46,8 @@ add_dir.test \ add_from_buffer.test \ add_from_file.test \ + add_from_file_duplicate.test \ + add_from_file_twice_duplicate.test \ add_from_filep.test \ add_from_zip.test \ encoding-ascii.test \ @@ -71,9 +73,6 @@ set_comment_revert.test \ torrent-already.test \ torrent-new.test -# problems with comparing stderr output -NOTYET= \ - add_from_file_duplicate.test AM_CPPFLAGS=-I${top_srcdir}/lib LDADD=${top_builddir}/lib/libzip.la
diff --git a/regress/add_from_file.c b/regress/add_from_file.c index cbcf5d9..f770666 100644 --- a/regress/add_from_file.c +++ b/regress/add_from_file.c
@@ -52,42 +52,45 @@ struct zip_source *zs; char buf[100]; int err; + int i; prg = argv[0]; - if (argc != 3) { - fprintf(stderr, "usage: %s archive file\n", prg); + if (argc < 3) { + fprintf(stderr, "usage: %s archive file [file ...]\n", prg); return 1; } archive = argv[1]; - file = argv[2]; - if ((za=zip_open(archive, ZIP_CREATE, &err)) == NULL) { zip_error_to_str(buf, sizeof(buf), err, errno); - fprintf(stderr, "%s: can't open zip archive %s: %s\n", prg, + fprintf(stderr, "can't open zip archive %s: %s\n", archive, buf); return 1; } - if ((zs=zip_source_file(za, file, 0, -1)) == NULL) { - fprintf(stderr, "%s: error creating file source for `%s': %s\n", prg, - file, zip_strerror(za)); - return 1; - } + for (i=2; i<argc; i++) { + file = argv[i]; + + if ((zs=zip_source_file(za, file, 0, -1)) == NULL) { + fprintf(stderr, "error creating file source for `%s': %s\n", + file, zip_strerror(za)); + return 1; + } - if ((name=strrchr(file, '/')) == NULL) - name = file; + if ((name=strrchr(file, '/')) == NULL) + name = file; - if (zip_add(za, name, zs) == -1) { - zip_source_free(zs); - fprintf(stderr, "%s: can't add file `%s': %s\n", prg, - file, zip_strerror(za)); - return 1; + if (zip_add(za, name, zs) == -1) { + zip_source_free(zs); + fprintf(stderr, "can't add file `%s': %s\n", + file, zip_strerror(za)); + return 1; + } } if (zip_close(za) == -1) { - fprintf(stderr, "%s: can't close zip archive `%s'\n", prg, + fprintf(stderr, "can't close zip archive `%s'\n", archive); return 1; }
diff --git a/regress/add_from_file_twice_duplicate.test b/regress/add_from_file_twice_duplicate.test new file mode 100644 index 0000000..94528cb --- /dev/null +++ b/regress/add_from_file_twice_duplicate.test
@@ -0,0 +1,6 @@ +# add file to zip twice, making duplicate names +program add_from_file +return 1 +args testfile.zip testfile.txt testfile.txt +file testfile.txt testfile.txt testfile.txt +stderr can't add file `testfile.txt': File already exists
diff --git a/regress/runtest b/regress/runtest index a104251..2d397e2 100755 --- a/regress/runtest +++ b/regress/runtest
@@ -288,7 +288,7 @@ test_empty "${RET}" return RET="$arg";; stderr) - echo "${PROGRAM}: $arg" >> stderr;; + echo "$arg" >> stderr;; stdout) echo "$arg" >> stdout;; *)