source: trunk/IPs/systemC/processor/Morpheo/Common/include/Test.h @ 74

Last change on this file since 74 was 71, checked in by rosiere, 17 years ago

Modification of Statisctics
Add a new systemC component : Load_Store_Queue (tested with one benchmark and one configuration). Store don't supported the Data Buss Error (Load is supported)

File size: 2.5 KB
RevLine 
[2]1#ifndef TEST_H
2#define TEST_H
3
4#include <iostream>
5#include <sstream>
6#include <stdint.h>
[71]7#include "Common/include/Message.h"
[44]8#include "Common/include/ErrorMorpheo.h"
[71]9#include "Common/include/ToString.h"
[2]10
11//-----[ Routine de test ]---------------------------------------
12
13static uint32_t num_test;
14
[71]15inline void test_ko_error (void)
[53]16{
[71]17  string msg = "Test ko : error in test \""+morpheo::toString(num_test)+"\"";
18  throw (morpheo::ErrorMorpheo (msg));
[53]19}
20 
[2]21template <class T>
[71]22inline void test_ko (char * file, uint32_t line, T exp1, T exp2)
[2]23{
[53]24  cerr << "[" << num_test << "] : Test KO"
25       << "\tline " << line                           << endl
26       << " * Localisation"                           << endl
27       << "   - File : " << file                      << endl
28       << "   - Line : " << line                      << endl
29       << " * Expression is different"                << endl
[71]30       << "   - exp1 : "+morpheo::toString(exp1)               << endl
31       << "   - exp2 : "+morpheo::toString(exp2)               << endl;
[53]32
33  test_ko_error ();
[2]34};
35
[71]36inline void test_ko (char * file, uint32_t line)
[50]37{
[53]38  cerr << "[" << num_test << "] : Test KO"
39       << "\tline " << line                           << endl
40       << " * Localisation"                           << endl
41       << "   - File : " << file                      << endl
42       << "   - Line : " << line                      << endl;
[50]43 
[53]44  test_ko_error ();
[50]45};
46
[71]47inline void test_ok ()
[2]48{
[71]49  msg (_("[%d] : Test OK\n"), num_test);
[2]50
51  num_test ++;
52};
53
[71]54inline void test_ok (char * file, uint32_t line)
[53]55{
[71]56  msg (_("[%d] : Test OK\n"), num_test);
57  msg (_("\tline %d\n"), line);
[53]58
59  num_test ++;
60};
61
[2]62template <class T>
[71]63inline void test_ok (char * file, uint32_t line, T exp)
[2]64{
[71]65  msg (_("[%d] : Test OK\n"), num_test);
66  msg (_("\tline %d\n"), line);
67  msg (_("\tvalue %s\n"), (morpheo::toString(exp)).c_str());
[53]68
69  num_test ++;
70}
71
72template <class T>
[71]73inline void test(char * file, uint32_t line, T exp1, T exp2)
[53]74{
[2]75  if (exp1 != exp2)
[53]76    test_ko <T> (file,line,exp1,exp2);
[2]77  else
[53]78    test_ok <T> (file,line,exp1);
[2]79};
80
[53]81#define TEST(type,exp1,exp2)            do {test<type> (__FILE__,__LINE__,exp1,exp2);} while(0)
82#define TEST_STR(type,exp1,exp2,str...) do {fprintf(stdout,str); fprintf(stdout,"\n"); test<type> (__FILE__,__LINE__,exp1,exp2);} while(0)
83#define TEST_OK(str...)                 do {fprintf(stdout,str); fprintf(stdout,"\n"); test_ok(__FILE__,__LINE__);} while(0)
[50]84#define TEST_KO(str...)                 do {fprintf(stdout,str); fprintf(stdout,"\n"); test_ko(__FILE__,__LINE__);} while(0)
[2]85
[50]86
[2]87#endif
Note: See TracBrowser for help on using the repository browser.