# yaffs_checkptrwtest.o\
TESTFILES = quick_tests.o lib.o \
- test_yaffs_mount.o test_yaffs_mount_ENODEV.o test_yaffs_mount_ENAMETOOLONG.o test_yaffs_mount_ENOENT.o test_yaffs_mount_EBUSY.o \
- test_yaffs_unmount.o test_yaffs_unmount_ENOENT.o test_yaffs_unmount_ENAMETOOLONG.o test_yaffs_unmount_EBUSY.o \
+ test_yaffs_mount.o test_yaffs_mount_ENODEV.o test_yaffs_mount_ENAMETOOLONG.o test_yaffs_mount_EBUSY.o \
+ test_yaffs_unmount.o test_yaffs_unmount_ENODEV.o test_yaffs_unmount_ENAMETOOLONG.o test_yaffs_unmount_EBUSY.o \
test_yaffs_open.o test_yaffs_open_ENOENT.o test_yaffs_open_ENOTDIR.o test_yaffs_open_EEXIST.o test_yaffs_open_EISDIR.o test_yaffs_open_ENAMETOOLONG.o \
test_yaffs_open_EINVAL.o test_yaffs_open_EINVAL2.o \
test_yaffs_unlink.o test_yaffs_unlink_EISDIR.o test_yaffs_unlink_ENOENT.o test_yaffs_unlink_ENAMETOOLONG.o test_yaffs_unlink_ENOTDIR.o\
test_yaffs_mount
test_yaffs_mount_ENODEV
test_yaffs_mount_ENAMETOOLONG
- test_yaffs_mount_ENOENT
+ test_yaffs_mount_ENODEV
test_yaffs_mount_EBUSY //caused by trying to mount a new mount point with a mount point already mounted.
test_yaffs_access
test_yaffs_unlink_ENOTDIR
test_yaffs_unmount
- test_yaffs_unmount_ENOENT
+ test_yaffs_unmount_ENODEV
test_yaffs_unmount_ENAMETOOLONG
test_yaffs_umount_EBUSY //cause by having a file handle open and then trying to unmount yaffs.
#include "lib.h"
+static int EXIT_ON_ERROR = 1;
+static int PRINT_LEVEL = 1; //This sets the level of detail which is printed. There are 3 levels 0,1,2 and 3
+ //0 just prints the number of tests passed and failed.
+ //1 is the basic print level. it will print the details of a failed test.
+ //2 will print if a test passes and cleans.
+void set_print_level(int new_level)
+{
+ PRINT_LEVEL=new_level;
+}
+
+void set_exit_on_error(int num)
+{
+ EXIT_ON_ERROR=num;
+}
+
+int get_exit_on_error(void)
+{
+ return EXIT_ON_ERROR;
+}
void join_paths(char *path1,char *path2,char *new_path )
{
#include <stdio.h>
#include <string.h>
-#define EXIT_ON_ERROR 0
-#define PRINT_LEVEL 2 //This sets the level of detail which is printed. There are 3 levels 0,1,2 and 3
- //0 just prints the number of tests passed and failed.
- //1 is the basic print level. it will print the details of a failed test.
- //2 will print if a test passes and cleans.
+
#define YAFFS_MOUNT_POINT "/yaffs2/"
#define FILE_NAME "foo"
void join_paths(char *path1,char *path2,char *new_path );
void print_message(char *message,char print_level);
+void set_print_level(int new_level);
+void set_exit_on_error(int num);
+int get_exit_on_error(void);
#endif
static unsigned int num_of_tests_failed=0;
static unsigned int total_number_of_tests=(sizeof(test_list)/sizeof(test_template));
-int main(){
+int main(int argc, char *argv[]){
int output=0;
char message[30];
message[0]='\0';
+ unsigned int x=0;
- unsigned int x=0;
- init_quick_tests();
+ init_quick_tests(argc, argv);
print_message("\n\nrunning quick tests for yaffs\n\n", 0);
//printf("testing yaffs\n");
get_error();
print_message("\n\n",1);
- if (EXIT_ON_ERROR){
+ if (get_exit_on_error()){
quit_quick_tests(1);
}
num_of_tests_pass--;
get_error();
printf("\n\n");
- if (EXIT_ON_ERROR){
+ if (get_exit_on_error()){
quit_quick_tests(1);
}
print_message(message,1);
}
-void init_quick_tests(void)
+void init_quick_tests(int argc, char *argv[])
{
+ int trace=0;
+ int x=0;
+ for (x = 0; x < argc; x++){
+ if (0==strcmp(argv[x],"-h")){
+ printf("help\n");
+ printf("-h will print the commands available\n");
+ printf("-c will continue after a test failes else the program will exit\n");
+ printf("-v will print all messages\n");
+ printf("-q quiet mode only the number of tests passed and failed will be printed\n");
+ printf("-t [number] set yaffs_trace to number\n");
+ exit(0);
+ } else if (0==strcmp(argv[x],"-c")) {
+ set_exit_on_error(0);
+ } else if (0==strcmp(argv[x],"-q")) {
+ set_print_level(-3);
+ } else if (0==strcmp(argv[x],"-t")) {
+ trace = atoi(argv[x+1]);
+ } else if (0==strcmp(argv[x],"-v")) {
+ set_print_level(5);
+ }
+
+ }
yaffs_start_up();
- yaffs_set_trace(0);
+ yaffs_set_trace(trace);
}
#include "test_yaffs_mount.h"
#include "test_yaffs_mount_ENODEV.h"
#include "test_yaffs_mount_ENAMETOOLONG.h"
-#include "test_yaffs_mount_ENOENT.h"
#include "test_yaffs_mount_EBUSY.h"
#include "test_yaffs_unmount.h"
-#include "test_yaffs_unmount_ENOENT.h"
+#include "test_yaffs_unmount_ENODEV.h"
#include "test_yaffs_unmount_ENAMETOOLONG.h"
#include "test_yaffs_unmount_EBUSY.h"
{test_yaffs_mount,test_yaffs_mount_clean,"test_yaffs_mount"},
{test_yaffs_mount_ENODEV,test_yaffs_mount_ENODEV_clean,"test_yaffs_mount_ENODEV"},
{test_yaffs_mount_ENAMETOOLONG,test_yaffs_mount_ENAMETOOLONG_clean,"test_yaffs_mount_ENAMETOOLONG"},
- {test_yaffs_mount_ENOENT,test_yaffs_mount_ENOENT_clean,"test_yaffs_mount_ENOENT"},
{test_yaffs_mount_EBUSY,test_yaffs_mount_EBUSY_clean,"test_yaffs_mount_EBUSY"},
{test_yaffs_unmount,test_yaffs_unmount_clean,"test_yaffs_unmount"},
- {test_yaffs_unmount_ENOENT,test_yaffs_unmount_ENOENT_clean,"test_yaffs_unmount_ENOENT"},
+ {test_yaffs_unmount_ENODEV,test_yaffs_unmount_ENODEV_clean,"test_yaffs_unmount_ENODEV"},
{test_yaffs_unmount_ENAMETOOLONG,test_yaffs_unmount_ENAMETOOLONG_clean,"test_yaffs_unmount_ENAMETOOLONG"},
{test_yaffs_unmount_EBUSY,test_yaffs_unmount_EBUSY_clean,"test_yaffs_unmount_EBUSY"},
{test_yaffs_write,test_yaffs_write_clean,"test_yaffs_write"},
{test_yaffs_write_EBADF,test_yaffs_write_EBADF_clean,"test_yaffs_write_EBADF"},
- {test_yaffs_write_EFBIG,test_yaffs_write_EFBIG_clean,"test_yaffs_write_EFBIG"},
+// {test_yaffs_write_EFBIG,test_yaffs_write_EFBIG_clean,"test_yaffs_write_EFBIG"},
{test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"},
{test_yaffs_read_EBADF,test_yaffs_read_EBADF_clean,"test_yaffs_read_EBADF"},
{test_yaffs_fchmod_EBADF,test_yaffs_fchmod_EBADF_clean,"test_yaffs_fchmod_EBADF"}
};
-void init_quick_tests(void);
+void init_quick_tests(int argc, char *argv[]);
void quit_quick_tests(int exit_code);
void get_error(void);
#endif
int test_yaffs_chmod_EINVAL_clean(void)
{
- return 1;
+ return test_yaffs_chmod();
}
#include "lib.h"
#include "yaffsfs.h"
+#include "test_yaffs_chmod.h"
int test_yaffs_chmod_EINVAL(void);
int test_yaffs_chmod_EINVAL_clean(void);
int test_yaffs_chmod_EINVAL2_clean(void)
{
- return 1;
+ return test_yaffs_chmod();
}
#include "lib.h"
#include "yaffsfs.h"
+#include "test_yaffs_chmod.h"
int test_yaffs_chmod_EINVAL2(void);
int test_yaffs_chmod_EINVAL2_clean(void);
+++ /dev/null
-/*
- * YAFFS: Yet another FFS. A NAND-flash specific file system.
- *
- * Copyright (C) 2002-2010 Aleph One Ltd.
- * for Toby Churchill Ltd and Brightstar Engineering
- *
- * Created by Timothy Manning <timothy@yaffs.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include "test_yaffs_mount_ENOENT.h"
-
-
-int test_yaffs_mount_ENOENT(void)
-{
- int output = 0;
- int error_code = 0;
-
- /* if a second file system is mounted then yaffs will return EBUSY. so first unmount yaffs */
- output = test_yaffs_unmount();
- if (output < 0){
- print_message("yaffs failed to unmount\n", 2);
- return -1;
- }
-
- output = yaffs_mount("/non_existaint_mount_point/");
- if (output == -1){
- error_code = yaffs_get_error();
- if (abs(error_code) == ENODEV){
- return 1;
- } else {
- print_message("different error than expected\n", 2);
- return -1;
- }
- } else {
- print_message("non existant mount point mounted.(which is a bad thing)\n",2);
- return -1;
- }
-
-}
-
-int test_yaffs_mount_ENOENT_clean(void)
-{
- return test_yaffs_mount();
-}
-
* published by the Free Software Foundation.
*/
-#include "test_yaffs_mount_ENOENT.h"
+#include "test_yaffs_unmount_ENODEV.h"
-int test_yaffs_unmount_ENOENT(void)
+static int handle = 0;
+
+int test_yaffs_unmount_ENODEV(void)
{
int output=0;
int error_code=0;
- output=yaffs_unmount("/non_existaint_mount_point/");
- if (output==-1){
- error_code=yaffs_get_error();
- if (abs(error_code)==EINVAL){
+ handle = yaffs_unmount("/nonexisting_mount_point/");
+ if (handle==-1){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == ENODEV){
return 1;
} else {
print_message("different error than expected\n",2);
return -1;
}
- } else {
- print_message("non existant mount point unmounted.(which is a bad thing)\n",2);
+ } else if (output >=0){
+ print_message("non existant directory opened.(which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_unmount_ENOENT_clean(void)
+
+int test_yaffs_unmount_ENODEV_clean(void)
{
return 1;
}
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*/
-#ifndef __test_yaffs_mount_ENOENT_h__
-#define __test_yaffs_mount_ENOENT_h__
+#ifndef __test_yaffs_unmount_ENODEV_h__
+#define __test_yaffs_unmount_ENODEV_h__
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_unmount.h"
-#include "test_yaffs_mount.h"
-int test_yaffs_mount_ENOENT(void);
-int test_yaffs_mount_ENOENT_clean(void);
+int test_yaffs_unmount_ENODEV(void);
+int test_yaffs_unmount_ENODEV_clean(void);
#endif
+++ /dev/null
-/*
- * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
- *
- * Copyright (C) 2002-2010 Aleph One Ltd.
- * for Toby Churchill Ltd and Brightstar Engineering
- *
- * Created by Timothy Manning <timothy@yaffs.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 2.1 as
- * published by the Free Software Foundation.
- *
- * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
- */
-
-#ifndef __test_yaffs_unmount_ENOENT_h__
-#define __test_yaffs_unmount_ENOENT_h__
-
-#include "lib.h"
-#include "yaffsfs.h"
-#include "test_yaffs_unmount.h"
-#include "test_yaffs_mount.h"
-
-int test_yaffs_unmount_ENOENT(void);
-int test_yaffs_unmount_ENOENT_clean(void);
-
-#endif