Index: tests/glibc_syscall_wrappers/test_fstat.c |
=================================================================== |
--- tests/glibc_syscall_wrappers/test_fstat.c (revision 0) |
+++ tests/glibc_syscall_wrappers/test_fstat.c (revision 0) |
@@ -0,0 +1,48 @@ |
+/* |
+ * Copyright 2010 The Native Client Authors. All rights reserved. |
+ * Use of this source code is governed by a BSD-style license that can |
+ * be found in the LICENSE file. |
+ */ |
+ |
+#include <assert.h> |
+#include <errno.h> |
+#include <stddef.h> |
+#include <stdio.h> |
+#include <sys/stat.h> |
+ |
+int main(int argc, char** argv) { |
+ struct stat st; |
+ FILE* file; |
+ int fd; |
+ if (2 != argc) { |
+ printf("Usage: sel_ldr test_fstat.nexe test_stat_data\n"); |
+ return 1; |
+ } |
+ st.st_size = 0; |
+ printf( |
+ "%d+%d %d+%d %d+%d %d+%d %d+%d %d+%d %d+%d %d+%d %d+%d %d+%d %d+%d %d\n", |
eaeltsin
2011/01/19 12:54:28
Probably make the output more verbose? Like
st_
halyavin
2011/01/19 14:19:25
Done. I already print size of stat structure.
|
+ offsetof(struct stat,st_dev),sizeof(st.st_dev), |
+ offsetof(struct stat,st_ino),sizeof(st.st_ino), |
+ offsetof(struct stat,st_mode),sizeof(st.st_mode), |
+ offsetof(struct stat,st_nlink),sizeof(st.st_nlink), |
+ offsetof(struct stat,st_uid),sizeof(st.st_uid), |
+ offsetof(struct stat,st_gid),sizeof(st.st_gid), |
+ offsetof(struct stat,st_rdev),sizeof(st.st_rdev), |
+ offsetof(struct stat,st_size),sizeof(st.st_size), |
+ offsetof(struct stat,st_blksize),sizeof(st.st_blksize), |
+ offsetof(struct stat,st_blocks),sizeof(st.st_blocks), |
+ offsetof(struct stat,st_atim),sizeof(st.st_atim), |
+ sizeof(st)); |
+ file = fopen( argv[1], "r"); |
+ assert (NULL != file); |
+ fd = fileno(file); |
+ errno = 0; |
+ assert (0 == fstat(fd, &st)); |
eaeltsin
2011/01/19 12:54:28
I doubt having meaningful side effects inside asse
halyavin
2011/01/19 14:19:25
Done. I use positive return values though.
|
+ printf("%d\n",(int)st.st_size); |
+ assert (0 == errno); |
+ assert (0 == fclose(file)); |
+ errno = 0; |
+ assert (-1 == fstat(-1, &st)); |
+ assert (EBADF == errno); |
+ return 0; |
+} |
Property changes on: tests/glibc_syscall_wrappers/test_fstat.c |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |