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"
18 static char *file_name = NULL;
19 int test_yaffs_read_EINVAL(void){
21 handle=test_yaffs_open();
22 char text[2000000]="\0";
26 printf("could not open file\n");
30 /*there needs a large amout of test in the file in order to trigger EINVAL */
31 output=test_yaffs_read_EINVAL_init();
33 printf("could not write text to the file\n");
38 output=yaffs_read(handle, text, -1);
41 error_code=yaffs_get_error();
42 if (abs(error_code)== EINVAL){
46 printf("different error than expected\n");
51 printf("read a negative number of bytes (which is a bad thing)\n");
56 printf("error opening file\n");
62 int test_yaffs_read_EINVAL_clean(void){
65 output=test_yaffs_read_EINVAL_init_clean();
67 output=yaffs_close(handle);
71 printf("could not close the handle\n");
75 printf("failed to fix the file\n");
82 int test_yaffs_read_EINVAL_init(void)
88 int file_name_length=1000000;
90 file_name = malloc(file_name_length);
92 printf("unable to create file text\n");
96 strcat(file_name,YAFFS_MOUNT_POINT);
97 for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
100 file_name[file_name_length-2]='\0';
105 output= yaffs_write(handle, file_name, file_name_length-1);
107 printf("could not write text to file\n");
115 printf("error opening file\n");
121 int test_yaffs_read_EINVAL_init_clean(void)
130 output= yaffs_truncate(FILE_PATH,FILE_SIZE );
132 output=test_yaffs_write();
136 printf("failed to write to file\n");
140 printf("failed to truncate file\n");