]>
git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-dir-link.c
1 #include <TargetConditionals.h>
12 #include "hfs-tests.h"
13 #include "test-utils.h"
15 #include "disk-image.h"
19 static disk_image_t
*di
;
20 static char *dir1
, *dir2
;
22 static volatile bool stop_thread
;
24 void *thread(__unused
void *arg
)
27 asprintf(&path1
, "%s/dir1/..", dir1
);
28 asprintf(&path2
, "%s/Dir1/..", dir1
);
31 while (!stop_thread
) {
32 assert_no_err(stat(path1
, &sb
));
33 assert_no_err(stat(path2
, &sb
));
42 int run_dir_link(__unused test_ctx_t
*ctx
)
44 di
= disk_image_get();
47 asprintf(&tstdir
, "%s/tmp", di
->mount_point
);
49 assert(!mkdir(tstdir
, 0777) || errno
== EEXIST
);
51 asprintf(&dir1
, "%s/dir1", tstdir
);
52 asprintf(&dir2
, "%s/dir2", tstdir
);
54 systemx("/bin/rm", "-rf", dir1
, NULL
);
55 systemx("/bin/rm", "-rf", dir2
, NULL
);
58 asprintf(&dir1dir1
, "%s/dir1", dir1
);
60 assert_no_err(mkdir(dir1
, 0777));
61 assert_no_err(mkdir(dir1dir1
, 0777));
64 pthread_create(&thread_id
, NULL
, thread
, NULL
);
67 struct timeval start
, now
, elapsed
;
69 gettimeofday(&start
, NULL
);
72 asprintf(&path1
, "%s/dir2/..", tstdir
);
73 asprintf(&path2
, "%s/Dir2/..", tstdir
);
76 assert_no_err(link(dir1dir1
, dir2
));
77 assert_no_err(stat(path1
, &sb
));
78 assert_no_err(stat(path2
, &sb
));
79 assert_no_err(rmdir(dir2
));
81 gettimeofday(&now
, NULL
);
83 timersub(&now
, &start
, &elapsed
);
84 } while (elapsed
.tv_sec
< 10);
88 pthread_join(thread_id
, NULL
);
90 assert_no_err(rmdir(dir1dir1
));
91 assert_no_err(rmdir(dir1
));
102 #endif // !TARGET_OS_IPHONE