version 1.2, 2005/02/25 06:00:58
|
version 1.3, 2005/02/25 06:34:24
|
|
|
| |
| |
#ifdef TVFS_MAIN | #ifdef TVFS_MAIN |
static char file_test_txt[] = "This is a test. Don't Panic!"; |
const static char name_test_txt[] = "test.txt"; |
static int szfile_test_txt = sizeof(file_test_txt); |
const static char file_test_txt[] = "This is a test. Don't Panic!"; |
| |
main(){ | main(){ |
int result; | int result; |
|
|
| |
char *filebuf; | char *filebuf; |
| |
char test_filename[] = "test.txt"; |
|
char dummy_filename[] = "dummy.txt"; | char dummy_filename[] = "dummy.txt"; |
char bad_filename[] = "chicken.txt"; | char bad_filename[] = "chicken.txt"; |
| |
filebuf = malloc(MAXFLEN); | filebuf = malloc(MAXFLEN); |
| |
printf("Testing TVFS implementation, creating %s\n",test_filename); |
printf("Testing TVFS implementation, creating %s\n",name_test_txt); |
result = tvfs_create( dummy_filename, file_test_txt, szfile_test_txt ); |
result = tvfs_create( dummy_filename, file_test_txt, sizeof(file_test_txt)); |
result = tvfs_create( test_filename, file_test_txt, szfile_test_txt ); |
result = tvfs_create( name_test_txt, file_test_txt,sizeof(file_test_txt)); |
printf("Created virtual file with inode %d\n",result); | printf("Created virtual file with inode %d\n",result); |
| |
/* This test failes because strcmp returns 0 incorrectly! */ | /* This test failes because strcmp returns 0 incorrectly! */ |
|
|
result = tvfs_open(bad_filename, _O_BINARY, 0 ); | result = tvfs_open(bad_filename, _O_BINARY, 0 ); |
printf("Result code %d\n",result); | printf("Result code %d\n",result); |
printf("Attempting to open existant file\n"); | printf("Attempting to open existant file\n"); |
result = tvfs_open(test_filename, _O_BINARY, 0 ); |
result = tvfs_open(name_test_txt, _O_BINARY, 0 ); |
printf("Result code %d\n",result); | printf("Result code %d\n",result); |
| |
active_handler = result; | active_handler = result; |
| |
memset (filebuf,0,MAXFLEN); | memset (filebuf,0,MAXFLEN); |
| |
printf("Testing reading from file %s\n",test_filename); |
printf("Testing reading from file %s\n",name_test_txt); |
result = tvfs_read(active_handler, filebuf, 9); | result = tvfs_read(active_handler, filebuf, 9); |
printf("Read _%s_\n", filebuf); | printf("Read _%s_\n", filebuf); |
if ( strcmp(filebuf,"This is a")) { | if ( strcmp(filebuf,"This is a")) { |
printf("File read check failed!\n"); | printf("File read check failed!\n"); |
} | } |
| |
printf("Testing sequential reading from file %s\n",test_filename); |
printf("Testing sequential reading from file %s\n",name_test_txt); |
result = tvfs_read(active_handler, filebuf, 12); | result = tvfs_read(active_handler, filebuf, 12); |
printf("Read _%s_\n", filebuf); | printf("Read _%s_\n", filebuf); |
if ( strcmp(filebuf," test. Don't")) { | if ( strcmp(filebuf," test. Don't")) { |
printf("File read check failed!\n"); | printf("File read check failed!\n"); |
} | } |
| |
printf("Testing edge reading from file %s\n",test_filename); |
printf("Testing edge reading from file %s\n",name_test_txt); |
result = tvfs_read(active_handler, filebuf, 20); | result = tvfs_read(active_handler, filebuf, 20); |
printf("Read %d bytes - _%s_\n", result, filebuf); | printf("Read %d bytes - _%s_\n", result, filebuf); |
if ( result != 8 ) { | if ( result != 8 ) { |