diff --git a/.directory b/.directory index 12b136299e653255777fcf2f362c56e0a7cd1d2b..caec04340910f06e73e19d3d3a0192c241633ef8 100644 --- a/.directory +++ b/.directory @@ -1,6 +1,3 @@ [Dolphin] -Timestamp=2013,1,7,14,37,46 +Timestamp=2013,1,8,14,55,19 Version=3 - -[Settings] -HiddenFilesShown=true diff --git a/Makefile b/Makefile index 3e615d0e76d932f2d05158f3a552b89e84039252..c665a793f23c581aa0c244def5b0027b35ad8462 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ SUBDIRS := miosix ## List here your source files (both .s, .c and .cpp) ## SRC := \ -main.cpp +./miosix/testsuite/testsuite.cpp +#main.cpp ## ## List here additional static libraries with relative path diff --git a/miosix/testsuite/testsuite.cpp b/miosix/testsuite/testsuite.cpp index 66f82e393bf18145229daa688282c60738d97790..e24ff01e349d0c3ecda58db8cf1646e09f09b74b 100644 --- a/miosix/testsuite/testsuite.cpp +++ b/miosix/testsuite/testsuite.cpp @@ -47,6 +47,12 @@ #include "board_settings.h" #include "interfaces/endianness.h" +#include "miosix/kernel/elf_program.h" +#include "miosix/kernel/process.h" + +#include "testsuite_syscall.h" +#include "testsuite_simple.h" + using namespace miosix; // A reasonably small stack value for spawning threads during the test. @@ -97,6 +103,9 @@ static void benchmark_4(); static void exception_test(); #endif //__NO_EXCEPTIONS +#ifdef WITH_PROCESSES +void syscall_test_1(); +#endif //main(), calls all tests int main() { @@ -106,7 +115,7 @@ int main() for(;;) { iprintf("Type 't' for kernel test, 'f' for filesystem test, 'x' for " - "exception test, 'b' for benchmarks or 's' for shutdown\n"); + "exception test, 'b' for benchmarks, 'p' for process test, 'y' for syscall test or 's' for shutdown\n"); char c; for(;;) { @@ -179,6 +188,15 @@ int main() iprintf("Shutting down\n"); while(!Console::txComplete()) ; shutdown(); + case 'y': + #ifdef WITH_PROCESSES + ledOn(); + syscall_test_1(); + ledOff(); + #else + fail("Process not supported"); + #endif + break; default: iprintf("Unrecognized option\n"); } @@ -217,6 +235,59 @@ static void fail(const char *cause) reboot(); } +void syscall_test_1(){ + test_name("System Call: open, read, write, seek, close, sytem"); + + char msg[256] = {0}; + + ElfProgram prog(reinterpret_cast<const unsigned int*>(testsuite_syscall_elf),testsuite_syscall_len); + int ret = 0; + + remove("/testsuite.bin"); + + pid_t child = Process::create(prog); + Process::waitpid(child, &ret, 0); + + switch(ret){ + case 0: + pass(); + break; + case 1: + fail("open with O_RDWR should have failed, the file doesn't exist"); + break; + case 2: + fail("cannot craete new file"); + break; + case 3: + fail("file descriptor not valid"); + break; + case 4: + fail("write has written the wrong amount of data"); + break; + case 5: + fail("read has read the wrong amount of data"); + break; + case 6: + fail("readed data doesn't match the written one"); + break; + case 7: + fail("close hasn't returned 0"); + break; + case 8: + fail("open with O_RDWR failed, but the file exists"); + break; + case 9: + fail("read has return the wrogn amount of data"); + break; + case 10: + fail("readed data doesn't match the written one"); + break; + case 11: + fail("close hasn't returned 0"); + break; + } +} + // // Test 1 // diff --git a/miosix/testsuite/testsuit_simple.h b/miosix/testsuite/testsuite_simple.h similarity index 92% rename from miosix/testsuite/testsuit_simple.h rename to miosix/testsuite/testsuite_simple.h index df98510dd67244516ed59a2dac03e966446ff207..66e912f2316697f61d77dd7f0875427307d5286b 100644 --- a/miosix/testsuite/testsuit_simple.h +++ b/miosix/testsuite/testsuite_simple.h @@ -1,4 +1,4 @@ -const unsigned char __attribute__((aligned(8))) test_elf[] = { +const unsigned char __attribute__((aligned(8))) testsuit_simple[] = { 0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -19,4 +19,4 @@ const unsigned char __attribute__((aligned(8))) test_elf[] = { 0x4d, 0x69, 0x6f, 0x73, 0x69, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -unsigned int test_elf_len = 220; +unsigned int testsuit_simple_len = 220; diff --git a/miosix/testsuite/testsuit_simple/.h b/miosix/testsuite/testsuite_simple/.h similarity index 100% rename from miosix/testsuite/testsuit_simple/.h rename to miosix/testsuite/testsuite_simple/.h diff --git a/miosix/testsuite/testsuit_simple/Makefile b/miosix/testsuite/testsuite_simple/Makefile similarity index 100% rename from miosix/testsuite/testsuit_simple/Makefile rename to miosix/testsuite/testsuite_simple/Makefile diff --git a/miosix/testsuite/testsuit_simple/crt0.s b/miosix/testsuite/testsuite_simple/crt0.s similarity index 100% rename from miosix/testsuite/testsuit_simple/crt0.s rename to miosix/testsuite/testsuite_simple/crt0.s diff --git a/miosix/testsuite/testsuit_simple/log.txt b/miosix/testsuite/testsuite_simple/log.txt similarity index 100% rename from miosix/testsuite/testsuit_simple/log.txt rename to miosix/testsuite/testsuite_simple/log.txt diff --git a/miosix/testsuite/testsuit_simple/main.c b/miosix/testsuite/testsuite_simple/main.c similarity index 100% rename from miosix/testsuite/testsuit_simple/main.c rename to miosix/testsuite/testsuite_simple/main.c diff --git a/miosix/testsuite/testsuit_simple/miosix.ld b/miosix/testsuite/testsuite_simple/miosix.ld similarity index 100% rename from miosix/testsuite/testsuit_simple/miosix.ld rename to miosix/testsuite/testsuite_simple/miosix.ld diff --git a/miosix/testsuite/testsuit_simple/prog3.h b/miosix/testsuite/testsuite_simple/prog3.h similarity index 100% rename from miosix/testsuite/testsuit_simple/prog3.h rename to miosix/testsuite/testsuite_simple/prog3.h diff --git a/miosix/testsuite/testsuit_simple/test.txt b/miosix/testsuite/testsuite_simple/test.txt similarity index 100% rename from miosix/testsuite/testsuit_simple/test.txt rename to miosix/testsuite/testsuite_simple/test.txt diff --git a/miosix/testsuite/testsuit_syscall.h b/miosix/testsuite/testsuite_syscall.h similarity index 96% rename from miosix/testsuite/testsuit_syscall.h rename to miosix/testsuite/testsuite_syscall.h index dfc8d01c15d4a698bac7ee298b59583d21092875..94e1ef64ef4bd1aedae711e1107ccbdb3dfbf7c4 100644 --- a/miosix/testsuite/testsuit_syscall.h +++ b/miosix/testsuite/testsuite_syscall.h @@ -1,4 +1,4 @@ -const unsigned char __attribute__((aligned(8))) test_elf[] = { +const unsigned char __attribute__((aligned(8))) testsuite_syscall_elf[] = { 0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -45,4 +45,4 @@ const unsigned char __attribute__((aligned(8))) test_elf[] = { 0x00, 0x00, 0x00, 0x00, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x75, 0x69, 0x74, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0x00, 0x00 }; -unsigned int test_elf_len = 536; +unsigned int testsuite_syscall_len = 536; diff --git a/miosix/testsuite/testsuit_syscall/.h b/miosix/testsuite/testsuite_syscall/.h similarity index 100% rename from miosix/testsuite/testsuit_syscall/.h rename to miosix/testsuite/testsuite_syscall/.h diff --git a/miosix/testsuite/testsuit_syscall/Makefile b/miosix/testsuite/testsuite_syscall/Makefile similarity index 100% rename from miosix/testsuite/testsuit_syscall/Makefile rename to miosix/testsuite/testsuite_syscall/Makefile diff --git a/miosix/testsuite/testsuit_syscall/crt0.s b/miosix/testsuite/testsuite_syscall/crt0.s similarity index 100% rename from miosix/testsuite/testsuit_syscall/crt0.s rename to miosix/testsuite/testsuite_syscall/crt0.s diff --git a/miosix/testsuite/testsuit_syscall/log.txt b/miosix/testsuite/testsuite_syscall/log.txt similarity index 100% rename from miosix/testsuite/testsuit_syscall/log.txt rename to miosix/testsuite/testsuite_syscall/log.txt diff --git a/miosix/testsuite/testsuit_syscall/main.c b/miosix/testsuite/testsuite_syscall/main.c similarity index 76% rename from miosix/testsuite/testsuit_syscall/main.c rename to miosix/testsuite/testsuite_syscall/main.c index 8068820db973fa46283377504adbb4f1b2c58670..eaebafa307410c6d52d4940e5026f7dea06b0af7 100644 --- a/miosix/testsuite/testsuit_syscall/main.c +++ b/miosix/testsuite/testsuite_syscall/main.c @@ -18,50 +18,52 @@ int main(){ for(i = 0; i < SIZE; i++) buffer[i] = i; - int fd = open("/testsuit.bin", O_RDWR, 0); + int fd = open("/testsuite.bin", O_RDWR, 0); if(fd != -1) - return error(0); + return error(1); + + close(fd); - fd = open("/testsuit.bin", O_RDWR|O_TRUNC, 0); + fd = open("/testsuite.bin", O_RDWR|O_TRUNC, 0); if(fd == -1) - return error(1); + return error(2); if(fd >= 0 && fd <= 2) - return error(2); + return error(3); if(write(fd, buffer, SIZE) != SIZE) - return error(3); + return error(4); seek(fd, SEEK_SET, 0); if(read(fd, buffer2, SIZE) != SIZE) - return error(4); + return error(5); for(i = 0; i < SIZE; i++){ if(buffer[i] != buffer2[i]) - return error(5); + return error(6); } if(close(fd) != 0) - return error(6); + return error(7); - fd = open("/testsuit.bin", O_RDWR); + fd = open("/testsuite.bin", O_RDWR); if(fd < 2) - return error(7); + return error(8); if(read(fd, buffer2, SIZE) != SIZE) - return error(8); + return error(9); for(i = 0; i < SIZE; i++){ if(buffer[i] != buffer2[i]) - return error(9); + return error(10); } if(close(fd)) - return error(10); + return error(11); return 0; } diff --git a/miosix/testsuite/testsuit_syscall/miosix.ld b/miosix/testsuite/testsuite_syscall/miosix.ld similarity index 100% rename from miosix/testsuite/testsuit_syscall/miosix.ld rename to miosix/testsuite/testsuite_syscall/miosix.ld diff --git a/miosix/testsuite/testsuit_syscall/prog3.h b/miosix/testsuite/testsuite_syscall/prog3.h similarity index 100% rename from miosix/testsuite/testsuit_syscall/prog3.h rename to miosix/testsuite/testsuite_syscall/prog3.h diff --git a/miosix/testsuite/testsuit_syscall/test.txt b/miosix/testsuite/testsuite_syscall/test.txt similarity index 100% rename from miosix/testsuite/testsuit_syscall/test.txt rename to miosix/testsuite/testsuite_syscall/test.txt