Fix unmatched temporary buffer allocations
[yaffs2.git] / direct / test-framework / timothy_tests / quick_tests / test_yaffs_lstat_ENOENT.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2018 Aleph One Ltd.
5  *
6  * Created by Timothy Manning <timothy@yaffs.net>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12
13 #include "test_yaffs_lstat_ENOENT.h"
14
15
16 int test_yaffs_lstat_ENOENT(void)
17 {
18         int output = -1;
19         int error_code = -1;
20         struct yaffs_stat stat;
21         if (0 != yaffs_access(FILE_PATH,0)){
22                 output=test_yaffs_open();
23                 if (output>=0){
24                         output = yaffs_close(output);
25                         if (output<0){
26                                 print_message("failed to close file\n",2);
27                                 return -1;
28                         }
29                 } else {
30                         print_message("failed to open file\n",2);
31                         return -1;
32                 }
33         }
34         if (0 != yaffs_access(SYMLINK_PATH,0)){
35                 output=yaffs_symlink(FILE_PATH,SYMLINK_PATH);
36                 if (output<0){
37                         print_message("failed to open file\n",2);
38                         return -1;
39                 }
40         }
41         
42         output =yaffs_lstat("yaffs2/non-existing-dir/",&stat);
43         if (output<0){
44                 error_code=yaffs_get_error();
45                 if (abs(error_code)==ENOENT){
46                         return 1;
47                 } else {
48                         print_message("different error than expected\n", 2);
49                         return -1;
50                 }
51         } else {
52                 print_message("lstatted a non-existing file\n", 2);
53                 return -1;
54         }
55 }
56
57
58 int test_yaffs_lstat_ENOENT_clean(void)
59 {
60         return 1;
61 }
62