Skip to content

Commit aa8c21e

Browse files
committed
Switch to using #ifdef UF_IMMUTABLE
1 parent 573a00a commit aa8c21e

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

tests/dispatch_io.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ test_io_read_write(void)
246246
test_errno("open", errno, 0);
247247
test_stop();
248248
}
249-
struct stat sb;
250-
if (fstat(in, &sb)) {
251-
test_errno("fstat", errno, 0);
252-
test_stop();
253-
}
254-
const size_t siz_in = MIN(1024 * 1024, sb.st_size);
249+
struct stat sb;
250+
if (fstat(in, &sb)) {
251+
test_errno("fstat", errno, 0);
252+
test_stop();
253+
}
254+
const size_t siz_in = MIN(1024 * 1024, sb.st_size);
255255

256256
int out = mkstemp(path_out);
257257
if (out == -1) {
@@ -351,11 +351,11 @@ test_async_read(char *path, size_t size, int option, dispatch_queue_t queue,
351351
{
352352
int fd = open(path, O_RDONLY);
353353
if (fd == -1) {
354-
// Don't stop for access permission issues
355-
if (errno == EACCES) {
356-
process_data(size);
357-
return;
358-
}
354+
// Don't stop for access permission issues
355+
if (errno == EACCES) {
356+
process_data(size);
357+
return;
358+
}
359359
test_errno("Failed to open file", errno, 0);
360360
test_stop();
361361
}
@@ -575,18 +575,18 @@ test_io_from_io(void) // rdar://problem/8388909
575575
test_ptr_notnull("mkdtemp failed", path);
576576
test_stop();
577577
}
578-
#ifdef __APPLE__
578+
#ifdef UF_IMMUTABLE
579579
// Make the directory immutable
580580
if (chflags(path, UF_IMMUTABLE) == -1) {
581581
test_errno("chflags", errno, 0);
582582
test_stop();
583583
}
584584
#else
585585
// Make the directory non-read/writeable
586-
if (chmod(path, 0) == -1) {
587-
test_errno("chmod", errno, 0);
588-
test_stop();
589-
}
586+
if (chmod(path, 0) == -1) {
587+
test_errno("chmod", errno, 0);
588+
test_stop();
589+
}
590590
#endif
591591
*tmp = '/';
592592
dispatch_io_t io = dispatch_io_create_with_path(DISPATCH_IO_RANDOM, path,
@@ -605,7 +605,7 @@ test_io_from_io(void) // rdar://problem/8388909
605605
dispatch_group_enter(g);
606606
dispatch_io_write(io, 0, tdata, q, ^(bool done, dispatch_data_t data_out,
607607
int err_out) {
608-
#ifdef __APPLE__
608+
#ifdef UF_IMMUTABLE
609609
test_errno("error from write to immutable directory", err_out, EPERM);
610610
#else
611611
test_errno("error from write to write protected directory", err_out, EACCES);
@@ -622,18 +622,18 @@ test_io_from_io(void) // rdar://problem/8388909
622622
dispatch_release(io);
623623
test_group_wait(g);
624624
*tmp = '\0';
625-
#ifdef __APPLE__
626-
// Change the directory to mutable
627-
if (chflags(path, 0) == -1) {
628-
test_errno("chflags", errno, 0);
629-
test_stop();
630-
}
625+
#ifdef UF_IMMUTABLE
626+
// Change the directory to mutable
627+
if (chflags(path, 0) == -1) {
628+
test_errno("chflags", errno, 0);
629+
test_stop();
630+
}
631631
#else
632-
// Change the directory to user read/write/execute
633-
if (chmod(path, S_IRUSR | S_IWUSR | S_IXUSR) == -1) {
634-
test_errno("chmod", errno, 0);
635-
test_stop();
636-
}
632+
// Change the directory to user read/write/execute
633+
if (chmod(path, S_IRUSR | S_IWUSR | S_IXUSR) == -1) {
634+
test_errno("chmod", errno, 0);
635+
test_stop();
636+
}
637637
#endif
638638
const char *path_in = "/dev/urandom";
639639
int in = open(path_in, O_RDONLY);

0 commit comments

Comments
 (0)