| Index: tests/syscalls/syscalls.cc
|
| diff --git a/tests/syscalls/syscalls.cc b/tests/syscalls/syscalls.cc
|
| index 4612c90d9c6532cd722a89c5544381c73d2985e9..fedd824ecd417d761cdd77768a0607cc1ca1ff0e 100644
|
| --- a/tests/syscalls/syscalls.cc
|
| +++ b/tests/syscalls/syscalls.cc
|
| @@ -103,6 +103,26 @@ bool test_unlink(const char *test_file) {
|
| return passed("test_unlink", "all");
|
| }
|
|
|
| +bool test_truncate(const char *test_file) {
|
| + return passed("test_truncate", "all");
|
| +}
|
| +
|
| +bool test_symlink_readlink(const char *test_file) {
|
| + return passed("test_symlink_readlink", "all");
|
| +}
|
| +
|
| +bool test_chmod_access(const char *test_file) {
|
| + return passed("test_chmod_access", "all");
|
| +}
|
| +
|
| +bool test_rename(const char *test_file) {
|
| + return passed("test_rename", "all");
|
| +}
|
| +
|
| +bool test_utimes(const char *test_file) {
|
| + return passed("test_utimes", "all");
|
| +}
|
| +
|
| #else
|
|
|
| // Simple test that chdir returns zero for '.'. chdir gets more
|
| @@ -211,6 +231,70 @@ bool test_unlink(const char *test_file) {
|
| return passed("test_unlink", "all");
|
| }
|
|
|
| +bool test_truncate(const char *test_file) {
|
| + char buffer[PATH_MAX];
|
| + struct stat stbuf;
|
| + int retval;
|
| + snprintf(buffer, PATH_MAX, "%s.tmp", test_file);
|
| + buffer[PATH_MAX - 1] = '\0';
|
| +
|
| + int fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
| + ASSERT_MSG(fd >= 0, "open() failed");
|
| +
|
| + retval = close(fd);
|
| + ASSERT_EQ_MSG(retval, 0, "close() failed");
|
| +
|
| + retval = truncate(buffer, 4096);
|
| + ASSERT_EQ_MSG(retval, 0, "truncate() failed");
|
| +
|
| + retval = stat(buffer, &stbuf);
|
| + ASSERT_EQ_MSG(retval, 0, "stat() failed");
|
| +
|
| + ASSERT_EQ(stbuf.st_size, 4096);
|
| +
|
| + return passed("test_truncate", "all");
|
| +}
|
| +
|
| +bool test_symlink_readlink(const char *test_file) {
|
| + char oldpath[PATH_MAX];
|
| + char newpath[PATH_MAX];
|
| + char buffer[PATH_MAX];
|
| + int retval;
|
| +
|
| + snprintf(oldpath, PATH_MAX, "%s.tmp", test_file);
|
| + buffer[PATH_MAX - 1] = '\0';
|
| +
|
| + int fd = open(oldpath, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
| + ASSERT_MSG(fd >= 0, "open() failed");
|
| +
|
| + retval = close(fd);
|
| + ASSERT_EQ_MSG(retval, 0, "close() failed");
|
| +
|
| + snprintf(newpath, PATH_MAX, "%s_link.tmp", test_file);
|
| + newpath[PATH_MAX - 1] = '\0';
|
| +
|
| + retval = symlink(oldpath, newpath);
|
| + ASSERT_EQ_MSG(retval, 0, "symlink() failed");
|
| +
|
| + retval = readlink(newpath, buffer, sizeof buffer);
|
| + ASSERT_EQ_MSG(retval, 0, "readlink() failed");
|
| + ASSERT_EQ(strcmp(oldpath, buffer), 0);
|
| +
|
| + return passed("test_symlink_readlink", "all");
|
| +}
|
| +
|
| +bool test_chmod_access(const char *test_file) {
|
| + return passed("test_chmod_access", "all");
|
| +}
|
| +
|
| +bool test_rename(const char *test_file) {
|
| + return passed("test_rename", "all");
|
| +}
|
| +
|
| +bool test_utimes(const char *test_file) {
|
| + return passed("test_utimes", "all");
|
| +}
|
| +
|
| #endif // !TESTS_USE_IRT
|
|
|
| // open() returns the new file descriptor, or -1 if an error occurred
|
| @@ -536,6 +620,11 @@ bool testSuite(const char *test_file) {
|
| ret &= test_write(test_file);
|
| ret &= test_lseek(test_file);
|
| ret &= test_unlink(test_file);
|
| + ret &= test_truncate(test_file);
|
| + ret &= test_symlink_readlink(test_file);
|
| + ret &= test_chmod_access(test_file);
|
| + ret &= test_rename(test_file);
|
| + ret &= test_utimes(test_file);
|
| ret &= test_chdir();
|
| ret &= test_getcwd();
|
| ret &= test_mkdir_rmdir(test_file);
|
|
|