From 5965bf09d4da45a86c4fbedc2ee33be0b0eb97bb Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 1 Dec 2016 17:12:49 -0800 Subject: [PATCH] Fix unistd.execvpe_ENOEXEC and unistd.execvpe_failure. These passed when run directly (as root) but failed in CTS' more restricted environment. Bug: http://b/33270012 Test: ran CTS tests Change-Id: Iccb407769fe356c30d52a0a99fff11862134a250 --- tests/unistd_test.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp index f8b35cc02..9d809f065 100644 --- a/tests/unistd_test.cpp +++ b/tests/unistd_test.cpp @@ -1347,7 +1347,8 @@ TEST(UNISTD_TEST, execvpe_failure) { ExecTestHelper eth; errno = 0; ASSERT_EQ(-1, execvpe("this-does-not-exist", eth.GetArgs(), eth.GetEnv())); - ASSERT_EQ(ENOENT, errno); + // Running in CTS we might not even be able to search all directories in $PATH. + ASSERT_TRUE(errno == ENOENT || errno == EACCES); } TEST(UNISTD_TEST, execvpe) { @@ -1380,8 +1381,8 @@ TEST(UNISTD_TEST, execvpe_ENOEXEC) { ASSERT_EQ(-1, execvpe(basename(tf.filename), eth.GetArgs(), eth.GetEnv())); ASSERT_EQ(EACCES, errno); - // Make it executable. - ASSERT_EQ(0, chmod(tf.filename, 0555)); + // Make it executable (and keep it writable because we're going to rewrite it below). + ASSERT_EQ(0, chmod(tf.filename, 0777)); // TemporaryFile will have a writable fd, so we can test ETXTBSY while we're here... errno = 0;