X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Ftimothy_tests%2Fmirror_tests%2Flib.c;h=e21e77d35a09426de3524f6001adadc762bf3df5;hp=4b9ebd67db3f1c9224c4d6be865547b56b88ac09;hb=ae68942c23ba444fc820519ac25865ab38edc3c5;hpb=137f935f6d622bffdef2fece0c5194e85f5174e9 diff --git a/direct/timothy_tests/mirror_tests/lib.c b/direct/timothy_tests/mirror_tests/lib.c index 4b9ebd6..e21e77d 100644 --- a/direct/timothy_tests/mirror_tests/lib.c +++ b/direct/timothy_tests/mirror_tests/lib.c @@ -22,6 +22,10 @@ void set_print_level(int new_level) { PRINT_LEVEL=new_level; } +int get_print_level(void) +{ + return PRINT_LEVEL; +} void set_exit_on_error(int num) { @@ -37,6 +41,55 @@ void display_error(void) { } + +void get_error_yaffs(void) +{ + int error_code=0; + char message[30]; + message[0]='\0'; + + error_code=yaffs_get_error(); + sprintf(message,"yaffs_error code %d\n",error_code); + print_message(1,message); + sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code)); + print_message(1,message); +} + +void get_error_linux(void) +{ + int error_code=0; + char message[30]; + message[0]='\0'; + + error_code=errno; + sprintf(message,"linux_error code %d\n",error_code); + print_message(1,message); + strcpy(message,"error code"); + sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code)); + //perror(message); + print_message(1,message); +} +void generate_random_string(char *ptr,int length_of_str){ + unsigned int x; + unsigned int length=((rand() %(length_of_str-3))+3); /*creates a int with the number of charecters been between 1 and 51*/ + char letter='\0'; + strcpy(ptr,""); + //printf("generating string\n"); + //printf("string length is %d\n",length); + for (x=0; x <= (length-2) &&length>2 ; x++) + { + //printf("x=%d\n",x); + /* keep generating a charecter until the charecter is legal*/ + while((letter=='\0' )||(letter=='/')||(letter=='\\')){ + letter=(rand() % 125-59)+58; /*generate a number between 32 and 126 and uses it as a charecter (letter) */ + } + ptr[x]=letter; + //printf("charecter generated is %c\n",ptr[x]); + } + ptr[x+1]='\0'; /*adds NULL charecter to turn it into a string*/ + +} + void join_paths(char *path1,char *path2,char *new_path ) { char message[100];