source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Priority/SelfTest/src/main.cpp @ 88

Last change on this file since 88 was 88, checked in by rosiere, 16 years ago

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1/*
2 * $Id: main.cpp 88 2008-12-10 18:31:39Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Generic/Priority/SelfTest/include/test.h"
9
10#define NB_PARAMS 4
11
12void usage (int argc, char * argv[])
13{
14  err (_("<Usage> %s name_instance list_params.\n"),argv[0]);
15  err (_("list_params is :\n"));
16  err (_(" * priority                (Tpriority_t      )\n"));
17  err (_(" * load_balancing          (Tload_balancing_t)\n"));
18  err (_(" * nb_grp                  (uint32_t         )\n"));
19  err (_(" * nb_elt         [nb_grp] (uint32_t         )\n"));
20  err (_(" * nb_grp_select           (uint32_t         )\n"));
21
22  exit (1);
23}
24
25#ifndef SYSTEMC
26int main    (int argc, char * argv[])
27#else
28int sc_main (int argc, char * argv[])
29#endif
30{
31  if (argc <= static_cast<int>(2+NB_PARAMS))
32    usage (argc, argv);
33
34  uint32_t x = 1;
35
36  string name = argv[x++];
37  Tpriority_t       _priority       = fromString<Tpriority_t      >(argv[x++]);
38  Tload_balancing_t _load_balancing = fromString<Tload_balancing_t>(argv[x++]);
39
40  uint32_t          _nb_grp         = fromString<uint32_t         >(argv[x++]);
41
42  if (argc != static_cast<int>(2+NB_PARAMS+_nb_grp))
43    usage (argc, argv);
44
45  uint32_t        * _nb_elt = new uint32_t [_nb_grp];
46  for (uint32_t i=0; i<_nb_grp; i++)
47    _nb_elt [i] = fromString<uint32_t>(argv[x++]);
48
49  uint32_t          _nb_grp_select  = fromString<uint32_t         >(argv[x++]);
50
51  int _return = EXIT_SUCCESS;
52  try 
53    {
54      Priority * _Priority = new Priority
55        (name.c_str(),
56         _priority,
57         _load_balancing,
58         _nb_grp       ,
59         _nb_elt       ,
60         _nb_grp_select);
61     
62      _Priority->reset();
63
64
65      std::list<select_t> * select;
66
67      for (uint32_t i=0; i<32; i++)
68        {
69          msg("Iteration [%d]\n",i);
70          _Priority->transition();
71          select = _Priority->select();
72          for (std::list<select_t>::iterator it = select->begin();
73               it != select->end();
74               it ++)
75            {
76              msg("  - [%d] %d\n",(*it).grp, (*it).elt);
77            }
78        }
79
80      delete _Priority;
81    }
82  catch (morpheo::ErrorMorpheo & error)
83    {
84      msg (_("<%s> :\n%s"),name.c_str(), error.what ());
85      _return = EXIT_FAILURE;
86    }
87 
88  try 
89    {
90      if (_return == EXIT_SUCCESS)
91        TEST_OK("Priority : no error");
92      else
93        TEST_KO("Priority : a lot of error");
94    }
95  catch (morpheo::ErrorMorpheo & error)
96    {
97      msg (_("<%s> :\n%s"),name.c_str(), error.what ());
98      _return = EXIT_FAILURE;
99    }
100
101  return (_return);
102}
Note: See TracBrowser for help on using the repository browser.