X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Ftests%2FTest.c;fp=src%2Ftests%2FTest.c;h=5b0dda05843dfca8838ffe1157142cabdbede8dd;hb=3eb15f58ca0911489d7d9bdc0ac2c575d27a68d8;hp=0000000000000000000000000000000000000000;hpb=a6ee28ca37621098ed040e6d1c4ae103934c3e97;p=nestedvm.git diff --git a/src/tests/Test.c b/src/tests/Test.c new file mode 100644 index 0000000..5b0dda0 --- /dev/null +++ b/src/tests/Test.c @@ -0,0 +1,208 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char *user_info[1024]; + +extern void _pause(); +extern int _call_java(int a, int b, int c, int d); + +void suckram(); + +int main(int argc, char **argv) { + int i,n,fd; + time_t now; + DIR *dir; + struct dirent *dent; + char buf[1024]; + unsigned char ubuf[1024]; + unsigned short sbuf[1024]; + char *s; + + printf("Entered main()\n"); + + if(argc > 1 && strcmp(argv[1],"calltest")==0) { + printf("pausing for call test\n"); + _pause(); + printf("unpaused from call test\n"); + + for(i=1;i<=3;i++) { + char *s = (char*)_call_java(i,0,0,0); + printf("_call_java(%d,0,0,0) = \"%s\" (%d chars)\n",i,s,strlen(s)); + free(s); + } + fd = _call_java(4,0,0,0); + if(fd != -1) { + FILE *fp; + fprintf(stderr,"fd: %i\n",fd); + fp = fdopen(fd,"w"); + if(fp != NULL) { + fprintf(fp,"It worked! fp is %p - Hello, Java!\n",fp); + fclose(fp); + } else { + fprintf(stderr,"fdopen failed\n"); + close(fd); + } + } else { + fprintf(stderr,"fd == -1\n"); + } + + printf("In main() in MIPS\n"); + _call_java(5,0,0,0); + printf("Back in main() in MIPS\n"); + } else if(argc > 2 && strcmp(argv[1],"fdtest")==0) { + printf("opening %s\n",argv[2]); + fd = open(argv[2],O_RDONLY); + if(fd < 0) { perror("open"); exit(1); } + + printf("reading up to 64 bytes\n"); + n = read(fd,buf,64); + if(n < 0) {perror("read"); exit(1); } + printf("read %d bytes\n",n); + for(i=0;i 1 && strcmp(argv[1],"fptest")==0) { + double d = 0.0; + while(d != 10.0) { + printf("d: %f\n",d); + d += 2.5; + } + } else if(argc > 1 && strcmp(argv[1],"nullderef")==0) { + volatile int *mem = 0; + *mem = 1; + } else { + printf("%d\n", 0xffffff); + printf("%u\n", 0xffffffU); + printf("%li\n",0xffffffL); + printf("%lu\n",0xffffffUL); + + + for(i=0;id_name,dent->d_ino); + closedir(dir); + } else { + perror("opendir"); + } + + +#if 0 + printf("Sleeping...\n"); + sleep(1); + printf("Done\n"); +#endif + + fd = open("test.txt",O_RDONLY); + if(fd != -1) { + printf("Opened test.txt\n"); + n = read(fd,sbuf,sizeof(sbuf)); + printf("n: %d\n",n); + if(n < 0) perror("read"); + ubuf[n] = '\0'; + printf("buf: %s\n",buf); + for(i=0;i