Fix unmatched temporary buffer allocations
[yaffs2.git] / direct / test-framework / unit_tests / quick_tests / test_yaffs_lseek_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_lseek_EROFS.h"
14
15 int handle=-1;
16
17 int test_yaffs_lseek_EROFS(void)
18 {
19
20         int error_code = 0;
21         int output = 0;
22         EROFS_setup();
23
24         handle = test_yaffs_open();
25         if (handle < 0){
26                 print_message("failed to open file\n", 2);
27                 return -1;
28         }
29
30         output = yaffs_lseek(handle, 0, 20);
31
32         if (output < 0){
33                 error_code = yaffs_get_error();
34                 if (abs(error_code) == EROFS){
35                         return 1;
36                 } else {
37                         print_message("different error than expected\n", 2);
38                         return -1;
39                 }
40         } else {
41                 print_message("lseeked with EROFS set (which is a bad thing)\n", 2);
42                 return -1;
43         }
44 }
45
46 int test_yaffs_lseek_EROFS_clean(void)
47 {
48         if (handle >= 0){
49                 return yaffs_close(handle);
50         } else {
51                 return 1; /* no handle was opened so there is no need to close a handle */
52         }       
53 }
54