yaffs_test: $(FRAMEWORK_SOURCES) $(YAFFS_TEST_OBJS)
- gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS)
+ gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS) -lpthread
quick_tests: $(FRAMEWORK_SOURCES) $(YAFFS_TEST_OBJS)
- gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS)
+ gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS) -lpthread
#include "yaffsfs.h"
-#define YAFFS_MOUNT_POINT "/yaffs2/"
+#define YAFFS_MOUNT_POINT "/yflash2/"
#define FILE_NAME "test_dir/foo"
#define FILE_SIZE 10
+#define YAFFS_TEST_LONG_VALUE (100000000000000000LL)
+
#define FILE_MODE (S_IREAD | S_IWRITE)
#define FILE_SIZE_TRUNCATED 100
#define FILE_TEXT "file foo " /* keep space at end of string */
#define FILE_TEXT_NBYTES 10
-#define TEST_DIR "/yaffs2/test_dir"
-#define DIR_PATH "/yaffs2/test_dir/new_directory"
-#define DIR_PATH2 "/yaffs2/test_dir/new_directory2"
-#define DIR_PATH2_FILE "/yaffs2/test_dir/new_directory2/foo"
-#define SYMLINK_PATH "/yaffs2/test_dir/sym_foo"
+#define TEST_DIR "/yflash2/test_dir"
+#define DIR_PATH "/yflash2/test_dir/new_directory"
+#define DIR_PATH2 "/yflash2/test_dir/new_directory2"
+#define DIR_PATH2_FILE "/yflash2/test_dir/new_directory2/foo"
+#define SYMLINK_PATH "/yflash2/test_dir/sym_foo"
-#define HARD_LINK_PATH "/yaffs2/test_dir/hard_link"
+#define HARD_LINK_PATH "/yflash2/test_dir/hard_link"
-#define NODE_PATH "/yaffs2/test_dir/node"
+#define NODE_PATH "/yflash2/test_dir/node"
-#define RENAME_PATH "/yaffs2/test_dir/foo2"
+#define RENAME_PATH "/yflash2/test_dir/foo2"
-#define RENAME_DIR_PATH "/yaffs2/test_dir/dir2"
+#define RENAME_DIR_PATH "/yflash2/test_dir/dir2"
-#define ELOOP_PATH "/yaffs2/test_dir/ELOOP"
-#define ELOOP2_PATH "/yaffs2/test_dir/ELOOP2"
+#define ELOOP_PATH "/yflash2/test_dir/ELOOP"
+#define ELOOP2_PATH "/yflash2/test_dir/ELOOP2"
-#define RMDIR_PATH "/yaffs2/test_dir/RM_DIR"
+#define RMDIR_PATH "/yflash2/test_dir/RM_DIR"
/* warning do not define anything as FILE because there seems to be a conflict with stdio.h */
-#define FILE_PATH "/yaffs2/test_dir/foo"
-#define FILE_PATH2 "/yaffs2/test_dir/foo2"
+#define FILE_PATH "/yflash2/test_dir/foo"
+#define FILE_PATH2 "/yflash2/test_dir/foo2"
void join_paths(char *path1,char *path2,char *new_path );
void print_message(char *message,char print_level);
#include "test_yaffs_access_ENOENT2.h"
-static int handle=0;
-
int test_yaffs_access_ENOENT2(void)
{
int output=0;
#include "test_yaffs_access_ENOTDIR.h"
-static int handle=0;
-
int test_yaffs_access_ENOTDIR(void)
{
int output=0;
* published by the Free Software Foundation.
*/
-/* generates a EBADF error by closing a handle twice */
+/* generates a EBADF error by closing a daft handle*/
#include "test_yaffs_close_NULL.h"
int error_code = 0;
- output = yaffs_close(NULL);
+ output = yaffs_close(999);
if (output < 0){
error_code = yaffs_get_error();
if (abs(error_code) == EBADF){
handle2 =yaffs_dup(handle);
return handle2;
}
-
+ return handle;
}
*/
#include "test_yaffs_fchmod.h"
+#include "test_yaffs_open.h"
static int handle = -1;
int error = 0;
int output = 0;
- output = yaffs_fchmod(NULL,S_IREAD|S_IWRITE);
+ output = yaffs_fchmod(999, S_IREAD|S_IWRITE);
if (output<0){
error=yaffs_get_error();
{
int output = 0;
int error_code = 0;
- output = yaffs_fdatasync(NULL);
+ output = yaffs_fdatasync(999);
if (output==-1){
error_code=yaffs_get_error();
if (abs(error_code)==EBADF){
*/
#include "test_yaffs_flush.h"
+#include "test_yaffs_open.h"
static int handle =-1;
#include "test_yaffs_ftruncate_EBADF.h"
-static int handle = 0;
-
int test_yaffs_ftruncate_EBADF(void)
{
int output = 0;
handle = test_yaffs_open();
if (handle >= 0){
- output = yaffs_ftruncate(handle,10000000000000000000000000000000);
+ output = yaffs_ftruncate(handle,YAFFS_TEST_LONG_VALUE);
if (output < 0){
error_code = yaffs_get_error();
if (abs(error_code) == EINVAL){ /* yaffs uses the error EINVAL instead of big_file */
}
} else {
print_message("error opening file\n", 2);
- return -1;
}
-
+ return -1;
}
int test_yaffs_lseek_clean(void)
return -1;
}
- output = yaffs_lseek(handle, 100000000000000000000000000000000000000, SEEK_SET);
+ output = yaffs_lseek(handle, YAFFS_TEST_LONG_VALUE, SEEK_SET);
if (output < 0){
error_code = yaffs_get_error();
*/
#include "test_yaffs_lstat.h"
-
+#include "test_yaffs_open.h"
int test_yaffs_lstat(void)
{
int test_yaffs_open_ENAMETOOLONG(void)
{
- int output = 0;
int x = 0;
int error_code = 0;
int file_name_length = 1000000;
int test_yaffs_open_ENOENT(void)
{
- int output = 0;
int error_code = 0;
/*printf("path %s\n",path); */
handle = yaffs_open("/yaffs2/non_existant_file", O_TRUNC| O_RDWR,FILE_MODE );
int test_yaffs_open_NULL(void)
{
- int output = 0;
int error_code = 0;
/*printf("path %s\n",path); */
handle = yaffs_open(NULL, O_TRUNC| O_RDWR,FILE_MODE );
/*this is no longer relevent because it is not possiable to read -1 bytes*/
#include "test_yaffs_read_EINVAL.h"
+#include "test_yaffs_write.h"
static int handle = -1;
static char *file_name = NULL;
int test_yaffs_remount_force_off_read_only_off(void)
{
int output = -1;
- int error_code =0;
-
output = yaffs_remount(YAFFS_MOUNT_POINT,0,0);
if (output>=0){
*/
#include "test_yaffs_remount_force_on_read_only_off.h"
+#include "test_yaffs_open.h"
int test_yaffs_remount_force_on_read_only_off(void)
{
int output = -1;
- int error_code =0;
+
output=test_yaffs_open();
if (output<0) {
print_message("failed to open file\n",2);
int test_yaffs_rename(void)
{
int output=0;
- int error_code =0;
if (0 != yaffs_access(FILE_PATH,0)) {
output = test_yaffs_open();
*/
#include "test_yaffs_rename_EROFS.h"
-
+#include "test_yaffs_open.h"
int test_yaffs_rename_EROFS(void)
{
{
int output=0;
- int error_code =0;
if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){
print_message("failed to create dir\n",1);
{
int output=0;
- int error_code =0;
if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
print_message("failed to create file\n",1);
{
int output=0;
- int error_code =0;
if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){
print_message("failed to create dir\n",1);
int output=0;
int error_code =0;
-
output = yaffs_rmdir("/yaffs2/");
if (output<0){
error_code=yaffs_get_error();
int test_yaffs_rmdir_EBUSY_clean(void)
{
- int output = 0;
-
return 1;
-
}
int test_yaffs_rmdir_ENOENT_clean(void)
{
- int output = 0;
return 1;
}
int test_yaffs_stat(void)
{
- char message[100];
- int mode=0;
- int size=0;
- message[0]='\0';
struct yaffs_stat stat;
+
if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
print_message("failed to create file \n",1);
return -1;
int error_code=0;
struct yaffs_stat stat;
int output=0;
- char text[100];
- text[0] ='\0';
if (set_up_ELOOP()<0){
print_message("failed to setup symlinks\n",2);
int error_code=0;
struct yaffs_stat stat;
int output=0;
- char text[100];
- text[0] ='\0';
if (set_up_ELOOP()<0){
print_message("failed to setup symlinks\n",2);
int error_code=0;
struct yaffs_stat stat;
int output=0;
- char text[100];
- text[0] ='\0';
int file_name_length=1000000;
char file_name[file_name_length];
int error_code=0;
struct yaffs_stat stat;
int output=0;
- char text[100];
- text[0] ='\0';
+
output=yaffs_stat("/yaffs2/non-existing_file", &stat);
if (output<0){
error_code=yaffs_get_error();
int error_code=0;
struct yaffs_stat stat;
int output=0;
- char text[100];
- text[0] ='\0';
+
output=yaffs_stat("/non-existing-dir/foo", &stat);;
if (output<0){
error_code=yaffs_get_error();
int error_code=0;
struct yaffs_stat stat;
int output=0;
- char text[100];
- text[0] ='\0';
+
if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
print_message("failed to create file\n",1);
return -1;
int error_code=0;
struct yaffs_stat stat;
int output=0;
- char text[100];
- text[0] ='\0';
+
output=yaffs_stat(NULL, &stat);
if (output<0){
error_code=yaffs_get_error();
*/
#include "test_yaffs_truncate.h"
-static int handle= -1;
int test_yaffs_truncate_EISDIR(void)
{
int error=0;
int output=0;
- output= yaffs_truncate("/yaffs2/foo",10000000000000000000000000000000000000000000 );
+ output= yaffs_truncate("/yaffs2/foo", YAFFS_TEST_LONG_VALUE);
if (output<0){
error=yaffs_get_error();
if (abs(error)==EINVAL){ /*in yaffs EINVAL is used instead of big_file */
*/
#include "test_yaffs_open_EROFS.h"
+#include "test_yaffs_open.h"
+
static int output =0;
int test_yaffs_unlink_EROFS(void)
*/
#include "test_yaffs_unmount2_with_handle_open_and_forced_mode_off.h"
+#include "test_yaffs_open.h"
int test_yaffs_unmount2_with_handle_open_and_forced_mode_off(void)
{
int output = -1;
int error_code =0;
+
output=test_yaffs_open();
if (output<0) {
print_message("failed to open file\n",2);
*/
#include "test_yaffs_unmount2_with_handle_open_and_forced_mode_on.h"
+#include "test_yaffs_open.h"
int test_yaffs_unmount2_with_handle_open_and_forced_mode_on(void)
{
int output = -1;
- int error_code =0;
+
output=test_yaffs_open();
if (output<0) {
print_message("failed to open file\n",2);
}
} else if (output >=0){
print_message("non existant directory opened.(which is a bad thing)\n",2);
- return -1;
}
+ return -1;
}
int test_yaffs_unmount_ENODEV_clean(void)
print_message("NULL path opened.(which is a bad thing)\n",2);
return -1;
}
+
+ return -1;
}
int test_yaffs_unmount_NULL_clean(void)