comparison test/system.tst @ 16030:1af8d21608b7

rename all test files in the test directory from test_X.m to X.tst * Use - instead of _ for .tst file names. Fix all file lists in module.mk and Makefile.am files. * __run_test_suite__.m: Adapt to new naming convention.
author John W. Eaton <jwe@octave.org>
date Sat, 09 Feb 2013 21:35:55 -0500
parents test/test_system.m@5b2126a8c84f
children b1283d4c06c2
comparison
equal deleted inserted replaced
16029:b8157404614f 16030:1af8d21608b7
1 ## Copyright (C) 2006-2012 John W. Eaton
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 %% test/octave.test/system/cputime-1.m
20 %!test
21 %! [t1, u1, s1] = cputime ();
22 %! for i = 1:200
23 %! sin (i);
24 %! endfor
25 %! [t2, u2, s2] = cputime ();
26 %! assert (t1, u1 + s1);
27 %! assert (t2 == u2 + s2);
28 %! assert (t2 >= t1);
29 %! assert (u2 >= u2);
30 %! assert (s2 >= s2);
31 %!#assert (t1 == u1 + s1 && t2 == u2 + s2 && t2 >= t1 && u2 >= u2 && s2 >= s2);
32
33 %% test/octave.test/system/tic-toc-1.m
34 %!test
35 %! tic ();
36 %! sleep (2);
37 %! assert (toc () > 0);
38
39 %% test/octave.test/system/pause-1.m
40 %!test
41 %! pause (0);
42 %! __printf_assert__ ("ok\n");
43 %! assert (__prog_output_assert__ ("ok"));
44
45 %% test/octave.test/system/pause-2.m
46 %!error <Invalid call to pause> pause (1, 2)
47
48 %% test/octave.test/system/sleep-1.m
49 %!test
50 %! sleep (0);
51 %! __printf_assert__ ("ok\n");
52 %! assert (__prog_output_assert__ ("ok"));
53
54 %% test/octave.test/system/sleep-2.m
55 %!error <Invalid call to sleep> sleep ()
56
57 %% test/octave.test/system/sleep-3.m
58 %!error <Invalid call to sleep> sleep (1, 2)
59
60 %% test/octave.test/system/usleep-1.m
61 %!test
62 %! usleep (0);
63 %! __printf_assert__ ("ok\n");
64 %! assert (__prog_output_assert__ ("ok"));
65
66 %% test/octave.test/system/usleep-2.m
67 %!error <Invalid call to usleep> usleep ()
68
69 %% test/octave.test/system/usleep-3.m
70 %!error <Invalid call to usleep> usleep (1, 2)
71
72 %% test/octave.test/system/rename-1.m
73 %!test
74 %! from = tmpnam ();
75 %! to = tmpnam ();
76 %! id = fopen (from, "wb");
77 %! if (id > 0 && fclose (id) == 0)
78 %! [s, e] = stat (from);
79 %! if (! e)
80 %! if (rename (from, to) == 0)
81 %! [s, e] = stat (from);
82 %! if (e < 0)
83 %! [s, e] = stat (to);
84 %! assert (e == 0);
85 %! unlink (to);
86 %! endif
87 %! endif
88 %! endif
89 %! endif
90
91 %% test/octave.test/system/rename-2.m
92 %!error <Invalid call to rename> rename ()
93
94 %% test/octave.test/system/rename-3.m
95 %!error <Invalid call to rename> rename ("foo", "bar", 1)
96
97 %% test/octave.test/system/unlink-1.m
98 %!test
99 %! nm = tmpnam ();
100 %! if ((id = fopen (nm, "wb")) > 0)
101 %! [s, err] = stat (nm);
102 %! if (! err && fclose (id) == 0 && unlink (nm) == 0)
103 %! [s, err] = stat (nm);
104 %! assert (err < 0);
105 %! endif
106 %! endif
107
108 %% test/octave.test/system/unlink-2.m
109 %!error <Invalid call to unlink> unlink ()
110
111 %% test/octave.test/system/unlink-3.m
112 %!error <Invalid call to unlink> unlink ("foo", 1)
113
114 %% test/octave.test/system/readdir-1.m
115 %!test
116 %! [files, status, msg] = readdir (filesep);
117 %! assert (iscell (files) && status == 0 && strcmp (msg, ""));
118
119 %% test/octave.test/system/readdir-2.m
120 %!error <Invalid call to readdir> readdir ()
121
122 %% test/octave.test/system/readdir-3.m
123 %!error <Invalid call to readdir> readdir ("foo", 1)
124
125 %% test/octave.test/system/mk-rm-dir-1.m
126 %!test
127 %! nm = tmpnam ();
128 %! e1 = mkdir (nm);
129 %! [s2, e2] = stat (nm);
130 %! e3 = rmdir (nm);
131 %! [s4, e4] = stat (nm);
132 %! assert ((e1 && strcmp (s2.modestr(1), "d") && e3 && e4 < 0));
133
134 %% test/octave.test/system/mkdir-1.m
135 %!error <Invalid call to mkdir> mkdir ()
136
137 %% test/octave.test/system/mkdir-2.m
138 %!error <Invalid call to mkdir> mkdir ("foo", 1, 2)
139
140 %% test/octave.test/system/rmdir-1.m
141 %!error <Invalid call to rmdir> rmdir ()
142
143 %% test/octave.test/system/rmdir-2.m
144 %!test
145 %! crr = confirm_recursive_rmdir ();
146 %! confirm_recursive_rmdir (0);
147 %! assert (!rmdir ("foo", "s"));
148 %! confirm_recursive_rmdir (crr);
149
150 %% test/octave.test/system/umask-1.m
151 %!test
152 %! orig_umask = umask (0);
153 %! nm = tmpnam ();
154 %! id = fopen (nm, "wb");
155 %! s1 = stat (nm);
156 %! fclose (id);
157 %! unlink (nm);
158 %!
159 %! umask (777);
160 %! nm = tmpnam ();
161 %! id = fopen (nm, "wb");
162 %! s2 = stat (nm);
163 %! fclose (id);
164 %! unlink (nm);
165 %!
166 %! assert (deblank (s1.modestr), "-rw-rw-rw-");
167 %! assert (deblank (s2.modestr), "----------");
168 %! # Restore original umask value
169 %! umask (orig_umask);
170
171 %% test/octave.test/system/umask-2.m
172 %!error <Invalid call to umask> umask ()
173
174 %% test/octave.test/system/umask-3.m
175 %!error <Invalid call to umask> umask (1, 2)
176
177 %% test/octave.test/system/stat-1.m
178 %!test
179 %! [s, err, msg] = stat (filesep);
180 %! assert ((err == 0
181 %! && isstruct (s)
182 %! && isfield (s, "dev")
183 %! && isfield (s, "ino")
184 %! && isfield (s, "modestr")
185 %! && isfield (s, "nlink")
186 %! && isfield (s, "uid")
187 %! && isfield (s, "gid")
188 %! && isfield (s, "size")
189 %! && isfield (s, "atime")
190 %! && isfield (s, "mtime")
191 %! && isfield (s, "ctime")
192 %! && ischar (msg)));
193
194 %% test/octave.test/system/stat-2.m
195 %!error <Invalid call to stat> stat ()
196
197 %% test/octave.test/system/stat-3.m
198 %!error <Invalid call to stat> stat ("foo", 1)
199
200 %% test/octave.test/system/lstat-1.m
201 %!test
202 %! [s, err, msg] = lstat (filesep);
203 %! assert ((err == 0
204 %! && isstruct (s)
205 %! && isfield (s, "dev")
206 %! && isfield (s, "ino")
207 %! && isfield (s, "modestr")
208 %! && isfield (s, "nlink")
209 %! && isfield (s, "uid")
210 %! && isfield (s, "gid")
211 %! && isfield (s, "size")
212 %! && isfield (s, "atime")
213 %! && isfield (s, "mtime")
214 %! && isfield (s, "ctime")
215 %! && ischar (msg)));
216
217 %% test/octave.test/system/lstat-2.m
218 %!error <Invalid call to lstat> lstat ()
219
220 %% test/octave.test/system/lstat-3.m
221 %!error <Invalid call to lstat> lstat ("foo", 1)
222
223 %% test/octave.test/system/glob-1.m
224 %!assert (iscell (glob ([filesep "*"])))
225
226 %% test/octave.test/system/glob-2.m
227 %!error <Invalid call to glob> glob ()
228
229 %% test/octave.test/system/glob-3.m
230 %!error <Invalid call to glob> glob ("foo", 1)
231
232 %% test/octave.test/system/fnmatch-1.m
233 %!test
234 %! string_fill_char = setstr (0);
235 %! assert ((fnmatch ("a*a", {"aba"; "xxxba"; "aa"}) == [1; 0; 1]
236 %! && fnmatch ({"a*a"; "b*b"}, "bob")
237 %! && fnmatch ("x[0-5]*", {"x1"; "x6"}) == [1; 0]
238 %! && fnmatch ("x[0-5]*", {"x1"; "x6"; "x001"}) == [1; 0; 1]
239 %! && fnmatch ("x???y", {"xabcy"; "xy"}) == [1; 0]));
240
241 %% test/octave.test/system/fnmatch-2.m
242 %!error <Invalid call to fnmatch> fnmatch ()
243
244 %% test/octave.test/system/fnmatch-3.m
245 %!error <Invalid call to fnmatch> fnmatch ("foo", "bar", 3)
246
247 %% test/octave.test/system/file_in_path-1.m
248 %!assert (ischar (file_in_path (path (), "date.m")))
249
250 %% test/octave.test/system/file_in_path-2.m
251 %!error <invalid option> file_in_path ("foo", "bar", 1)
252
253 %% test/octave.test/system/file_in_path-3.m
254 %!error <Invalid call to file_in_path> file_in_path ()
255
256 %% test/octave.test/system/file_in_path-4.m
257 %!error <Invalid call to file_in_path> file_in_path ("foo", "bar", "baz", "ooka")
258
259 %% test/octave.test/system/tilde_expand-1.m
260 %!testif HAVE_GETPWUID
261 %! x = getpwuid (getuid ());
262 %! assert ((strcmp (x.dir, tilde_expand ("~"))
263 %! && strcmp (x.dir, tilde_expand (sprintf ("~%s", x.name)))
264 %! && strcmp ("foobar", tilde_expand ("foobar"))));
265
266 %% test/octave.test/system/tilde_expand-2.m
267 %!error <Invalid call to tilde_expand> tilde_expand ()
268
269 %% test/octave.test/system/tilde_expand-3.m
270 %!error <Invalid call to tilde_expand> tilde_expand ("str", 2)
271
272 %% test/octave.test/system/getpgrp-1.m
273 %!testif HAVE_GETPGRP
274 %! assert (getpgrp () > 0);
275
276 %% test/octave.test/system/getpgrp-2.m
277 %!error <... getpgrp> getpgrp (1)
278
279 %% test/octave.test/system/getpid-1.m
280 %!assert (getpid () > 0)
281
282 %% test/octave.test/system/getpid-2.m
283 %!error <... getpid> getpid (1)
284
285 %% test/octave.test/system/getppid-1.m
286 %!testif HAVE_GETPPID
287 %! assert (getppid () > 0);
288
289 %% test/octave.test/system/getppid-2.m
290 %!error <... getppid> getppid (1)
291
292 %% test/octave.test/system/geteuid-1.m
293 %!assert (geteuid () >= 0)
294
295 %% test/octave.test/system/geteuid-2.m
296 %!error <... geteuid> geteuid (1)
297
298 %% test/octave.test/system/getuid-1.m
299 %!assert (getuid () >= 0)
300
301 %% test/octave.test/system/getuid-2.m
302 %!error <... getuid> getuid (1)
303
304 %% test/octave.test/system/getegid-1.m
305 %!assert (getegid () >= 0)
306
307 %% test/octave.test/system/getegid-2.m
308 %!error <... getegid> getegid (1)
309
310 %% test/octave.test/system/getgid-1.m
311 %!assert (getgid () >= 0)
312
313 %% test/octave.test/system/getgid-2.m
314 %!error <... getgid> getgid (1)
315
316 %% test/octave.test/system/getenv-1.m
317 %!assert (getenv ("HOME"), tilde_expand ("~"))
318
319 %% test/octave.test/system/getenv-2.m
320 %!error <Invalid call to getenv> getenv ()
321
322 %% test/octave.test/system/getenv-3.m
323 %!error <Invalid call to getenv> getenv ("foo", 1)
324
325 %% test/octave.test/system/getenv-4.m
326 %!test
327 %! wns = warning ("query", "Octave:num-to-str");
328 %! warning ("on", "Octave:num-to-str");
329 %! fail ("getenv (1)", "warning");
330 %! warning (wns.state, "Octave:num-to-str");
331
332 %% test/octave.test/system/putenv-1.m
333 %!test
334 %! putenv ("foobar", "baz");
335 %! assert (getenv ("foobar"), "baz");
336
337 %% test/octave.test/system/putenv-2.m
338 %!error <Invalid call to putenv> putenv ()
339
340 %% test/octave.test/system/putenv-3.m
341 %!error <Invalid call to putenv> putenv ("foo", "bar", 1)
342
343 %% test/octave.test/system/putenv-4.m
344 %!test
345 %! wns = warning ("query", "Octave:num-to-str");
346 %! warning ("on", "Octave:num-to-str");
347 %! fail ("putenv (1, 2)","warning");
348 %! warning (wns.state, "Octave:num-to-str");
349
350 %% test/octave.test/system/cd-1.m
351 %!test
352 %! xdir = pwd ();
353 %! cd /
354 %! d1 = pwd ();
355 %! cd (xdir);
356 %! if (ispc () && ! isunix ())
357 %! # should be a drive letter
358 %! assert (length (d1), 3);
359 %! assert (d1(2), ":");
360 %! assert (d1(3), "\\");
361 %! else
362 %! assert ("/", d1);
363 %! endif
364 %! assert (pwd(), xdir);
365
366 %% test/octave.test/system/cd-2.m
367 %!error cd (1)
368
369 %% test/octave.test/system/pwd-1.m
370 %!assert (ischar (pwd ()))
371
372 %% test/octave.test/system/getpwent-1.m
373 %!testif HAVE_GETPWENT
374 %! s = getpwent ();
375 %! endpwent ();
376 %! assert ((isstruct (s)
377 %! && isfield (s, "name")
378 %! && isfield (s, "passwd")
379 %! && isfield (s, "uid")
380 %! && isfield (s, "gid")
381 %! && isfield (s, "gecos")
382 %! && isfield (s, "dir")
383 %! && isfield (s, "shell")));
384
385 %% test/octave.test/system/getpwent-2.m
386 %!error <Invalid call to getpwent> getpwent (1)
387
388 %% test/octave.test/system/getpwuid-1.m
389 %!testif HAVE_GETPWUID
390 %! x = getpwent ();
391 %! y = getpwuid (x.uid);
392 %! endpwent ();
393 %! assert (strcmp (x.name, y.name) && x.uid == y.uid && x.gid == y.gid);
394
395 %% test/octave.test/system/getpwuid-2.m
396 %!error <Invalid call to getpwuid> getpwuid ()
397
398 %% test/octave.test/system/getpwuid-3.m
399 %!error <Invalid call to getpwuid> getpwuid (1, 2)
400
401 %% test/octave.test/system/getpwnam-1.m
402 %!testif HAVE_GETPWNAM
403 %! x = getpwent ();
404 %! y = getpwnam (x.name);
405 %! endpwent ();
406 %! assert (strcmp (x.name, y.name) && x.uid == y.uid && x.gid == y.gid);
407
408 %% test/octave.test/system/getpwnam-2.m
409 %!error <Invalid call to getpwnam> getpwnam ()
410
411 %% test/octave.test/system/getpwnam-3.m
412 %!error <Invalid call to getpwnam> getpwnam ("foo", 1)
413
414 %% test/octave.test/system/setpwent-1.m
415 %!testif HAVE_SETPWENT
416 %! x = getpwent ();
417 %! setpwent ();
418 %! y = getpwent ();
419 %! endpwent ();
420 %! assert (strcmp (x.name, y.name) && x.uid == y.uid && x.gid == y.gid);
421
422 %% test/octave.test/system/setpwent-2.m
423 %!error <Invalid call to setpwent> setpwent (1)
424
425 %% test/octave.test/system/endpwent-1.m
426 %!error <Invalid call to endpwent> endpwent (1)
427
428 %% test/octave.test/system/getgrent-1.m
429 %!testif HAVE_GETGRENT
430 %! x = getgrent ();
431 %! endgrent ();
432 %! assert ((isstruct (x)
433 %! && isfield (x, "name")
434 %! && isfield (x, "passwd")
435 %! && isfield (x, "gid")
436 %! && isfield (x, "mem")));
437
438 %% test/octave.test/system/getgrent-2.m
439 %!error <Invalid call to getgrent> getgrent (1)
440
441 %% test/octave.test/system/getgrgid-1.m
442 %!testif HAVE_GETGRGID
443 %! x = getgrent ();
444 %! y = getgrgid (x.gid);
445 %! endgrent ();
446 %! assert (strcmp (x.name, y.name) && x.gid == y.gid);
447
448 %% test/octave.test/system/getgrgid-2.m
449 %!error <Invalid call to getgrgid> getgrgid ()
450
451 %% test/octave.test/system/getgrgid-3.m
452 %!error <Invalid call to getgrgid> getgrgid (1, 2)
453
454 %% test/octave.test/system/getgrnam-1.m
455 %!testif HAVE_GETGRNAM
456 %! x = getgrent ();
457 %! y = getgrnam (x.name);
458 %! endgrent ();
459 %! assert (strcmp (x.name, y.name) && x.gid == y.gid);
460
461 %% test/octave.test/system/getgrnam-2.m
462 %!error <Invalid call to getgrnam> getgrnam ()
463
464 %% test/octave.test/system/getgrnam-3.m
465 %!error <Invalid call to getgrnam> getgrnam ("foo", 1)
466
467 %% test/octave.test/system/setgrent-1.m
468 %!testif HAVE_SETGRENT
469 %! x = getgrent ();
470 %! setgrent ();
471 %! y = getgrent ();
472 %! endgrent ();
473 %! assert (strcmp (x.name, y.name) && x.gid == y.gid);
474
475 %% test/octave.test/system/setgrent-2.m
476 %!error <Invalid call to setgrent> setgrent (1)
477
478 %% test/octave.test/system/endgrent-1.m
479 %!error <Invalid call to endgrent> endgrent (1)
480
481 %% test/octave.test/system/isieee-1.m
482 %!assert (isieee () == 1 || isieee () == 0)
483
484 %% test/octave.test/system/octave_config_info-1.m
485 %!assert (isstruct (octave_config_info ()))
486
487 %% test/octave.test/system/getrusage-1.m
488 %!assert (isstruct (getrusage ()))
489