testmain.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include <cstdlib>
  2. #include <cstdio>
  3. #include "TestDesc.h"
  4. #if defined(EMBEDDED)
  5. #include "FPGA.h"
  6. #else
  7. #include "Semihosting.h"
  8. #endif
  9. #include "IORunner.h"
  10. #include "ArrayMemory.h"
  11. using namespace std;
  12. #ifdef BENCHMARK
  13. #define MEMSIZE 300000
  14. #else
  15. #define MEMSIZE 230000
  16. #endif
  17. // Dummy (will be generated by python scripts)
  18. // char* array describing the tests and the input patterns.
  19. // Reference patterns are ignored in this case.
  20. #include "TestDrive.h"
  21. int testmain(const char *patterns)
  22. {
  23. char *memoryBuf=NULL;
  24. memoryBuf = (char*)malloc(MEMSIZE);
  25. if (memoryBuf !=NULL)
  26. {
  27. try
  28. {
  29. // Choice of a memory manager.
  30. // Here we choose the Array one (only implemented one)
  31. Client::ArrayMemory memory(memoryBuf,MEMSIZE);
  32. // There is also possibility of using "FPGA" io
  33. #if defined(EMBEDDED)
  34. Client::FPGA io(testDesc,patterns);
  35. #else
  36. Client::Semihosting io("../TestDesc.txt","../Patterns","../Output","../Parameters");
  37. #endif
  38. // Pattern Manager making the link between IO and Memory
  39. Client::PatternMgr mgr(&io,&memory);
  40. // A Runner to run the test.
  41. // An IO runner is driven by some IO
  42. // In future one may have a client/server runner driven
  43. // by a server running on a host.
  44. #if defined(EMBEDDED)
  45. Client::IORunner runner(&io,&mgr,Testing::kTestOnly);
  46. //Client::IORunner runner(&io,&mgr,Testing::kTestAndDump);
  47. #else
  48. // Works also in embedded but slower since data is dumped
  49. Client::IORunner runner(&io,&mgr,Testing::kTestAndDump);
  50. #endif
  51. // Root object containing all the tests
  52. Root d(1);
  53. // Runner applied to the tree of tests
  54. d.accept(&runner);
  55. }
  56. catch(...)
  57. {
  58. printf("Exception\n");
  59. }
  60. free(memoryBuf);
  61. }
  62. else
  63. {
  64. printf("NOT ENOUGH MEMORY\n");
  65. }
  66. /* code */
  67. return 0;
  68. }