Add sun4i ram controller definitions
[AROS.git] / test / clib / fchdir.c
blob4321060fd9d8c69ded74029d23372f25493a09d6
1 /*
2 Copyright © 2008-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <unistd.h>
7 #include <stdio.h>
8 #include <fcntl.h>
9 #include <string.h>
10 #include <errno.h>
11 #include <proto/dos.h>
12 #include "test.h"
14 int fd = -1;
16 int main()
18 char path1[256];
19 char path2[256];
21 /* First something simple */
22 TEST((chdir("SYS:") != -1));
23 TEST((getcwd(path1, sizeof(path1)) != (char*) -1));
24 TEST(((fd = open("SYS:", O_READ)) != -1));
25 TEST((fchdir(fd) != -1));
26 close(fd); fd = -1;
27 TEST((getcwd(path2, sizeof(path2)) != (char*) -1));
28 printf("Comparing paths: %s and %s\n", path1, path2);
29 TEST((strcmp(path1, path2) == 0));
31 /* Now more complicated case */
32 TEST((mkdir("T:__TEST__", 0777) != -1));
34 TEST((chdir("T:__TEST__") != -1));
35 TEST((getcwd(path1, sizeof(path1)) != (char*) -1));
36 TEST(((fd = open("T:__TEST__", O_READ)) != -1));
37 TEST((fchdir(fd) != -1));
38 close(fd); fd = -1;
39 TEST((getcwd(path2, sizeof(path2)) != (char*) -1));
40 printf("Comparing paths: %s and %s\n", path1, path2);
41 TEST((strcmp(path1, path2) == 0));
43 /* Test directory is going to disappear soon, evacuate! */
44 TEST((chdir("SYS:") != -1));
46 cleanup();
47 return OK;
50 void cleanup()
52 if(fd != -1)
53 close(fd);
55 DeleteFile("T:__TEST__");