Lines Matching refs:fd
45 void* map = mmap(nullptr, 100, PROT_READ, MAP_SHARED, tf.fd, 1); in TEST()
52 void* map = mmap64(nullptr, 100, PROT_READ, MAP_SHARED, tf.fd, 1); in TEST()
64 ASSERT_EQ(STR_SSIZE(STRING_MSG), write(tf.fd, STRING_MSG, sizeof(STRING_MSG))); in TEST()
66 void* map = mmap(nullptr, sizeof(STRING_MSG), PROT_READ, MAP_SHARED, tf.fd, 0); in TEST()
78 ASSERT_EQ(STR_SSIZE(INITIAL_MSG), write(tf.fd, INITIAL_MSG, sizeof(INITIAL_MSG))); in TEST()
79 lseek(tf.fd, 0, SEEK_SET); in TEST()
81 void* map = mmap(nullptr, sizeof(STRING_MSG), PROT_WRITE, MAP_SHARED, tf.fd, 0); in TEST()
83 close(tf.fd); in TEST()
89 tf.fd = open(tf.path, O_RDWR); in TEST()
92 ASSERT_EQ(STR_SSIZE(STRING_MSG), read(tf.fd, buf, sizeof(STRING_MSG))); in TEST()
107 ASSERT_EQ(STR_SSIZE(PAGE0_MSG), write(tf.fd, PAGE0_MSG, sizeof(PAGE0_MSG))); in TEST()
108 ASSERT_NE(-1, lseek(tf.fd, pagesize, SEEK_SET)); in TEST()
109 ASSERT_EQ(STR_SSIZE(PAGE1_MSG), write(tf.fd, PAGE1_MSG, sizeof(PAGE1_MSG))); in TEST()
110 ASSERT_NE(-1, lseek(tf.fd, 2 * pagesize, SEEK_SET)); in TEST()
111 ASSERT_EQ(STR_SSIZE(PAGE2_MSG), write(tf.fd, PAGE2_MSG, sizeof(PAGE2_MSG))); in TEST()
112 ASSERT_NE(-1, lseek(tf.fd, 3 * pagesize - sizeof(END_MSG), SEEK_SET)); in TEST()
113 ASSERT_EQ(STR_SSIZE(END_MSG), write(tf.fd, END_MSG, sizeof(END_MSG))); in TEST()
115 ASSERT_NE(-1, lseek(tf.fd, 0, SEEK_SET)); in TEST()
117 void* map = mmap(nullptr, pagesize, PROT_READ, MAP_SHARED, tf.fd, pagesize); in TEST()
125 map = mmap(nullptr, pagesize, PROT_READ, MAP_SHARED, tf.fd, 2 * pagesize); in TEST()
143 ASSERT_EQ(STR_SSIZE(PAGE0_MSG), write(tf.fd, PAGE0_MSG, sizeof(PAGE0_MSG))); in TEST()
144 ASSERT_NE(-1, lseek(tf.fd, pagesize, SEEK_SET)); in TEST()
145 ASSERT_EQ(STR_SSIZE(PAGE1_MSG), write(tf.fd, PAGE1_MSG, sizeof(PAGE1_MSG))); in TEST()
146 ASSERT_NE(-1, lseek(tf.fd, 2 * pagesize, SEEK_SET)); in TEST()
147 ASSERT_EQ(STR_SSIZE(PAGE2_MSG), write(tf.fd, PAGE2_MSG, sizeof(PAGE2_MSG))); in TEST()
148 ASSERT_NE(-1, lseek(tf.fd, 3 * pagesize - sizeof(END_MSG), SEEK_SET)); in TEST()
149 ASSERT_EQ(STR_SSIZE(END_MSG), write(tf.fd, END_MSG, sizeof(END_MSG))); in TEST()
151 ASSERT_NE(-1, lseek(tf.fd, 0, SEEK_SET)); in TEST()
153 void* map = mmap(nullptr, pagesize, PROT_WRITE, MAP_SHARED, tf.fd, pagesize); in TEST()
155 close(tf.fd); in TEST()
160 tf.fd = open(tf.path, O_RDWR); in TEST()
161 map = mmap(nullptr, pagesize, PROT_WRITE, MAP_SHARED, tf.fd, 2 * pagesize); in TEST()
163 close(tf.fd); in TEST()
168 tf.fd = open(tf.path, O_RDWR); in TEST()
170 ASSERT_EQ(static_cast<ssize_t>(pagesize), read(tf.fd, buf, pagesize)); in TEST()
172 ASSERT_NE(-1, lseek(tf.fd, pagesize, SEEK_SET)); in TEST()
173 ASSERT_EQ(static_cast<ssize_t>(pagesize), read(tf.fd, buf, pagesize)); in TEST()
175 ASSERT_NE(-1, lseek(tf.fd, 2 * pagesize, SEEK_SET)); in TEST()
176 ASSERT_EQ(static_cast<ssize_t>(pagesize), read(tf.fd, buf, pagesize)); in TEST()
187 ASSERT_EQ(static_cast<ssize_t>(pagesize), write(tempfile.fd, buf, pagesize)); in TEST()
188 void* map = mmap(nullptr, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, tempfile.fd, 0); in TEST()
297 int fd = memfd_create("doesn't matter", 0); in TEST()
298 if (fd == -1 && errno == ENOSYS) GTEST_SKIP() << "no memfd_create() in this kernel"; in TEST()
299 ASSERT_NE(-1, fd) << strerror(errno); in TEST()
301 int f = fcntl(fd, F_GETFD); in TEST()
304 close(fd); in TEST()
307 fd = memfd_create("doesn't matter", MFD_CLOEXEC); in TEST()
308 f = fcntl(fd, F_GETFD); in TEST()
314 ASSERT_TRUE(android::base::WriteStringToFd(expected, fd)); in TEST()
315 ASSERT_EQ(0, lseek(fd, 0, SEEK_SET)); in TEST()
317 ASSERT_TRUE(android::base::ReadFdToString(fd, &actual)); in TEST()
320 close(fd); in TEST()