Fix unmatched temporary buffer allocations
[yaffs2.git] / direct / test-framework / timothy_tests / quick_tests / test_yaffs_fchmod_EINVAL.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_fchmod_EINVAL.h"
14
15 static int handle = -1;
16
17 int test_yaffs_fchmod_EINVAL(void)
18 {
19         int error = 0;
20         int output = 0;
21
22         
23         handle = test_yaffs_open();
24
25         if (handle < 0){
26                 print_message("failed to open file\n",2);
27                 return -1;
28         }
29
30
31
32         output = yaffs_fchmod(handle,111111);
33
34         if (output<0){
35                 error=yaffs_get_error();
36                 if (abs(error)==EINVAL){
37                         return 1;
38                 } else {
39                         print_message("different error than expected\n",2);
40                         return -1;
41                 }
42         } else {
43                 print_message("chmoded an non-existing file (which is a bad thing)\n",2);
44                 return -1;
45         }
46
47
48 }
49
50 int test_yaffs_fchmod_EINVAL_clean(void)
51 {
52         if (handle >= 0) {
53                 return yaffs_close(handle);
54         }
55         return test_yaffs_chmod();
56 }