[rtems commit] cdtest: Print proper begin/end of test messages

Sebastian Huber sebh at rtems.org
Fri Dec 9 07:27:07 UTC 2016


Module:    rtems
Branch:    master
Commit:    05006c9017523eaa18ddc2a617c1a6fe2b792b6c
Changeset: http://git.rtems.org/rtems/commit/?id=05006c9017523eaa18ddc2a617c1a6fe2b792b6c

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Dec  9 08:25:47 2016 +0100

cdtest: Print proper begin/end of test messages

---

 testsuites/samples/cdtest/cdtest.scn | 64 +++++++++++++++++++++---------------
 testsuites/samples/cdtest/main.cc    | 20 +++++++++--
 2 files changed, 56 insertions(+), 28 deletions(-)

diff --git a/testsuites/samples/cdtest/cdtest.scn b/testsuites/samples/cdtest/cdtest.scn
index a832a72..7307d7c 100644
--- a/testsuites/samples/cdtest/cdtest.scn
+++ b/testsuites/samples/cdtest/cdtest.scn
@@ -1,31 +1,43 @@
-Hey I'm in base class constructor number 1 for 0x400010cc.
-Hey I'm in base class constructor number 2 for 0x400010d4.
-Hey I'm in derived class constructor number 3 for 0x400010d4.
+*** BEGIN OF TEST CONSTRUCTOR/DESTRUCTOR ***
+GLOBAL: Hey I'm in base class constructor number 1 for 0x2052154.
+GLOBAL: Hey I'm in base class constructor number 2 for 0x2052148.
+GLOBAL: Hey I'm in derived class constructor number 3 for 0x2052148.
 
 
-*** CONSTRUCTOR/DESTRUCTOR TEST ***
-Hey I'm in base class constructor number 4 for 0x4009ee08.
-Hey I'm in base class constructor number 5 for 0x4009ee10.
-Hey I'm in base class constructor number 6 for 0x4009ee18.
-Hey I'm in base class constructor number 7 for 0x4009ee20.
-Hey I'm in derived class constructor number 8 for 0x4009ee20.
-Testing a C++ I/O stream
-Hey I'm in derived class destructor number 8 for 0x4009ee20.
+*** BEGIN OF TEST CONSTRUCTOR/DESTRUCTOR ***
+LOCAL: Hey I'm in base class constructor number 4 for 0x2057978.
+LOCAL: Hey I'm in base class constructor number 5 for 0x2057984.
+LOCAL: Hey I'm in base class constructor number 6 for 0x2057990.
+LOCAL: Hey I'm in base class constructor number 7 for 0x205799c.
+LOCAL: Hey I'm in derived class constructor number 8 for 0x205799c.
+IO Stream not tested
+LOCAL: Hey I'm in derived class destructor number 8 for 205799C.
 Derived class - Instantiation order 8
-Hey I'm in base class destructor number 7 for 0x4009ee20.
-Instantiation order 8
-Hey I'm in base class destructor number 6 for 0x4009ee18.
-Instantiation order 6
-Hey I'm in base class destructor number 5 for 0x4009ee10.
-Instantiation order 5
-Hey I'm in base class destructor number 4 for 0x4009ee08.
-Instantiation order 5
-*** END OF CONSTRUCTOR/DESTRUCTOR TEST ***
-
+LOCAL: Hey I'm in base class destructor number 7 for 205799C.
+Derived class - Instantiation order 8
+LOCAL: Hey I'm in base class destructor number 6 for 2057990.
+Derived class - Instantiation order 6
+LOCAL: Hey I'm in base class destructor number 5 for 2057984.
+Derived class - Instantiation order 5
+LOCAL: Hey I'm in base class destructor number 4 for 2057978.
+Derived class - Instantiation order 5
+*** TESTING C++ EXCEPTIONS ***
 
-Hey I'm in derived class destructor number 3 for 0x400010d4.
+foo_function() catch block called:
+   < foo_function() throw this exception  >
+Success catching a char * exception
+foo_function() re-throwing execption...
+throw std::runtime: caught: thrown std::runtime object
+throw an instance based exception
+RtemsException raised=File:../../../../../../../rtems/c/src/../../testsuites/samples/cdtest/main.cc, Line:229, Error=55
+Success catching RtemsException...
+RtemsException ---> File:../../../../../../../rtems/c/src/../../testsuites/samples/cdtest/main.cc, Line:229, Error=55
+Exceptions are working properly.
+Global Dtors should be called after this line....
+GLOBAL: Hey I'm in derived class destructor number 3 for 2052148.
+Derived class - Instantiation order 3
+GLOBAL: Hey I'm in base class destructor number 2 for 2052148.
 Derived class - Instantiation order 3
-Hey I'm in base class destructor number 2 for 0x400010d4.
-Instantiation order 3
-Hey I'm in base class destructor number 1 for 0x400010cc.
-Instantiation order 1
+GLOBAL: Hey I'm in base class destructor number 1 for 2052154.
+Derived class - Instantiation order 1
+*** END OF TEST CONSTRUCTOR/DESTRUCTOR ***
diff --git a/testsuites/samples/cdtest/main.cc b/testsuites/samples/cdtest/main.cc
index fb015fa..43b6b06 100644
--- a/testsuites/samples/cdtest/main.cc
+++ b/testsuites/samples/cdtest/main.cc
@@ -44,10 +44,25 @@ extern rtems_task main_task(rtems_task_argument);
 
 static int num_inst = 0;
 
+static void check_begin_of_test(void)
+{
+  if ( num_inst == 0 ) {
+    printf(TEST_BEGIN_STRING);
+  }
+}
+
+static void check_end_of_test(void)
+{
+  if ( num_inst == 0 ) {
+    printk(TEST_END_STRING);
+  }
+}
+
 class AClass {
 public:
   AClass(const char *p = "LOCAL" ) : ptr( p )
     {
+        check_begin_of_test();
         num_inst++;
         printf(
           "%s: Hey I'm in base class constructor number %d for %p.\n",
@@ -71,6 +86,7 @@ public:
         );
         printk("Derived class - %s\n", string);
         num_inst--;
+        check_end_of_test();
     };
 
     virtual void print()  { printf("%s\n", string); };
@@ -84,6 +100,7 @@ class BClass : public AClass {
 public:
   BClass(const char *p = "LOCAL" ) : AClass( p )
     {
+        check_begin_of_test();
         num_inst++;
         printf(
           "%s: Hey I'm in derived class constructor number %d for %p.\n",
@@ -107,6 +124,7 @@ public:
         );
         printk("Derived class - %s\n", string);
         num_inst--;
+        check_end_of_test();
     };
 
     void print()  { printf("Derived class - %s\n", string); }
@@ -185,8 +203,6 @@ rtems_task main_task(
 
     cdtest();
 
-    TEST_END();
-
     printf( "*** TESTING C++ EXCEPTIONS ***\n\n" );
 
     try




More information about the vc mailing list