Ignore:
Timestamp:
May 28, 2013, 11:17:14 AM (11 years ago)
Author:
meunier
Message:

Tried to clean the test_regression directory:

  • Code formatting
  • Supressed warnings
  • Made comprehensible outputs
  • Factorized Makefiles

There's still a lot to do (many tests don't pass for either good or bad reasons)

Location:
sources/test_regression/16062005a
Files:
3 deleted
2 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • sources/test_regression/16062005a/Makefile

    r15 r55  
     1
    12include ../env.mk
     3HIERARCHY = object_hierarchy.txt
     4ERASE = $(HIERARCHY)
     5include ../Makefile.common
    26
    3 SYSTEM    = system.cpp system2.cpp
    4 EXE_SCASS = $(SYSTEM:.cpp=_systemcass.x)
    5 EXE_SC    = $(SYSTEM:.cpp=_systemc.x)
    6 EXE       = ${EXE_SCASS} ${EXE_SC}
    7 LOG       = $(SYSTEM:.cpp=.log)
    8 OBJECTS   = $(EXE:.x=.o)
    9 LINKS     = $(OBJECTS:.o=.cpp)
     7HIERARCHY_REF = object_hierarchy_ref.txt
    108
    11 .SECONDARY:
     9test : $(EXE_SCASS)
     10        @echo -ne "| Testing $$(basename $$(pwd)): " ;
     11        @./$(EXE_SCASS) $(HIERARCHY) 2> /dev/null
     12        @if diff $(HIERARCHY) $(HIERARCHY_REF) > /dev/null ; then \
     13    echo "OK" ; \
     14    else echo "KO" ; \
     15    fi ;
    1216
    13 main : $(EXE_SCASS)
    1417
    15 test : main
    16         ./system_systemcass.x object_hierarchy1.txt
    17         diff object_hierarchy1_reference.txt object_hierarchy1.txt
    18         ./system2_systemcass.x object_hierarchy2.txt
    19         diff object_hierarchy2_reference.txt object_hierarchy2.txt
    20         @echo Test OK.
    2118
    22 %.gif : %.dot
    23         dot -Tgif -o $*.gif $*.dot
    24 
    25 %_systemc.x : %_systemc.o $(SYSTEMC_LIB)
    26         $(CXX) -o $@ $*_systemc.o $(LFLAGS_SYSTEMC) 2>&1 | $(CPPFILT)
    27 
    28 %_systemcass.x : %_systemcass.o  $(SYSTEMCASS_LIB)
    29         $(CXX) -o $@ $*_systemcass.o $(LFLAGS_SYSTEMCASS) 2>&1 | $(CPPFILT)
    30 
    31 -include Makefile.deps
    32 
    33 %_systemc.cpp : %.cpp
    34         ln -s $*.cpp $*_systemc.cpp
    35 
    36 %_systemcass.cpp : %.cpp
    37         ln -s $*.cpp $*_systemcass.cpp
    38 
    39 %_systemc.o : %_systemc.cpp
    40         $(CXX) $(CFLAGS_SYSTEMC) -MM $*_systemc.cpp >> Makefile.deps
    41         $(CXX) $(CFLAGS_SYSTEMC) -c $*_systemc.cpp -o $*_systemc.o
    42 
    43 %_systemcass.o : %_systemcass.cpp
    44         $(CXX) $(CFLAGS_SYSTEMCASS) -MM $*_systemcass.cpp >> Makefile.deps
    45         $(CXX) $(CFLAGS_SYSTEMCASS) -c $*_systemcass.cpp -o $*_systemcass.o
    46 
    47 clean :
    48         rm -f Makefile.deps
    49         -rm -f *.o gmon.out *~
    50         -rm -f ${LOG}
    51         -rm -f signal_order.txt module_order.dot signal_graph.dot
    52         -rm -f module_order.gif signal_graph.gif
    53         -rm -f $(EXE) $(OBJECTS)
    54         -for i in $(LINKS) ; do unlink $$i ; done 2> /dev/null
    55         -rm -f core*
    56         -rm -rf generated_by_systemcass
    57         -rm -rf system_systemcass.x.vcd system_systemc.x.vcd
    58        
  • sources/test_regression/16062005a/system.cpp

    r1 r55  
    1 #include "systemc.h"
     1
    22#include <iostream>
    33#include <fstream>
    44#include <vector>
    55
    6 #define ASSERT(x) { if (!(x)) { \
    7                       cerr << "ASSERT : " #x \
    8                            << " in function '" << __FUNCTION__  \
    9                            << "'\n"; exit (-1); \
    10                     } \
    11                   }
     6#include "systemc.h"
     7#include "test.h"
    128
    139
    1410using namespace std;
    1511
    16 struct D : sc_module
    17 {
    18   D (sc_module_name)
    19   {
    20   }
     12struct D : sc_module {
     13    D(sc_module_name) {}
    2114};
    2215
    23 struct C : sc_module
    24 {
    25   C (sc_module_name)
    26   {
    27   }
     16
     17
     18struct C : sc_module {
     19    C(sc_module_name) {}
    2820};
    2921
    30 struct B : sc_module
    31 {
    32   D d1;
    33   D d2;
    34   C c;
    35   B (sc_module_name) : d1("d1"), d2("d2"), c("c")
    36   {
    37   }
     22
     23struct B : sc_module {
     24    D d1;
     25    D d2;
     26    C c;
     27    B(sc_module_name) : d1("d1"), d2("d2"), c("c") {}
    3828};
    3929
    40 struct A : sc_module
    41 {
    42   B b;
    43   C c;
    44   A (sc_module_name) : b("b"), c("c")
    45   {
    46   }
     30
     31struct A : sc_module {
     32    B b;
     33    C c;
     34    A(sc_module_name) : b("b"), c("c") {}
    4735};
    4836
    49 struct top_level1 : sc_module
    50 {
    51   A a;
    52   D d;
    53   top_level1(sc_module_name) : a("a"), d("d")
    54   {
    55   }
     37
     38struct top_level1 : sc_module {
     39    A a;
     40    D d;
     41    top_level1(sc_module_name) : a("a"), d("d") {}
    5642};
    5743
    58 struct top_level2 : sc_module
    59 {
    60   B b1;
    61   B b2;
    62   C c;
    63   top_level2(sc_module_name) : b1("b1"), b2("b2"), c("c")
    64   {
    65   }
     44
     45struct top_level2 : sc_module {
     46    B b1;
     47    B b2;
     48    C c;
     49    top_level2(sc_module_name) : b1("b1"), b2("b2"), c("c") {}
    6650};
    6751
    68 void
    69 dump_hierarchy (ostream &o, sc_object *obj)
    70 {
    71   const std::vector<sc_object*> &children = obj->get_child_objects();
    72   for (unsigned i = 0; i < children.size(); i++)
    73     if (children[i])
    74       dump_hierarchy (o,children[i]);
    75   o << obj->name () << " " << obj->kind() << endl;
     52
     53void dump_hierarchy(ostream & o, sc_object * obj) {
     54    const vector<sc_object *> & children = obj->get_child_objects();
     55    for (unsigned i = 0; i < children.size(); i++) {
     56        if (children[i]) {
     57            dump_hierarchy(o, children[i]);
     58        }
     59    }
     60    o << obj->name() << " " << obj->kind() << endl;
    7661}
    7762
    78 void
    79 dump_hierarchy (ostream &o, const std::vector<sc_object*> &obj_list)
    80 {
    81   for (unsigned i = 0; i < obj_list.size(); i++)
    82     dump_hierarchy(o, obj_list[i]);
     63
     64void dump_hierarchy (ostream & o, const vector<sc_object *> & obj_list) {
     65    for (unsigned i = 0; i < obj_list.size(); i++) {
     66        dump_hierarchy(o, obj_list[i]);
     67    }
    8368}
    8469
    85 int
    86 sc_main (int argc, char ** argv)
    87 {
    88   if (argc < 2)
    89   {
    90     cerr << "Usage : " << argv[0] << " <filename>\n";
    91     exit (-1);
    92   }
    9370
    94   sc_clock   clk("clock");
    95   top_level1 top1("top1");
    96   top_level2 top2("top2");
    97  
    98   ofstream o;
    99   o.open (argv[1],ios::out | ios::trunc);
    100   if (o.is_open () == false)
    101   {
    102     cerr << "Unable to open '" << argv[1] << "'.\n";
    103     return 1;
    104   }
     71int sc_main (int argc, char ** argv) {
     72    if (argc < 2) {
     73        cerr << "Usage : " << argv[0] << " <filename>\n";
     74        exit(-1);
     75    }
    10576
    106   sc_start(0);
    107   dump_hierarchy (o,sc_get_top_level_objects());
    108  
    109   ASSERT(sc_find_object("top2.b1"    ) == &top2.b1    );
    110   ASSERT(sc_find_object("top2.b1.d1" ) == &top2.b1.d1 );
    111   ASSERT(sc_find_object("top2.b1.d2" ) == &top2.b1.d2 );
    112   ASSERT(sc_find_object("top2.b1.c"  ) == &top2.b1.c  );
    113   ASSERT(sc_find_object("top2.b2"    ) == &top2.b2    );
    114   ASSERT(sc_find_object("top2.c"     ) == &top2.c     );
    115   ASSERT(sc_find_object("top1.a"     ) == &top1.a     );
    116   ASSERT(sc_find_object("top1.d"     ) == &top1.d     );
    117   ASSERT(sc_find_object("top1.a.b"   ) == &top1.a.b   );
    118   ASSERT(sc_find_object("top1.a.b.d1") == &top1.a.b.d1);
    119   ASSERT(sc_find_object("top1.a.b.d2") == &top1.a.b.d2);
    120   ASSERT(sc_find_object("top1.a.b.c" ) == &top1.a.b.c );
    121   ASSERT(sc_find_object("top1.a.c"   ) == &top1.a.c   ); 
    122   ASSERT(sc_find_object("top1.c"     ) == NULL        );
    123   ASSERT(sc_find_object("top1"       )->get_parent_object() == NULL);
    124   ASSERT(sc_find_object("top1.a"     )->get_parent_object() == &top1);
    125   ASSERT(sc_find_object("top1.a.b"   )->get_parent_object() == &top1.a);
    126   ASSERT(sc_find_object("top1.a.b.d2")->get_parent_object() == &top1.a.b);
    127   ASSERT(sc_find_object("top1.d"     )->get_parent_object() == &top1);
    128   ASSERT(sc_find_object("top2.b1"    )->get_parent_object() == &top2);
    129   ASSERT(sc_find_object("top2.b2"    )->get_parent_object() == &top2);
    130   ASSERT(sc_find_object("top2.c"     )->get_parent_object() == &top2);
    131   ASSERT(sc_find_object("top2.b1.c"  )->get_parent_object() == &top2.b1);
    132 #if 0
    133   o << sc_find_object("top2.b1.d1")->name() << endl;
    134   o << sc_find_object("top2.b1.d2")->name() << endl;
    135   o << sc_find_object("top2.b1.c")->name() << endl;
    136   o << sc_find_object("top2.b2")->name() << endl;
    137   o << sc_find_object("top2.c")->name() << endl;
    138   o << sc_find_object("top1.a")->name() << endl;
    139   o << sc_find_object("top1.d")->name() << endl;
    140   o << sc_find_object("top1.a.b")->name() << endl;
    141   o << sc_find_object("top1.a.b.d1")->name() << endl;
    142   o << sc_find_object("top1.a.b.d2")->name() << endl;
    143   o << sc_find_object("top1.a.b.c")->name() << endl;
    144   o << sc_find_object("top1.a.c")->name() << endl;
    145   if (sc_find_object("top1.c") == NULL)
    146     o << "top1.c not found.\n";
    147   else
    148     o << "top1.c found.\n";
    149   o << sc_find_object("top2.b1.c")->get_parent_object()->name () << endl;
    150   o << sc_find_object("top1.a")->get_parent_object()->name () << endl;
    151   if (top1.get_parent_object() == NULL)
    152     o << "top1 has no parent.\n";
    153   else
    154     o << "top1 has a parent.\n";
    155 #endif
     77    sc_clock clk("clock");
     78    top_level1 top1("top1");
     79    top_level2 top2("top2");
    15680
    157   o.close ();
     81    ofstream o;
     82    o.open(argv[1],ios::out | ios::trunc);
     83    if (!o.is_open()) {
     84        cerr << "Unable to open '" << argv[1] << "'.\n";
     85        return 1;
     86    }
    15887
    159   return 0;
     88    sc_start(sc_time(0, sc_core::SC_NS));
     89    dump_hierarchy(o, sc_get_top_level_objects());
     90
     91    ASSERT(sc_find_object("top2.b1"    ) == &top2.b1    );
     92    ASSERT(sc_find_object("top2.b1.d1" ) == &top2.b1.d1 );
     93    ASSERT(sc_find_object("top2.b1.d2" ) == &top2.b1.d2 );
     94    ASSERT(sc_find_object("top2.b1.c"  ) == &top2.b1.c  );
     95    ASSERT(sc_find_object("top2.b2"    ) == &top2.b2    );
     96    ASSERT(sc_find_object("top2.c"     ) == &top2.c     );
     97    ASSERT(sc_find_object("top1.a"     ) == &top1.a     );
     98    ASSERT(sc_find_object("top1.d"     ) == &top1.d     );
     99    ASSERT(sc_find_object("top1.a.b"   ) == &top1.a.b   );
     100    ASSERT(sc_find_object("top1.a.b.d1") == &top1.a.b.d1);
     101    ASSERT(sc_find_object("top1.a.b.d2") == &top1.a.b.d2);
     102    ASSERT(sc_find_object("top1.a.b.c" ) == &top1.a.b.c );
     103    ASSERT(sc_find_object("top1.a.c"   ) == &top1.a.c   ); 
     104    ASSERT(sc_find_object("top1.c"     ) == NULL        );
     105    ASSERT(sc_find_object("top1"       )->get_parent_object() == NULL);
     106    ASSERT(sc_find_object("top1.a"     )->get_parent_object() == &top1);
     107    ASSERT(sc_find_object("top1.a.b"   )->get_parent_object() == &top1.a);
     108    ASSERT(sc_find_object("top1.a.b.d2")->get_parent_object() == &top1.a.b);
     109    ASSERT(sc_find_object("top1.d"     )->get_parent_object() == &top1);
     110    ASSERT(sc_find_object("top2.b1"    )->get_parent_object() == &top2);
     111    ASSERT(sc_find_object("top2.b2"    )->get_parent_object() == &top2);
     112    ASSERT(sc_find_object("top2.c"     )->get_parent_object() == &top2);
     113    ASSERT(sc_find_object("top2.b1.c"  )->get_parent_object() == &top2.b1);
     114
     115    o.close();
     116
     117    return 0;
    160118}
    161119
     120
     121/*
     122# Local Variables:
     123# tab-width: 4;
     124# c-basic-offset: 4;
     125# c-file-offsets:((innamespace . 0)(inline-open . 0));
     126# indent-tabs-mode: nil;
     127# End:
     128#
     129# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     130*/
     131
Note: See TracChangeset for help on using the changeset viewer.