Add RUNNER_ERROR_MSG(message) macro 96/28896/7
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Thu, 16 Oct 2014 17:10:49 +0000 (19:10 +0200)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Thu, 30 Oct 2014 10:23:29 +0000 (11:23 +0100)
Macro can be used to print error messages during test runtime.
Sometimes there is a need to print out important information
that are related to error that happen during test run, but it is
impossible to do that with RUNNER_ASSERT... macros because
an exception is alredy thrown.

Change-Id: I574af27bba7c20f21e2c6f9fc0b808f7ed9675ed

README
tests/framework/include/dpl/test/test_runner.h

diff --git a/README b/README
index 7b277c5..9caea47 100644 (file)
--- a/README
+++ b/README
@@ -140,6 +140,14 @@ dpl-test-framework
     RUNNER_PERF_TEST_END
           End time measurement.
 
+--Message macros---------------------------------------------------------------
+Used to print error messages during test run time.
+
+dpl-test-framework
+  test_runner.h
+    RUNNER_ERROR_MSG
+          Print error message using red color.
+
 --Collectors-------------------------------------------------------------------
 Collectors are classes which collect test results. Each class does it differently.
 Collectors can be registered by --output parameter (see HOW TO RUN section) but
index 3f9ff7b..de7abb9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
 
 #include <chrono>
 #include <cstring>
+#include <iostream>
 #include <list>
 #include <map>
 #include <set>
@@ -35,6 +36,7 @@
 
 #include <dpl/atomic.h>
 #include <dpl/availability.h>
+#include <dpl/colors.h>
 #include <dpl/gdbbacktrace.h>
 #include <dpl/singleton.h>
 #include <dpl/test/test_results_collector.h>
@@ -327,5 +329,16 @@ typedef DPL::Singleton<TestRunner> TestRunnerSingleton;
         DPL::Test::TestRunnerSingleton::Instance().endPerformanceTestTime();  \
     } while (0)
 
+/**
+ * MSG MACROS
+ *
+ * Use these macros to print error messages during test run time
+ */
+
+#define RUNNER_ERROR_MSG(message)                             \
+    do {                                                      \
+        std::cerr << DPL::Colors::Text::RED_BEGIN << message  \
+                  << DPL::Colors::Text::RED_END << std::endl; \
+    } while (0)
 
 #endif // DPL_TEST_RUNNER_H