OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 e.toString = function() { throw new Error("foo bar"); } | 47 e.toString = function() { throw new Error("foo bar"); } |
48 try { | 48 try { |
49 eval(str); | 49 eval(str); |
50 } catch (exception) { | 50 } catch (exception) { |
51 assertTrue(/tring conversion/.test(exception), str); | 51 assertTrue(/tring conversion/.test(exception), str); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 if (this.os && os.system) { | 56 if (this.os && os.system) { |
| 57 // Ensure that we have a valid working directory. |
| 58 os.chdir("/tmp"); |
57 try { | 59 try { |
58 // Delete the dir if it is lying around from last time. | 60 // Delete the dir if it is lying around from last time. |
59 os.system("ls", [TEST_DIR]); | 61 os.system("ls", [TEST_DIR]); |
60 os.system("rm", ["-r", TEST_DIR]); | 62 os.system("rm", ["-r", TEST_DIR]); |
61 } catch (e) { | 63 } catch (e) { |
62 } | 64 } |
63 os.mkdirp(TEST_DIR); | 65 os.mkdirp(TEST_DIR); |
64 os.chdir(TEST_DIR); | 66 os.chdir(TEST_DIR); |
65 try { | 67 try { |
66 // Check the chdir worked. | 68 // Check the chdir worked. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 138 |
137 } | 139 } |
138 | 140 |
139 // Check that we don't fill up the process table with zombies. | 141 // Check that we don't fill up the process table with zombies. |
140 // Disabled because it's too slow. | 142 // Disabled because it's too slow. |
141 if (have_echo) { | 143 if (have_echo) { |
142 //for (var i = 0; i < 65536; i++) { | 144 //for (var i = 0; i < 65536; i++) { |
143 assertEquals("baz\n", os.system("echo", ["baz"])); | 145 assertEquals("baz\n", os.system("echo", ["baz"])); |
144 //} | 146 //} |
145 } | 147 } |
| 148 |
| 149 // Too few args. |
| 150 arg_error("os.umask();"); |
| 151 arg_error("os.system();"); |
| 152 arg_error("os.mkdirp();"); |
| 153 arg_error("os.chdir();"); |
| 154 arg_error("os.setenv();"); |
| 155 arg_error("os.rmdir();"); |
| 156 |
| 157 // Too many args. |
| 158 arg_error("os.setenv('FOO=bar');"); |
| 159 arg_error("os.umask(0, 0);"); |
| 160 arg_error("os.system('ls', [], -1, -1, -1);"); |
| 161 arg_error("os.mkdirp('foo', 0, 0)"); |
| 162 arg_error("os.chdir('foo', 'bar')"); |
| 163 arg_error("os.rmdir('foo', 'bar');"); |
| 164 |
| 165 // Wrong kind of args. |
| 166 arg_error("os.umask([]);"); |
| 167 arg_error("os.system('ls', 'foo');"); |
| 168 arg_error("os.system('ls', 123);"); |
| 169 arg_error("os.system('ls', [], 'foo');"); |
| 170 arg_error("os.system('ls', [], -1, 'foo');"); |
| 171 arg_error("os.mkdirp('foo', 'bar');"); |
| 172 |
| 173 // Test broken toString(). |
| 174 str_error("os.system(e);"); |
| 175 str_error("os.system('ls', [e]);"); |
| 176 str_error("os.system('ls', ['.', e]);"); |
| 177 str_error("os.system('ls', [e, '.']);"); |
| 178 str_error("os.mkdirp(e);"); |
| 179 str_error("os.setenv(e, 'goo');"); |
| 180 str_error("os.setenv('goo', e);"); |
| 181 str_error("os.chdir(e);"); |
| 182 str_error("os.rmdir(e);"); |
| 183 |
146 } finally { | 184 } finally { |
147 os.system("rm", ["-r", TEST_DIR]); | 185 os.system("rm", ["-r", TEST_DIR]); |
148 } | 186 } |
149 | |
150 // Too few args. | |
151 arg_error("os.umask();"); | |
152 arg_error("os.system();"); | |
153 arg_error("os.mkdirp();"); | |
154 arg_error("os.chdir();"); | |
155 arg_error("os.setenv();"); | |
156 arg_error("os.rmdir();"); | |
157 | |
158 // Too many args. | |
159 arg_error("os.setenv('FOO=bar');"); | |
160 arg_error("os.umask(0, 0);"); | |
161 arg_error("os.system('ls', [], -1, -1, -1);"); | |
162 arg_error("os.mkdirp('foo', 0, 0)"); | |
163 arg_error("os.chdir('foo', 'bar')"); | |
164 arg_error("os.rmdir('foo', 'bar');"); | |
165 | |
166 // Wrong kind of args. | |
167 arg_error("os.umask([]);"); | |
168 arg_error("os.system('ls', 'foo');"); | |
169 arg_error("os.system('ls', 123);"); | |
170 arg_error("os.system('ls', [], 'foo');"); | |
171 arg_error("os.system('ls', [], -1, 'foo');"); | |
172 arg_error("os.mkdirp('foo', 'bar');"); | |
173 | |
174 // Test broken toString(). | |
175 str_error("os.system(e);"); | |
176 str_error("os.system('ls', [e]);"); | |
177 str_error("os.system('ls', ['.', e]);"); | |
178 str_error("os.system('ls', [e, '.']);"); | |
179 str_error("os.mkdirp(e);"); | |
180 str_error("os.setenv(e, 'goo');"); | |
181 str_error("os.setenv('goo', e);"); | |
182 str_error("os.chdir(e);"); | |
183 str_error("os.rmdir(e);"); | |
184 } | 187 } |
OLD | NEW |