Update timothy test Makefile
[yaffs2.git] / direct / timothy_tests / quick_tests / test_yaffs_link_ELOOP_dir.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2011 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Timothy Manning <timothy@yaffs.net>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #include "test_yaffs_link_ELOOP_dir.h"
15
16
17
18 int test_yaffs_link_ELOOP_dir(void)
19 {
20         int output=0;   
21         int error =0;
22
23         if (set_up_ELOOP()<0){
24                 print_message("failed to setup symlinks\n",2);
25                 return -1;
26         }
27
28         output = yaffs_link(ELOOP_PATH "/file",HARD_LINK_PATH);
29         if (output<0){
30                 error=yaffs_get_error();
31                 if (abs(error)==ELOOP){
32                         return 1;
33                 } else {
34                         print_message("different error than expected\n",2);
35                         return -1;
36                 }
37         } else {
38                 print_message("created a hard link to a non-existing-dir (which is a bad thing)\n",2);
39                 return -1;      
40         }
41 }
42
43
44 int test_yaffs_link_ELOOP_dir_clean(void)
45 {
46         int output=0;   
47         int error =0;
48         output= yaffs_unlink(HARD_LINK_PATH);
49         if (output<0){
50                 error=yaffs_get_error();
51                 if (abs(error)==ENOENT){
52                         //if the file does not exist then the error should be ENOENT.
53                         return 1;
54                 } else {
55                         print_message("different error than expected\n",2);
56                         return -1;
57                 }
58         } else {
59                 return 1;       /* the file failed to open so there is no need to close it */
60         }
61 }
62