xref: /xnu-12377.41.6/tests/fduiomove.c (revision bbb1b6f9e71b8cdde6e5cd6f4841f207dee3d828)
1*bbb1b6f9SApple OSS Distributions #include <darwintest.h>
2*bbb1b6f9SApple OSS Distributions #include <darwintest_utils.h>
3*bbb1b6f9SApple OSS Distributions #include <crt_externs.h>
4*bbb1b6f9SApple OSS Distributions #include <sys/types.h>
5*bbb1b6f9SApple OSS Distributions #include <sys/uio.h>
6*bbb1b6f9SApple OSS Distributions #include <unistd.h>
7*bbb1b6f9SApple OSS Distributions #include <fcntl.h>
8*bbb1b6f9SApple OSS Distributions 
9*bbb1b6f9SApple OSS Distributions T_GLOBAL_META(
10*bbb1b6f9SApple OSS Distributions 	T_META_NAMESPACE("xnu.fd"),
11*bbb1b6f9SApple OSS Distributions 	T_META_RUN_CONCURRENTLY(true));
12*bbb1b6f9SApple OSS Distributions 
13*bbb1b6f9SApple OSS Distributions T_DECL(fd_invalid_pread, "Test for 66711697: make sure we get EFAULT", T_META_TAG_VM_PREFERRED)
14*bbb1b6f9SApple OSS Distributions {
15*bbb1b6f9SApple OSS Distributions 	int fd;
16*bbb1b6f9SApple OSS Distributions 	ssize_t rc;
17*bbb1b6f9SApple OSS Distributions 
18*bbb1b6f9SApple OSS Distributions 	fd = open(*_NSGetProgname(), O_RDONLY);
19*bbb1b6f9SApple OSS Distributions 	T_ASSERT_POSIX_SUCCESS(fd, "open(self)");
20*bbb1b6f9SApple OSS Distributions 
21*bbb1b6f9SApple OSS Distributions 	rc = pread(fd, (void *)~0, 64 << 10, 0);
22*bbb1b6f9SApple OSS Distributions 	T_ASSERT_POSIX_FAILURE(rc, EFAULT, "pread should fail with EFAULT");
23*bbb1b6f9SApple OSS Distributions 
24*bbb1b6f9SApple OSS Distributions 	close(fd);
25*bbb1b6f9SApple OSS Distributions }
26