コード例 #1
0
int test_yaffs_rename_file_to_dir(void)
{
    int output=0;

    if (0 !=  yaffs_access(FILE_PATH,0)) {
        output = test_yaffs_open();
        if (output < 0) {
            print_message("failed to create file\n",2);
            return -1;
        } else {
            output = yaffs_close(output);
            if (output < 0) {
                print_message("failed to close file\n",2);
                return -1;
            }
        }
    }
    output = yaffs_rename( "/yaffs2/foo" , RENAME_DIR_PATH);
    if (output<0) {
        print_message("failed to rename a file over an empty directory\n",2);
        return -1;
    } else {
        return 1;
    }

}
コード例 #2
0
int test_yaffs_open_EACCES(void)
{
	int error_code=0;
	int output =-1;
	if (yaffs_access(FILE_PATH,0)!=0){
		output=yaffs_close(test_yaffs_open());
		if (output<0){
			print_message("failed to open file\n",2);
			return -1;
		}
	}

	output=yaffs_chmod(FILE_PATH,S_IREAD);
	if (output<0){
		print_message("failed to chmod file\n",2);
		return -1;
	}
	handle=yaffs_open(FILE_PATH, O_TRUNC| O_RDWR,FILE_MODE );
	if (handle <0){
		error_code=yaffs_get_error();
		if (abs(error_code)==EACCES){
			return 1;
		}
		else {
			print_message("different error than expected\n",2);
			return -1;
		}
	}
	else {
		print_message("file opened with read and write permissions, chmoded to read only.(which is a bad thing)\n",2);
		return -1;
	}
}
コード例 #3
0
int test_yaffs_ftruncate_big_file(void)
{
    int output = 0;
    int error_code = 0;
    handle = test_yaffs_open();

    if (handle >= 0) {
        output = yaffs_ftruncate(handle,10000000000000000000000000000000);
        if (output < 0) {
            error_code = yaffs_get_error();
            if (abs(error_code) == EINVAL) {	/* yaffs uses the error EINVAL instead of big_file */
                return 1;
            } else {
                print_message("different error than expected\n", 2);
                return -1;
            }
        } else {
            print_message("file truncated to a very large size.(which is a bad thing)\n", 2);
            return -1;
        }
    } else {
        print_message("error opening file\n", 2);
        return -1;
    }
}
コード例 #4
0
int test_yaffs_unlink_NULL_clean(void)
{
	if (handle >= 0){
		return test_yaffs_open();
	} else {
		return 1;	/* the file failed to open so there is no need to close it*/
	}
}
コード例 #5
0
int test_yaffs_rename_file_to_dir_clean(void)
{
    int output = 0;
    test_yaffs_open();
    if (0 ==  yaffs_access(RENAME_DIR_PATH,0)) {
        output = yaffs_unlink(RENAME_DIR_PATH);
        if (output < 0) {
            print_message("failed to unlink the file\n",2);
            return -1;
        }
        output = test_yaffs_open();
        if (output < 0) {
            print_message("failed to open a new\n",2);
            return -1;
        }
    }
    return 1;

}
コード例 #6
0
/*tests renaming a non empty file */
int test_yaffs_rename_dir(void)
{
	int output=0;
	int error_code =0;
	output = yaffs_open("/yaffs2/new_directory/file",O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
	if (output < 0 )

	if (0 !=  yaffs_access(FILE_PATH,0)) {
		output = test_yaffs_open();
		if (output < 0) {
			print_message("failed to create file\n",2);
			return -1;
		}
	}
	output = yaffs_rename( DIR_PATH , RENAME_DIR_PATH);
	return output;	
}