Fix d8-os unit test to work with isolates.

We cannot use chdir to set the working directory on a per-isolate basis,
hence we need to specify absolute directories instead for this test to
work properly on multi-threaded runs.

R=yangguo@chromium.org
TEST=mjsunit/d8-os

Review URL: https://chromiumcodereview.appspot.com/9348051

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10639 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a0b287a3
...@@ -63,52 +63,51 @@ if (this.os && os.system) { ...@@ -63,52 +63,51 @@ if (this.os && os.system) {
} catch (e) { } catch (e) {
} }
os.mkdirp(TEST_DIR); os.mkdirp(TEST_DIR);
os.chdir(TEST_DIR);
try { try {
// Check the chdir worked. // Check the chdir worked.
os.system('ls', [TEST_DIR]); os.system('ls', [TEST_DIR]);
// Simple create dir. // Simple create dir.
os.mkdirp("dir"); os.mkdirp(TEST_DIR + "/dir");
// Create dir in dir. // Create dir in dir.
os.mkdirp("dir/foo"); os.mkdirp(TEST_DIR + "/dir/foo");
// Check that they are there. // Check that they are there.
os.system('ls', ['dir/foo']); os.system('ls', [TEST_DIR + '/dir/foo']);
// Check that we can detect when something is not there. // Check that we can detect when something is not there.
assertThrows("os.system('ls', ['dir/bar']);", "dir not there"); assertThrows("os.system('ls', [TEST_DIR + '/dir/bar']);", "dir not there");
// Check that mkdirp makes intermediate directories. // Check that mkdirp makes intermediate directories.
os.mkdirp("dir2/foo"); os.mkdirp(TEST_DIR + "/dir2/foo");
os.system("ls", ["dir2/foo"]); os.system("ls", [TEST_DIR + "/dir2/foo"]);
// Check that mkdirp doesn't mind if the dir is already there. // Check that mkdirp doesn't mind if the dir is already there.
os.mkdirp("dir2/foo"); os.mkdirp(TEST_DIR + "/dir2/foo");
os.mkdirp("dir2/foo/"); os.mkdirp(TEST_DIR + "/dir2/foo/");
// Check that mkdirp can cope with trailing / // Check that mkdirp can cope with trailing /
os.mkdirp("dir3/"); os.mkdirp(TEST_DIR + "/dir3/");
os.system("ls", ["dir3"]); os.system("ls", [TEST_DIR + "/dir3"]);
// Check that we get an error if the name is taken by a file. // Check that we get an error if the name is taken by a file.
os.system("sh", ["-c", "echo foo > file1"]); os.system("sh", ["-c", "echo foo > " + TEST_DIR + "/file1"]);
os.system("ls", ["file1"]); os.system("ls", [TEST_DIR + "/file1"]);
assertThrows("os.mkdirp('file1');", "mkdir over file1"); assertThrows("os.mkdirp(TEST_DIR + '/file1');", "mkdir over file1");
assertThrows("os.mkdirp('file1/foo');", "mkdir over file2"); assertThrows("os.mkdirp(TEST_DIR + '/file1/foo');", "mkdir over file2");
assertThrows("os.mkdirp('file1/');", "mkdir over file3"); assertThrows("os.mkdirp(TEST_DIR + '/file1/');", "mkdir over file3");
assertThrows("os.mkdirp('file1/foo/');", "mkdir over file4"); assertThrows("os.mkdirp(TEST_DIR + '/file1/foo/');", "mkdir over file4");
// Create a dir we cannot read. // Create a dir we cannot read.
os.mkdirp("dir4", 0); os.mkdirp(TEST_DIR + "/dir4", 0);
// This test fails if you are root since root can read any dir. // This test fails if you are root since root can read any dir.
assertThrows("os.chdir('dir4');", "chdir dir4 I"); assertThrows("os.chdir(TEST_DIR + '/dir4');", "chdir dir4 I");
os.rmdir("dir4"); os.rmdir(TEST_DIR + "/dir4");
assertThrows("os.chdir('dir4');", "chdir dir4 II"); assertThrows("os.chdir(TEST_DIR + '/dir4');", "chdir dir4 II");
// Set umask. // Set umask.
var old_umask = os.umask(0777); var old_umask = os.umask(0777);
// Create a dir we cannot read. // Create a dir we cannot read.
os.mkdirp("dir5"); os.mkdirp(TEST_DIR + "/dir5");
// This test fails if you are root since root can read any dir. // This test fails if you are root since root can read any dir.
assertThrows("os.chdir('dir5');", "cd dir5 I"); assertThrows("os.chdir(TEST_DIR + '/dir5');", "cd dir5 I");
os.rmdir("dir5"); os.rmdir(TEST_DIR + "/dir5");
assertThrows("os.chdir('dir5');", "chdir dir5 II"); assertThrows("os.chdir(TEST_DIR + '/dir5');", "chdir dir5 II");
os.umask(old_umask); os.umask(old_umask);
os.mkdirp("hest/fisk/../fisk/ged"); os.mkdirp(TEST_DIR + "/hest/fisk/../fisk/ged");
os.system("ls", ["hest/fisk/ged"]); os.system("ls", [TEST_DIR + "/hest/fisk/ged"]);
os.setenv("FOO", "bar"); os.setenv("FOO", "bar");
var environment = os.system("printenv"); var environment = os.system("printenv");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment