Rune - Content-locking work 1/2
[rune.git] / tests / link.d
1 #!/usr/local/bin/rune -x
2 #
3
4 limport "sys";
5 import "stdio";
6
7 int
8 main(int ac, char **av)
9 {
10         FStat st;
11         Fs fs;
12         char buf[Fs.PATH_MAX];
13
14         fs.unlink("test.x1");
15         fs.unlink("test.x2");
16         fs.unlink("test.x3");
17         Fs.umask(0077);
18         if (fs.open("test.x1", O_RDWR|O_CREAT|O_TRUNC, 0666) < 0) {
19                 stdio.stderr->show("failed to create test.x1 ", fs.error);
20                 return 1;
21         }
22         if (fs.symlink("test.x1", "test.x2") < 0) {
23                 stdio.stderr->show("failed to symlink test.x2 ", fs.error);
24                 return 1;
25         }
26         if (fs.readlink("test.x2", buf) < 0) {
27                 stdio.stderr->show("failed to readlink test.x2 ", fs.error);
28                 return 1;
29         }
30         stdio.stderr->format("readlink test.x2: %s\n", &buf[0]);
31         if (fs.link("test.x1", "test.x3") < 0) {
32                 stdio.stderr->show("failed to link test.x3 ", fs.error);
33                 return 1;
34         }
35         if (fs.unlink("test.x1") < 0) {
36                 stdio.stderr->show("failed to unlink test.x1 ", fs.error);
37                 return 1;
38         }
39         #fs.unlink("test.x2");
40         #fs.unlink("test.x3");
41         stdio.stderr->show("all tests succeeded");
42 }