Commit c3872ad0 by Marcus Winter

Merge branch 'development' into embb485_dataflow_dynamic_tokencount

parents 4dadd0cd 87cee4dd
......@@ -241,7 +241,7 @@ int embb_thread_create(embb_thread_t* thread, const embb_core_set_t* core_set,
status = pthread_attr_setaffinity_np(&attr, sizeof(cpuset), &cpuset);
if (status != 0) {
thread->embb_internal_arg = NULL;
thread->embb_internal_handle = NULL;
thread->embb_internal_handle = 0;
return EMBB_ERROR;
}
#else
......@@ -254,7 +254,7 @@ int embb_thread_create(embb_thread_t* thread, const embb_core_set_t* core_set,
thread->embb_internal_arg = (embb_internal_thread_arg_t*)
embb_alloc(sizeof(embb_internal_thread_arg_t));
if (thread->embb_internal_arg == NULL) {
thread->embb_internal_handle = NULL;
thread->embb_internal_handle = 0;
pthread_attr_destroy(&attr);
return EMBB_NOMEM;
}
......
......@@ -28,7 +28,7 @@
#include <embb/base/c/internal/unused.h>
#include <embb/base/log.h>
#include <cstring>
#include <string>
namespace embb {
namespace base {
......@@ -38,7 +38,7 @@ LogTest::LogTest() {
CreateUnit("Test all").Add(&LogTest::Test, this);
}
static char const * logged_message;
static std::string logged_message;
static void test_log_function(void * context, char const * msg) {
EMBB_UNUSED(context);
......@@ -48,101 +48,90 @@ static void test_log_function(void * context, char const * msg) {
void LogTest::Test() {
using embb::base::Log;
char const * test_msg = "hello";
char const * null = 0;
Log::SetLogFunction(0, test_log_function);
Log::SetLogLevel(EMBB_LOG_LEVEL_TRACE);
logged_message = null;
logged_message = "none";
Log::Trace("chn", test_msg);
#ifdef EMBB_DEBUG
PT_ASSERT_NE(logged_message, null);
PT_EXPECT(0 == strcmp(logged_message, "[chn] - [TRACE] hello"));
PT_EXPECT(logged_message == "[chn] - [TRACE] hello");
#else
PT_EXPECT_EQ(null, logged_message);
PT_EXPECT(logged_message == "none");
#endif
logged_message = null;
logged_message = "none";
Log::Info("chn", test_msg);
#ifdef EMBB_DEBUG
PT_ASSERT_NE(logged_message, null);
PT_EXPECT(0 == strcmp(logged_message, "[chn] - [INFO ] hello"));
PT_EXPECT(logged_message == "[chn] - [INFO ] hello");
#else
PT_EXPECT_EQ(null, logged_message);
PT_EXPECT(logged_message == "none");
#endif
logged_message = null;
logged_message = "none";
Log::Warning("chn", test_msg);
PT_ASSERT_NE(logged_message, null);
PT_EXPECT(0 == strcmp(logged_message, "[chn] - [WARN ] hello"));
logged_message = null;
PT_EXPECT(logged_message == "[chn] - [WARN ] hello");
logged_message = "none";
Log::Error("chn", test_msg);
PT_ASSERT_NE(logged_message, null);
PT_EXPECT(0 == strcmp(logged_message, "[chn] - [ERROR] hello"));
PT_EXPECT(logged_message == "[chn] - [ERROR] hello");
Log::SetLogLevel(EMBB_LOG_LEVEL_INFO);
logged_message = null;
logged_message = "none";
Log::Trace("chn", test_msg);
PT_EXPECT_EQ(null, logged_message);
logged_message = null;
PT_EXPECT(logged_message == "none");
logged_message = "none";
Log::Info("chn", test_msg);
#ifdef EMBB_DEBUG
PT_ASSERT_NE(logged_message, null);
PT_EXPECT(0 == strcmp(logged_message, "[chn] - [INFO ] hello"));
PT_EXPECT(logged_message == "[chn] - [INFO ] hello");
#else
PT_EXPECT_EQ(null, logged_message);
PT_EXPECT(logged_message == "none");
#endif
logged_message = null;
logged_message = "none";
Log::Warning("chn", test_msg);
PT_ASSERT_NE(logged_message, null);
PT_EXPECT(0 == strcmp(logged_message, "[chn] - [WARN ] hello"));
logged_message = null;
PT_EXPECT(logged_message == "[chn] - [WARN ] hello");
logged_message = "none";
Log::Error("chn", test_msg);
PT_ASSERT_NE(logged_message, null);
PT_EXPECT(0 == strcmp(logged_message, "[chn] - [ERROR] hello"));
PT_EXPECT(logged_message == "[chn] - [ERROR] hello");
Log::SetLogLevel(EMBB_LOG_LEVEL_WARNING);
logged_message = null;
logged_message = "none";
Log::Trace("chn", test_msg);
PT_EXPECT_EQ(null, logged_message);
logged_message = null;
PT_EXPECT(logged_message == "none");
logged_message = "none";
Log::Info("chn", test_msg);
PT_EXPECT_EQ(null, logged_message);
logged_message = null;
PT_EXPECT(logged_message == "none");
logged_message = "none";
Log::Warning("chn", test_msg);
PT_ASSERT_NE(logged_message, null);
PT_EXPECT(0 == strcmp(logged_message, "[chn] - [WARN ] hello"));
logged_message = null;
PT_EXPECT(logged_message == "[chn] - [WARN ] hello");
logged_message = "none";
Log::Error("chn", test_msg);
PT_ASSERT_NE(logged_message, null);
PT_EXPECT(0 == strcmp(logged_message, "[chn] - [ERROR] hello"));
PT_EXPECT(logged_message == "[chn] - [ERROR] hello");
Log::SetLogLevel(EMBB_LOG_LEVEL_ERROR);
logged_message = null;
logged_message = "none";
Log::Trace("chn", test_msg);
PT_EXPECT_EQ(null, logged_message);
logged_message = null;
PT_EXPECT(logged_message == "none");
logged_message = "none";
Log::Info("chn", test_msg);
PT_EXPECT_EQ(null, logged_message);
logged_message = null;
PT_EXPECT(logged_message == "none");
logged_message = "none";
Log::Warning("chn", test_msg);
PT_EXPECT_EQ(null, logged_message);
logged_message = null;
PT_EXPECT(logged_message == "none");
logged_message = "none";
Log::Error("chn", test_msg);
PT_ASSERT_NE(logged_message, null);
PT_EXPECT(0 == strcmp(logged_message, "[chn] - [ERROR] hello"));
PT_EXPECT(logged_message == "[chn] - [ERROR] hello");
Log::SetLogLevel(EMBB_LOG_LEVEL_NONE);
logged_message = null;
logged_message = "none";
Log::Trace("chn", test_msg);
PT_EXPECT_EQ(null, logged_message);
logged_message = null;
PT_EXPECT(logged_message == "none");
logged_message = "none";
Log::Info("chn", test_msg);
PT_EXPECT_EQ(null, logged_message);
logged_message = null;
PT_EXPECT(logged_message == "none");
logged_message = "none";
Log::Warning("chn", test_msg);
PT_EXPECT_EQ(null, logged_message);
logged_message = null;
PT_EXPECT(logged_message == "none");
logged_message = "none";
Log::Error("chn", test_msg);
PT_EXPECT_EQ(null, logged_message);
PT_EXPECT(logged_message == "none");
}
} // namespace test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment