[DEV] add test-debug interface

This commit is contained in:
Edouard DUPIN 2015-06-11 21:20:51 +02:00
parent b02a75a7b8
commit 0e45f30afa
3 changed files with 83 additions and 0 deletions

19
tools/lutin_test-debug.py Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/python
import lutin.module as module
import lutin.tools as tools
import lutin.debug as debug
def get_desc():
return "basic debug log for test"
def create(target):
myModule = module.Module(__file__, 'test-debug', 'LIBRARY')
myModule.add_src_file([
'test-debug/debug.cpp'
])
myModule.add_module_depend('etk')
myModule.add_export_path(tools.get_current_path(__file__))
return myModule

View File

@ -0,0 +1,15 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <test-debug/debug.h>
int32_t test::getLogId() {
static int32_t g_val = etk::log::registerInstance("test");
return g_val;
}

49
tools/test-debug/debug.h Normal file
View File

@ -0,0 +1,49 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <etk/types.h>
#ifndef __TEST_DEBUG_H__
#define __TEST_DEBUG_H__
#include <etk/log.h>
namespace test {
int32_t getLogId();
};
#define TEST_BASE(info,data) TK_LOG_BASE(test::getLogId(),info,data)
#define TEST_PRINT(data) TEST_BASE(-1, data)
#define TEST_CRITICAL(data) TEST_BASE(1, data)
#define TEST_ERROR(data) TEST_BASE(2, data)
#define TEST_WARNING(data) TEST_BASE(3, data)
#ifdef DEBUG
#define TEST_INFO(data) TEST_BASE(4, data)
#define TEST_DEBUG(data) TEST_BASE(5, data)
#define TEST_VERBOSE(data) TEST_BASE(6, data)
#define TEST_TODO(data) TEST_BASE(4, "TODO : " << data)
#else
#define TEST_INFO(data) do { } while(false)
#define TEST_DEBUG(data) do { } while(false)
#define TEST_VERBOSE(data) do { } while(false)
#define TEST_TODO(data) do { } while(false)
#endif
#define TEST_HIDDEN(data) do { } while(false)
#define TEST_ASSERT(cond,data) \
do { \
if (!(cond)) { \
TEST_CRITICAL(data); \
assert(!#cond); \
} \
} while (0)
#endif