Fix unmatched temporary buffer allocations
[yaffs2.git] / direct / test-framework / timothy_tests / quick_tests / test_yaffs_fchmod_EROFS.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_EROFS.h"
14 static int handle = -1;
15
16 int test_yaffs_fchmod_EROFS(void)
17 {
18         int error = 0;
19         int output = 0;
20         if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
21                 print_message("failed to create file\n",1);
22                 return -1;
23         }
24         if (EROFS_setup() < 0 ){
25                 return -1;
26         }
27         handle = yaffs_open(FILE_PATH,O_CREAT  ,S_IREAD  );
28         if (handle<0){
29                 print_message("failed to open file\n",2);
30                 return -1;
31         }
32
33
34
35         output = yaffs_fchmod(handle,S_IREAD|S_IWRITE);
36
37         if (output<0){
38                 error=yaffs_get_error();
39                 if (abs(error)==EROFS){
40                         return 1;
41                 } else {
42                         print_message("different error than expected\n",2);
43                         return -1;
44                 }
45         } else {
46                 print_message("chmoded with EROFS (which is a bad thing)\n",2);
47                 return -1;
48         }
49
50
51 }
52
53 int test_yaffs_fchmod_EROFS_clean(void)
54 {
55         int output =-1;
56         if (handle >= 0) {
57                 output= yaffs_close(handle);
58         }
59         return (EROFS_clean() && output);
60 }