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

Unified Diff: test/mjsunit/d8-os.js

Issue 7491057: Make d8-os test less flaky. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/d8-os.js
diff --git a/test/mjsunit/d8-os.js b/test/mjsunit/d8-os.js
index 630a39e9660d84651a62e56f44356e76feeab8bf..c3a34cdde398089223c7bb048cc4e3b376b1ea94 100644
--- a/test/mjsunit/d8-os.js
+++ b/test/mjsunit/d8-os.js
@@ -30,6 +30,9 @@
// implemented on Windows, and even if it were then many of the things
// we are calling would not be available.
+var TEST_DIR = "d8-os-test-directory-" + ((Math.random() * 65535) | 0);
+
+
function arg_error(str) {
try {
eval(str);
@@ -53,96 +56,98 @@ function str_error(str) {
if (this.os && os.system) {
try {
// Delete the dir if it is lying around from last time.
- os.system("ls", ["d8-os-test-directory"]);
- os.system("rm", ["-r", "d8-os-test-directory"]);
+ os.system("ls", [TEST_DIR]);
+ os.system("rm", ["-r", TEST_DIR]);
} catch (e) {
}
- os.mkdirp("d8-os-test-directory");
- os.chdir("d8-os-test-directory");
- // Check the chdir worked.
- os.system('ls', ['../d8-os-test-directory']);
- // Simple create dir.
- os.mkdirp("dir");
- // Create dir in dir.
- os.mkdirp("dir/foo");
- // Check that they are there.
- os.system('ls', ['dir/foo']);
- // Check that we can detect when something is not there.
- assertThrows("os.system('ls', ['dir/bar']);", "dir not there");
- // Check that mkdirp makes intermediate directories.
- os.mkdirp("dir2/foo");
- os.system("ls", ["dir2/foo"]);
- // Check that mkdirp doesn't mind if the dir is already there.
- os.mkdirp("dir2/foo");
- os.mkdirp("dir2/foo/");
- // Check that mkdirp can cope with trailing /
- os.mkdirp("dir3/");
- os.system("ls", ["dir3"]);
- // Check that we get an error if the name is taken by a file.
- os.system("sh", ["-c", "echo foo > file1"]);
- os.system("ls", ["file1"]);
- assertThrows("os.mkdirp('file1');", "mkdir over file1");
- assertThrows("os.mkdirp('file1/foo');", "mkdir over file2");
- assertThrows("os.mkdirp('file1/');", "mkdir over file3");
- assertThrows("os.mkdirp('file1/foo/');", "mkdir over file4");
- // Create a dir we cannot read.
- os.mkdirp("dir4", 0);
- // This test fails if you are root since root can read any dir.
- assertThrows("os.chdir('dir4');", "chdir dir4 I");
- os.rmdir("dir4");
- assertThrows("os.chdir('dir4');", "chdir dir4 II");
- // Set umask.
- var old_umask = os.umask(0777);
- // Create a dir we cannot read.
- os.mkdirp("dir5");
- // This test fails if you are root since root can read any dir.
- assertThrows("os.chdir('dir5');", "cd dir5 I");
- os.rmdir("dir5");
- assertThrows("os.chdir('dir5');", "chdir dir5 II");
- os.umask(old_umask);
-
- os.mkdirp("hest/fisk/../fisk/ged");
- os.system("ls", ["hest/fisk/ged"]);
-
- os.setenv("FOO", "bar");
- var environment = os.system("printenv");
- assertTrue(/FOO=bar/.test(environment));
-
- // Check we time out.
- var have_sleep = true;
- var have_echo = true;
+ os.mkdirp(TEST_DIR);
+ os.chdir(TEST_DIR);
try {
- os.system("ls", ["/bin/sleep"]);
- } catch (e) {
- have_sleep = false;
- }
- try {
- os.system("ls", ["/bin/echo"]);
- } catch (e) {
- have_echo = false;
- }
- if (have_sleep) {
- assertThrows("os.system('sleep', ['2000'], 200);", "sleep 1");
-
- // Check we time out with total time.
- assertThrows("os.system('sleep', ['2000'], -1, 200);", "sleep 2");
-
- // Check that -1 means no timeout.
- os.system('sleep', ['1'], -1, -1);
-
- }
-
- // Check that we don't fill up the process table with zombies.
- // Disabled because it's too slow.
- if (have_echo) {
- //for (var i = 0; i < 65536; i++) {
+ // Check the chdir worked.
+ os.system('ls', ['../' + TEST_DIR]);
+ // Simple create dir.
+ os.mkdirp("dir");
+ // Create dir in dir.
+ os.mkdirp("dir/foo");
+ // Check that they are there.
+ os.system('ls', ['dir/foo']);
+ // Check that we can detect when something is not there.
+ assertThrows("os.system('ls', ['dir/bar']);", "dir not there");
+ // Check that mkdirp makes intermediate directories.
+ os.mkdirp("dir2/foo");
+ os.system("ls", ["dir2/foo"]);
+ // Check that mkdirp doesn't mind if the dir is already there.
+ os.mkdirp("dir2/foo");
+ os.mkdirp("dir2/foo/");
+ // Check that mkdirp can cope with trailing /
+ os.mkdirp("dir3/");
+ os.system("ls", ["dir3"]);
+ // Check that we get an error if the name is taken by a file.
+ os.system("sh", ["-c", "echo foo > file1"]);
+ os.system("ls", ["file1"]);
+ assertThrows("os.mkdirp('file1');", "mkdir over file1");
+ assertThrows("os.mkdirp('file1/foo');", "mkdir over file2");
+ assertThrows("os.mkdirp('file1/');", "mkdir over file3");
+ assertThrows("os.mkdirp('file1/foo/');", "mkdir over file4");
+ // Create a dir we cannot read.
+ os.mkdirp("dir4", 0);
+ // This test fails if you are root since root can read any dir.
+ assertThrows("os.chdir('dir4');", "chdir dir4 I");
+ os.rmdir("dir4");
+ assertThrows("os.chdir('dir4');", "chdir dir4 II");
+ // Set umask.
+ var old_umask = os.umask(0777);
+ // Create a dir we cannot read.
+ os.mkdirp("dir5");
+ // This test fails if you are root since root can read any dir.
+ assertThrows("os.chdir('dir5');", "cd dir5 I");
+ os.rmdir("dir5");
+ assertThrows("os.chdir('dir5');", "chdir dir5 II");
+ os.umask(old_umask);
+
+ os.mkdirp("hest/fisk/../fisk/ged");
+ os.system("ls", ["hest/fisk/ged"]);
+
+ os.setenv("FOO", "bar");
+ var environment = os.system("printenv");
+ assertTrue(/FOO=bar/.test(environment));
+
+ // Check we time out.
+ var have_sleep = true;
+ var have_echo = true;
+ try {
+ os.system("ls", ["/bin/sleep"]);
+ } catch (e) {
+ have_sleep = false;
+ }
+ try {
+ os.system("ls", ["/bin/echo"]);
+ } catch (e) {
+ have_echo = false;
+ }
+ if (have_sleep) {
+ assertThrows("os.system('sleep', ['2000'], 200);", "sleep 1");
+
+ // Check we time out with total time.
+ assertThrows("os.system('sleep', ['2000'], -1, 200);", "sleep 2");
+
+ // Check that -1 means no timeout.
+ os.system('sleep', ['1'], -1, -1);
+
+ }
+
+ // Check that we don't fill up the process table with zombies.
+ // Disabled because it's too slow.
+ if (have_echo) {
+ //for (var i = 0; i < 65536; i++) {
assertEquals("baz\n", os.system("echo", ["baz"]));
- //}
+ //}
+ }
+ } finally {
+ os.chdir("..");
+ os.system("rm", ["-r", TEST_DIR]);
}
- os.chdir("..");
- os.system("rm", ["-r", "d8-os-test-directory"]);
-
// Too few args.
arg_error("os.umask();");
arg_error("os.system();");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698