Skip to content

Commit

Permalink
Merge pull request #1736 from uckelman-sf/mingw_fixes
Browse files Browse the repository at this point in the history
Fixes for running tests on Windows (or Wine)
  • Loading branch information
mmatuska committed Sep 5, 2022
2 parents 66d6e8a + 4471283 commit 01a280f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
14 changes: 11 additions & 3 deletions libarchive/archive_read_support_format_mtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1250,9 +1250,17 @@ parse_file(struct archive_read *a, struct archive_entry *entry,
archive_entry_filetype(entry) == AE_IFDIR) {
mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
__archive_ensure_cloexec_flag(mtree->fd);
if (mtree->fd == -1 &&
(errno != ENOENT ||
archive_strlen(&mtree->contents_name) > 0)) {
if (mtree->fd == -1 && (
#if defined(_WIN32) && !defined(__CYGWIN__)
/*
* On Windows, attempting to open a file with an
* invalid name result in EINVAL (Error 22)
*/
(errno != ENOENT && errno != EINVAL)
#else
errno != ENOENT
#endif
|| archive_strlen(&mtree->contents_name) > 0)) {
archive_set_error(&a->archive, errno,
"Can't open %s", path);
r = ARCHIVE_WARN;
Expand Down
30 changes: 30 additions & 0 deletions libarchive/test/test_archive_match_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ test_newer_ctime_than_file_mbs(void)
struct archive_entry *ae;
struct archive *m;

#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif

if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
Expand Down Expand Up @@ -435,6 +440,11 @@ test_newer_ctime_than_file_wcs(void)
struct archive_entry *ae;
struct archive *m;

#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif

if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
Expand Down Expand Up @@ -782,6 +792,11 @@ test_older_ctime_than_file_mbs(void)
struct archive_entry *ae;
struct archive *m;

#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif

if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
Expand Down Expand Up @@ -897,6 +912,11 @@ test_older_ctime_than_file_wcs(void)
struct archive_entry *ae;
struct archive *m;

#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif

if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
Expand Down Expand Up @@ -1073,6 +1093,11 @@ test_ctime_between_files_mbs(void)
struct archive_entry *ae;
struct archive *m;

#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif

if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
Expand Down Expand Up @@ -1132,6 +1157,11 @@ test_ctime_between_files_wcs(void)
struct archive_entry *ae;
struct archive *m;

#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif

if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
Expand Down

0 comments on commit 01a280f

Please sign in to comment.