-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca686c1
commit e64e82e
Showing
4 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -421,6 +421,7 @@ set(BASIC_TESTS | |
read_nothing | ||
readdir | ||
readlink | ||
readlinkat | ||
readv | ||
rlimit | ||
robust_futex | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* -*- Mode: C; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ | ||
|
||
#include "rrutil.h" | ||
|
||
#define BUF_SIZE 10 | ||
#define BUF2_SIZE 1000 | ||
|
||
int main(int argc, char* argv[]) { | ||
char path[] = "rr-test-file-XXXXXX"; | ||
char dpath[] = "rr-test-dir-XXXXXX"; | ||
const char *dir_path = mkdtemp(dpath); | ||
int count; | ||
char link[PATH_MAX]; | ||
char* buf = allocate_guard(BUF_SIZE, 'q'); | ||
char* buf2 = allocate_guard(BUF2_SIZE, 'r'); | ||
|
||
test_assert(0 <= dirfd); | ||
|
||
chdir(dir_path); | ||
|
||
for (count = 0;; ++count) { | ||
sprintf(link, "rr-test-link-%d", count); | ||
int ret = symlink(path, link); | ||
if (ret == 0) { | ||
break; | ||
} | ||
test_assert(errno == EEXIST); | ||
} | ||
int ret = readlinkat(AT_FDCWD, link, buf, BUF_SIZE); | ||
test_assert(BUF_SIZE == ret); | ||
test_assert(0 == memcmp(path, buf, BUF_SIZE)); | ||
verify_guard(BUF_SIZE, buf); | ||
|
||
test_assert(strlen(path) == readlinkat(AT_FDCWD, link, buf2, BUF2_SIZE)); | ||
test_assert(0 == memcmp(path, buf2, strlen(path))); | ||
verify_guard(BUF2_SIZE, buf2); | ||
|
||
test_assert(0 == unlink(link)); | ||
|
||
atomic_puts("EXIT-SUCCESS"); | ||
return 0; | ||
} |