File: rtest_operatingsystem.mac

package info (click to toggle)
maxima-sage 5.45.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 113,788 kB
  • sloc: lisp: 440,833; fortran: 14,665; perl: 14,369; tcl: 10,997; sh: 4,475; makefile: 2,520; ansic: 447; python: 262; xml: 59; awk: 37; sed: 17
file content (104 lines) | stat: -rw-r--r-- 2,161 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* Tests for the operatingsystem package */
/* File tests may need write and read permissions in the current directory */
/* run the test (if you start maxima with ./maxima-local) with */
/* batch("share/contrib/operatingsystem/rtest_operatingsystem.mac", 'test); */
/* Be careful: if operations fail, directories may be left over or one might be in another directory! */

(kill(all),0);
0$

( load("operatingsystem"), 0 );
0$

(olddir : getcurrentdirectory(), 0);
0$

(mkdir("testdir1"), 0);
0$

(chdir("testdir1"),0);
0$

(newdir : getcurrentdirectory(), 0);
0$

mkdirokay : if sequal(concat(olddir, "testdir1/"), newdir) then "ok" else "not ok";
"ok"$

/* in the new directory, try to create, rename and remove a file */
pathname_name(stringout("testfile", "testdata"));
"testfile"$

length(directory("*"));
1$

pathname_name(first(directory("*")));
"testfile"$

(rename_file("testfile", "testfile2"),0);
0$

length(directory("*"));
1$

pathname_name(first(directory("*")));
"testfile2"$

(copy_file("testfile2", "testfile3"),0);
0$

length(directory("*"));
2$

pathname_name(first(sort(directory("*"))));
"testfile2"$

pathname_name(second(sort(directory("*"))));
"testfile3"$

(delete_file("testfile2"),0);
0$

length(directory("*"));
1$

pathname_name(first(directory("*")));
"testfile3"$

(delete_file("testfile3"),0);
0$

length(directory("*"));
0$


(if sequal(mkdirokay, "ok") then chdir(".."),0);
0$


/* do this test only if creating a new directory worked */
(if sequal(mkdirokay, "ok") then rmdir("testdir1"), 0);
0$

/* now test a more complicated name - with spaces, german umlauts */
(mkdir("testdir1 äöüß"), 0);
0$

/* do this test only if creating a new directory worked */
(chdir("testdir1 äöüß"),0);
0$

(newdir : getcurrentdirectory(), 0);
0$

mkdirokay : if sequal(concat(olddir, "testdir1 äöüß/"), newdir) then "ok" else "not ok";
"ok"$

/* do this test only if creating a new directory worked */
(if sequal(mkdirokay, "ok") then chdir(".."),0);
0$

/* do this test only if creating a new directory worked */
(if sequal(mkdirokay, "ok") then rmdir("testdir1 äöüß"), 0);
0$