2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2010 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 #include "test_yaffs_read_EINVAL.h"
16 static int handle = -1;
17 static char *file_name = NULL;
19 int test_yaffs_read_EINVAL(void)
22 handle=test_yaffs_open();
23 char text[2000000]="\0";
27 print_message("could not open file\n",2);
31 /*there needs a large amout of test in the file in order to trigger EINVAL */
32 output=test_yaffs_read_EINVAL_init();
34 print_message("could not write text to the file\n",2);
39 output=yaffs_read(handle, text, -1);
41 error_code=yaffs_get_error();
42 if (abs(error_code)== EINVAL){
45 print_message("different error than expected\n",2);
49 print_message("read a negative number of bytes (which is a bad thing)\n",2);
53 print_message("error opening file\n",2);
58 int test_yaffs_read_EINVAL_clean(void)
62 output=test_yaffs_read_EINVAL_init_clean();
64 output=yaffs_close(handle);
68 print_message("could not close the handle\n",2);
72 print_message("failed to fix the file\n",2);
76 print_message("no open handle\n",2);
80 int test_yaffs_read_EINVAL_init(void)
85 int file_name_length=1000000;
87 file_name = malloc(file_name_length);
89 print_message("unable to create file text\n",2);
93 strcat(file_name,YAFFS_MOUNT_POINT);
94 for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
97 file_name[file_name_length-2]='\0';
102 output= yaffs_write(handle, file_name, file_name_length-1);
104 print_message("could not write text to file\n",2);
112 print_message("error opening file\n",2);
118 int test_yaffs_read_EINVAL_init_clean(void)
127 output= yaffs_truncate(FILE_PATH,FILE_SIZE );
129 output=test_yaffs_write();
133 print_message("failed to write to file\n",2);
137 print_message("failed to truncate file\n",2);