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