2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2011 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Timothy Manning <timothy@yaffs.net>
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.
14 /*this is no longer relevent because it is not possiable to read -1 bytes*/
16 #include "test_yaffs_read_EINVAL.h"
17 #include "test_yaffs_write.h"
19 static int handle = -1;
20 static char *file_name = NULL;
22 int test_yaffs_read_EINVAL(void)
27 /*if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
28 print_message("failed to create file before remounting\n",1);
31 handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
34 print_message("could not open file\n",2);
38 /*there needs a large amout of test in the file in order to trigger EINVAL */
39 output=test_yaffs_read_EINVAL_init();
41 print_message("could not write text to the file\n",2);
46 output=yaffs_read(handle, text, -1);
48 error_code=yaffs_get_error();
49 if (abs(error_code)== EINVAL){
52 print_message("different error than expected\n",2);
56 print_message("read a negative number of bytes (which is a bad thing)\n",2);
60 print_message("error opening file\n",2);
65 int test_yaffs_read_EINVAL_clean(void)
75 output= yaffs_truncate(FILE_PATH,FILE_SIZE );
77 output=test_yaffs_write();
79 print_message("failed to write to file\n",2);
82 output=test_yaffs_write_clean();
84 print_message("failed to clean the write_to_file function\n",2);
88 print_message("failed to truncate file\n",2);
93 output=yaffs_close(handle);
97 print_message("could not close the handle\n",2);
101 print_message("failed to fix the file\n",2);
105 print_message("no open handle\n",2);
110 int test_yaffs_read_EINVAL_init(void)
115 int file_name_length=1000000;
117 file_name = malloc(file_name_length);
119 print_message("unable to create file text\n",2);
123 strcpy(file_name,YAFFS_MOUNT_POINT);
124 for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
127 file_name[file_name_length-2]='\0';
132 output= yaffs_write(handle, file_name, file_name_length-1);
134 print_message("could not write text to file\n",2);
142 print_message("error opening file\n",2);