summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/tests/sanitizer_libc_test.cc
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2013-05-08 14:43:49 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2013-05-08 14:43:49 +0000
commit9578a3ecfc35a264ede1135033398e2a77a6cad6 (patch)
tree5e4cb064cb5c58ec85e5a9705ae92226b18bddd3 /lib/sanitizer_common/tests/sanitizer_libc_test.cc
parent33280bba681b7bb683be01749aaba70dc06ffb6c (diff)
[nolibc] Change internal syscall API to remove reliance on libc's errno.
This change moves to a model where the error value of a system call is potentially contained in the return value itself rather than being implicit in errno. The helper function internal_iserror can be used to extract the error value from a return value. On platforms other than Linux/x86_64 this still uses errno, but other platforms are free to port their error handling to this new model. Differential Revision: http://llvm-reviews.chandlerc.com/D756 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@181436 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/tests/sanitizer_libc_test.cc')
-rw-r--r--lib/sanitizer_common/tests/sanitizer_libc_test.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/sanitizer_common/tests/sanitizer_libc_test.cc b/lib/sanitizer_common/tests/sanitizer_libc_test.cc
index 51cd66cf0..459fa39d5 100644
--- a/lib/sanitizer_common/tests/sanitizer_libc_test.cc
+++ b/lib/sanitizer_common/tests/sanitizer_libc_test.cc
@@ -74,29 +74,31 @@ TEST(SanitizerCommon, FileOps) {
internal_snprintf(temp_filename, sizeof(temp_filename),
"/tmp/sanitizer_common.tmp.%d", uid);
#endif
- fd_t fd = OpenFile(temp_filename, true);
- EXPECT_NE(fd, kInvalidFd);
+ uptr openrv = OpenFile(temp_filename, true);
+ EXPECT_EQ(false, internal_iserror(openrv));
+ fd_t fd = openrv;
EXPECT_EQ(len1, internal_write(fd, str1, len1));
EXPECT_EQ(len2, internal_write(fd, str2, len2));
internal_close(fd);
- fd = OpenFile(temp_filename, false);
- EXPECT_NE(fd, kInvalidFd);
+ openrv = OpenFile(temp_filename, false);
+ EXPECT_EQ(false, internal_iserror(openrv));
+ fd = openrv;
uptr fsize = internal_filesize(fd);
EXPECT_EQ(len1 + len2, fsize);
#if SANITIZER_TEST_HAS_STAT_H
struct stat st1, st2, st3;
- EXPECT_EQ(0, internal_stat(temp_filename, &st1));
- EXPECT_EQ(0, internal_lstat(temp_filename, &st2));
- EXPECT_EQ(0, internal_fstat(fd, &st3));
+ EXPECT_EQ(0u, internal_stat(temp_filename, &st1));
+ EXPECT_EQ(0u, internal_lstat(temp_filename, &st2));
+ EXPECT_EQ(0u, internal_fstat(fd, &st3));
EXPECT_EQ(fsize, (uptr)st3.st_size);
// Verify that internal_fstat does not write beyond the end of the supplied
// buffer.
struct stat_and_more sam;
memset(&sam, 0xAB, sizeof(sam));
- EXPECT_EQ(0, internal_fstat(fd, &sam.st));
+ EXPECT_EQ(0u, internal_fstat(fd, &sam.st));
EXPECT_EQ(0xAB, sam.z);
EXPECT_NE(0xAB, sam.st.st_size);
EXPECT_NE(0, sam.st.st_size);