Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc

Issue 795213003: Fix handling of free descriptors when calling dup2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
index a93d0305034a3992050c3e3bbd1a626db6bbd8ef..0b9b3ddd01ef1df3f44251a8e3f5bc37819471e3 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
@@ -527,6 +527,19 @@ TEST_F(KernelProxyTest, MemMountDup) {
// fd, new_fd, dup_fd -> "/bar"
}
+TEST_F(KernelProxyTest, Dup2Allocation) {
Sam Clegg 2014/12/12 00:44:40 Comment here? I would like a better test name bu
bradn 2014/12/12 22:58:18 Added more.
+ int fd = ki_open("/foo", O_CREAT | O_RDWR, 0777);
+ ASSERT_GT(fd, -1);
+
+ int dup_fd = ki_dup(fd);
+ ASSERT_EQ(fd + 1, dup_fd);
binji 2014/12/12 18:55:20 Is this guaranteed to be true? The fd returned sho
bradn 2014/12/12 22:58:18 Commented more verbosely. The test assumes the ini
+
+ ASSERT_EQ(100, ki_dup2(fd, 100));
+
+ int dup_fd2 = ki_dup(fd);
+ ASSERT_EQ(fd + 2, dup_fd2);
+}
+
TEST_F(KernelProxyTest, Lstat) {
int fd = ki_open("/foo", O_CREAT | O_RDWR, 0777);
ASSERT_GT(fd, -1);

Powered by Google App Engine
This is Rietveld 408576698