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"
18 static int handle = -1;
19 static char *file_name = NULL;
21 int test_yaffs_read_EINVAL(void)
26 /*if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
27 print_message("failed to create file before remounting\n",1);
30 handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
33 print_message("could not open file\n",2);
37 /*there needs a large amout of test in the file in order to trigger EINVAL */
38 output=test_yaffs_read_EINVAL_init();
40 print_message("could not write text to the file\n",2);
45 output=yaffs_read(handle, text, -1);
47 error_code=yaffs_get_error();
48 if (abs(error_code)== EINVAL){
51 print_message("different error than expected\n",2);
55 print_message("read a negative number of bytes (which is a bad thing)\n",2);
59 print_message("error opening file\n",2);
64 int test_yaffs_read_EINVAL_clean(void)
74 output= yaffs_truncate(FILE_PATH,FILE_SIZE );
76 output=test_yaffs_write();
78 print_message("failed to write to file\n",2);
81 output=test_yaffs_write_clean();
83 print_message("failed to clean the write_to_file function\n",2);
87 print_message("failed to truncate file\n",2);
92 output=yaffs_close(handle);
96 print_message("could not close the handle\n",2);
100 print_message("failed to fix the file\n",2);
104 print_message("no open handle\n",2);
109 int test_yaffs_read_EINVAL_init(void)
114 int file_name_length=1000000;
116 file_name = malloc(file_name_length);
118 print_message("unable to create file text\n",2);
122 strcpy(file_name,YAFFS_MOUNT_POINT);
123 for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
126 file_name[file_name_length-2]='\0';
131 output= yaffs_write(handle, file_name, file_name_length-1);
133 print_message("could not write text to file\n",2);
141 print_message("error opening file\n",2);