Chromium Code Reviews| Index: tests/syscalls/syscalls.cc |
| diff --git a/tests/syscalls/syscalls.cc b/tests/syscalls/syscalls.cc |
| index ba2099d893b9c3ef2cab9f9cecb7a1e30df00265..3cba47602ce90faa6c3099dec9cfda5eeea510e3 100644 |
| --- a/tests/syscalls/syscalls.cc |
| +++ b/tests/syscalls/syscalls.cc |
| @@ -17,6 +17,7 @@ |
| #include <stdio.h> |
| #include <string.h> |
| #include <unistd.h> |
| +#include <utime.h> |
| #include "native_client/src/include/nacl_assert.h" |
| #include "native_client/src/trusted/service_runtime/include/sys/nacl_syscalls.h" |
| @@ -26,13 +27,16 @@ |
| #define TEXT_LINE_SIZE 1024 |
| /* |
| - * TODO(sbc): remove this test once these declarations get added to the prebuilt |
| + * TODO(sbc): remove this test once these declarations get added to the |
| * newlib toolchain |
| */ |
| #ifndef __GLIBC__ |
| -extern "C" int gethostname(char *name, size_t len); |
| -extern "C" int utimes(const char *filename, const struct timeval times[2]); |
| -extern "C" int eaccess(const char *pathname, int mode); |
| +extern "C" { |
| +int gethostname(char *name, size_t len); |
| +int utimes(const char *filename, const struct timeval times[2]); |
| +int utime(const char *filename, const struct utimbuf *times); |
| +int eaccess(const char *pathname, int mode); |
| +} |
| #endif |
| /* |
| @@ -475,6 +479,23 @@ bool test_utimes(const char *test_file) { |
| return passed("test_utimes", "all"); |
| } |
| +bool test_utime(const char *test_file) { |
| + // TODO(mseaborn): Implement utimes for unsandboxed mode. |
| + if (NONSFI_MODE) |
| + return true; |
| + printf("test_utime"); |
| + struct utimbuf times; |
| + times.actime = 0; |
| + times.modtime = 0; |
| + // utimes() is currently not implemented and should always |
| + // fail with ENOSYS |
| + printf("test_utime 2"); |
| + |
| + ASSERT_EQ(utime("dummy", ×), -1); |
| + ASSERT_EQ(errno, ENOSYS); |
| + return passed("test_utime", "all"); |
| +} |
| + |
| bool test_truncate(const char *test_file) { |
| char temp_file[PATH_MAX]; |
| snprintf(temp_file, PATH_MAX, "%s.tmp_truncate", test_file); |
| @@ -1076,6 +1097,7 @@ bool testSuite(const char *test_file) { |
| #if !defined(__GLIBC__) |
| ret &= test_truncate(test_file); |
| #endif |
| + ret &= test_utime(test_file); |
|
Mark Seaborn
2015/04/07 19:08:43
Nit: Put after test_utimes() to match the definiti
Sam Clegg
2015/04/10 21:18:56
Done.
|
| ret &= test_utimes(test_file); |
| return ret; |
| } |