Merge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2
[yaffs2.git] / direct / timothy_tests / quick_tests / test_yaffs_truncate_ENOENT.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2010 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_truncate_ENOENT.h"
15 static int handle=0;
16
17 int test_yaffs_truncate_ENOENT(void){
18         int error=0;
19         int output=0;
20         handle=test_yaffs_open();
21         if (handle>=0){
22                 output= yaffs_truncate("/yaffs2/non_existing_file",FILE_SIZE_TRUNCATED );
23                 if (output<0){
24                         error=yaffs_get_error();
25                         if (abs(error)==ENOENT){
26                                 return 1;
27                         }
28                         else {
29                                 printf("recieved a different error than expected\n");
30                                 return -1;
31                         }
32                 }
33                 else{
34                         printf("truncated a nonexisting file\n");
35                         return -1;
36                 }
37                         
38         }
39         else {
40                 printf("error opening file");
41                 return -1;
42         }
43 }
44
45 int test_yaffs_truncate_ENOENT_clean(void){
46         return 1;
47 }