OSDN Git Service

Fix unistd.execvpe_ENOEXEC and unistd.execvpe_failure.
authorElliott Hughes <enh@google.com>
Fri, 2 Dec 2016 01:12:49 +0000 (17:12 -0800)
committerElliott Hughes <enh@google.com>
Fri, 2 Dec 2016 01:12:49 +0000 (17:12 -0800)
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

index f8b35cc..9d809f0 100644 (file)
@@ -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;