testmain.cpp 2.2 KB

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