summaryrefslogtreecommitdiffstats
path: root/src/usr/trace/test
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2012-10-31 16:01:11 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-12-14 10:18:59 -0600
commitda3888270ff596441bf78535c26dee0a7d923145 (patch)
tree019b88ce38e87b8346e0ef659f058556e26dec42 /src/usr/trace/test
parent6d7290eca2b0e753d1b954a56e2c82284dd23eb9 (diff)
downloadtalos-hostboot-da3888270ff596441bf78535c26dee0a7d923145.tar.gz
talos-hostboot-da3888270ff596441bf78535c26dee0a7d923145.zip
Lockless trace implementation
RTC: 35396 Change-Id: I96ea0d95606f04abb4dc2b0470345ca475b53912 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/2520 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/trace/test')
-rw-r--r--src/usr/trace/test/testbuffer.H92
-rw-r--r--src/usr/trace/test/testcomplist.H61
-rw-r--r--src/usr/trace/test/tracetest.H306
3 files changed, 153 insertions, 306 deletions
diff --git a/src/usr/trace/test/testbuffer.H b/src/usr/trace/test/testbuffer.H
new file mode 100644
index 000000000..d63a24ab3
--- /dev/null
+++ b/src/usr/trace/test/testbuffer.H
@@ -0,0 +1,92 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/trace/test/testbuffer.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2012 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include "../buffer.H"
+#include "../bufferpage.H"
+#include "../compdesc.H"
+#include "../entry.H"
+#include "../daemonif.H"
+
+#include <cxxtest/TestSuite.H>
+#include <limits.h>
+#include <sys/task.h>
+#include <sys/time.h>
+#include <kernel/pagemgr.H>
+
+namespace TRACE
+{
+
+class BufferTest : public CxxTest::TestSuite
+{
+ public:
+ void testClaimEntry()
+ {
+ DaemonIf d;
+ Buffer b(&d, 1);
+
+ tid_t child = task_create(testClaimEntryThread, &b);
+ msg_free(d.wait());
+
+ BufferPage* page = b.claimPages();
+ PageManager::freePage(page);
+
+ task_wait_tid(child, NULL, NULL);
+
+ page = b.claimPages();
+ if (NULL == page)
+ {
+ TS_FAIL("Not enough pages created in trace buffer.\n");
+ }
+ PageManager::freePage(page);
+
+ page = b.claimPages();
+ if (NULL != page)
+ {
+ TS_FAIL("Too many pages created in trace buffer.\n");
+ }
+
+ }
+
+ static void* testClaimEntryThread(void* _buffer)
+ {
+ Buffer* b = reinterpret_cast<Buffer*>(_buffer);
+
+ ComponentList l;
+ ComponentDesc* t = l.getDescriptor("TEST", 2048);
+
+ static const size_t ALLOC_SIZE = 128;
+
+ for(size_t i = 0; i < PAGESIZE/ALLOC_SIZE; i++)
+ {
+ Entry* e = b->claimEntry(t, ALLOC_SIZE - sizeof(Entry));
+ if (e->comp != t)
+ {
+ TS_FAIL("Component ID is not updated in entry.");
+ }
+ }
+
+ return NULL;
+
+ }
+};
+
+}
diff --git a/src/usr/trace/test/testcomplist.H b/src/usr/trace/test/testcomplist.H
new file mode 100644
index 000000000..1bee55cc8
--- /dev/null
+++ b/src/usr/trace/test/testcomplist.H
@@ -0,0 +1,61 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/trace/test/testcomplist.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2012 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include "../compdesc.H"
+
+#include <cxxtest/TestSuite.H>
+
+using namespace TRACE;
+
+class ComponentListTest : public CxxTest::TestSuite
+{
+ public:
+ void testGetDescriptor()
+ {
+ ComponentList l;
+
+ ComponentDesc* t = l.getDescriptor("TEST", 2048);
+
+ if (NULL == t)
+ {
+ TS_FAIL("Component descriptor was NULL.");
+ }
+
+ ComponentDesc* t2 = l.getDescriptor("teST", 2048);
+ if (t2 != t)
+ {
+ TS_FAIL("Component descriptor failed case-insensitive test.");
+ }
+
+ ComponentDesc* t3 = l.getDescriptor("TEST2", 0);
+ if (NULL != t3)
+ {
+ TS_FAIL("Component descriptor failed non-existance test.");
+ }
+
+ t3 = l.getDescriptor("TEST2", 2048);
+ if (t3 == t)
+ {
+ TS_FAIL("Component descriptor failed uniqueness test.");
+ }
+ }
+};
diff --git a/src/usr/trace/test/tracetest.H b/src/usr/trace/test/tracetest.H
deleted file mode 100644
index e574f55c5..000000000
--- a/src/usr/trace/test/tracetest.H
+++ /dev/null
@@ -1,306 +0,0 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/usr/trace/test/tracetest.H $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2011
-//
-// p1
-//
-// Object Code Only (OCO) source materials
-// Licensed Internal Code Source Materials
-// IBM HostBoot Licensed Internal Code
-//
-// The source code for this program is not published or other-
-// wise divested of its trade secrets, irrespective of what has
-// been deposited with the U.S. Copyright Office.
-//
-// Origin: 30
-//
-// IBM_PROLOG_END
-#ifndef __TEST_TRACETEST_H
-#define __TEST_TRACETEST_H
-
-/**
- * @file tracetest.H
- *
- * @brief All unit tests for the trace module in host boot.
-*/
-
-#include <cxxtest/TestSuite.H>
-//#include <trace/interface.H>
-#include <tracinterface.H>
-#include <stdio.h>
-
-class TraceTest : public CxxTest::TestSuite
-{
-public:
-
- /**
- * @test Test Component Trace Interfaces
- */
- void testTracComp(void)
- {
- trace_desc_t *g_trac_test = NULL;
- TRAC_INIT_BUFFER(&g_trac_test, "EXAMPLE", 4096);
-
- if(g_trac_test == NULL)
- {
- TS_FAIL("g_trac_test was returned as NULL!");
- }
- else
- {
- // Component trace tests - There is no easy way to validate these
- // are working but we can at least ensure we don't cause host boot
- // to crash when running them.
-
- for(uint32_t i=0;i<100;i++)
- {
- TRACFCOMP(g_trac_test, "Thread ID: %d", task_gettid());
- TRACFCOMP(g_trac_test, "Validate all number types (c,u,X,d): %c %u 0x%X %d",
- 'a',i,i+1,i+2);
-
- TRACFCOMP(g_trac_test, "Validate pointer type (p): %p",
- g_trac_test);
-
- TRACFCOMP(g_trac_test, "64 Bit Value Test - 0x123456789ABCDEF0: 0x%X",
- 0x123456789ABCDEF0);
-
- // Do a debug trace
- TRACDCOMP(g_trac_test,"This is a debug trace");
-
- // Do an strace
- TRACSCOMP(g_trac_test, "STRACE: Testing all number types (c,u,X,d,s): %c %u 0x%X %d %s",
- 'b',i,i+1,i+2,"Hostboot");
-
- // Test formatting
- TRACFCOMP(g_trac_test, "Test width.precision formatting (u,x,X,d): %8u 0x%.06x 0x%16X %01.01d",
- 0xABCD,0x1234,0x123456789ABCDEF0,0x12345678);
-
- TRACFCOMP(g_trac_test, "Test width.precision.length formatting (u,x,X,d): %8hu 0x%.06lx 0x%16LX %01.01lld",
- 0xABCD,0x1234,0x123456789ABCDEF0,0x12345678);
-
- TRACFCOMP(g_trac_test, "Test width.precision.length formatting (u,x,X,i): %8hu 0x%.06lx 0x%16LX %01.01lli",
- 0xABCD,0x1234,0x123456789ABCDEF0,0x12345678AB);
- }
-
- // Be sure a NULL trace descriptor does not cause a failure
- TRACFCOMP(NULL,"This trace should never show up");
-
- }
- }
-
- /**
- * @test Test Binary Trace Interface
- */
- void testTracBinary(void)
- {
- trace_desc_t *g_trac_test = NULL;
- TRAC_INIT_BUFFER(&g_trac_test, "EXAMPLEBIN", 4096);
-
- if(g_trac_test == NULL)
- {
- TS_FAIL("g_trac_test was returned as NULL!");
- }
- else
- {
- // Binary trace tests - There is no easy way to validate these
- // are working but we can at least ensure we don't cause host boot
- // to crash when running them.
- TRACFBIN(g_trac_test,"Binary dump of trace descriptor",
- g_trac_test,sizeof(trace_desc_t));
-
- TRACDBIN(g_trac_test,"Unaligned Debug binary trace of the trace descriptor",
- g_trac_test,9);
-
- // Be sure a NULL trace descriptor does not cause a failure
- TRACFBIN(NULL,"This trace should never show up",
- g_trac_test,sizeof(trace_desc_t));
-
- // Be sure it handles a size of 0
- TRACFBIN(NULL,"This trace should never show up - 0 size",
- g_trac_test,0);
- }
- }
-
- /**
- * @test Test a mix of traces
- */
- void testTracMix(void)
- {
- trace_desc_t *g_trac_test = NULL;
- TRAC_INIT_BUFFER(&g_trac_test, "EXAMPLEMIX", 4096);
-
- if(g_trac_test == NULL)
- {
- TS_FAIL("g_trac_test was returned as NULL!");
- }
- else
- {
- uint32_t l_size = 0;
-
- for(uint32_t i=0;i<100;i++)
- {
-
- TRACFCOMP(g_trac_test, INFO_MRK"Validate all number types (c,u,X,d): %c %u 0x%X %d",
- 'a',i,i+1,i+2);
-
- l_size = i % sizeof(trace_desc_t);
-
- TRACFBIN(g_trac_test,"Unaligned Binary dump of trace descriptor",
- g_trac_test,l_size);
-
- TRACFCOMP(g_trac_test, "64 Bit Value Test - 0x123456789ABCDEF0: 0x%X",
- 0x123456789ABCDEF0);
-
- }
- }
- }
-
- /**
- * @test Test max component name size
- */
- void testTracCompName(void)
- {
- trace_desc_t *g_trac_test = NULL;
- char l_comp[] = "EXAMPLE89ABCDEFGHI";
-
- TRAC_INIT_BUFFER(&g_trac_test, l_comp, 4096);
-
- if(g_trac_test == NULL)
- {
- TS_FAIL("g_trac_test was returned as NULL!");
- }
- else
- {
- TRACFCOMP(g_trac_test, INFO_MRK"Testing max component name");
- }
- }
-
- /**
- * @test Test trace macros
- */
- void testTracMacros(void)
- {
- trace_desc_t *g_trac_test = NULL;
- char l_comp[] = "TEST";
-
- #define __COMP_TD__ g_trac_test
- #define __COMP_NAMESPACE__ "TRACE"
- #define __COMP_CLASS__ "TraceTest"
- #define __COMP_FN__ "testTracMacros"
-
- TRAC_INIT_BUFFER(&g_trac_test, l_comp, 4096);
-
- if(g_trac_test == NULL)
- {
- TS_FAIL("g_trac_test was returned as NULL!");
- }
- else
- {
- TRAC_ENTER("testTracMacros");
- TRAC_ENTER_();
- TRAC_INF("Testing Info Mark");
- TRAC_ERR("Testing Error Mark");
- TRAC_EXIT("testTracMacros");
- TRAC_EXIT_();
-
- DTRAC_ENTER("testTracMacros - Debug Trace");
- DTRAC_ENTER_(" - Debug Trace");
- DTRAC_INF("Testing Debug Info Mark");
- DTRAC_ERR("Testing Debug Error Mark");
- DTRAC_EXIT("testTracMacros - Debug Trace");
- DTRAC_EXIT_(" - Debug Trace");
-
- STRAC_ENTER("testTracMacros - Strace");
- STRAC_ENTER_(" - Strace");
- STRAC_INF("Testing Strace Info Mark");
- STRAC_ERR("Testing Strace Error Mark");
- STRAC_EXIT("testTracMacros - Strace");
- STRAC_EXIT_(" - Strace");
-
- }
-
- #undef __COMP_FN__
- #undef __COMP_CLASS__
- #undef __COMP_NAMESPACE__
- #undef __COMP_TD__
- }
-
- /**
- * @test Test String Trace Interface
- */
- void testTracString(void)
- {
- trace_desc_t *g_trac_test = NULL;
- TRAC_INIT_BUFFER(&g_trac_test, "STRING", 4096);
-
- if(g_trac_test == NULL)
- {
- TS_FAIL("g_trac_test was returned as NULL!");
- }
- else
- {
- TRACFCOMP(g_trac_test,"String at end '%s'", "Last");
- TRACFCOMP(g_trac_test,"%s: String at beginning", "FIRST");
- TRACFCOMP(g_trac_test,"Test '%s' string", "middle");
-
- const char * str = "This is a \tlong string\nwith horizontal tab and newline.";
- TRACFCOMP(g_trac_test,"Testing (c,u,s,X): %c, %u, %s 0x%X", 'b',0x11,str,10);
-
- TRACFCOMP(g_trac_test,"Testing string len 1: %s, %s, %s", "A", "B", "C");
- TRACFCOMP(g_trac_test,"Testing NULL string: %s", "");
-
- TRACFCOMP(g_trac_test,"Testing string alignment: %s %s", "hello", "world");
- TRACFCOMP(g_trac_test,"Testing string alignment: %s %s", "Hostboot", "Software");
- TRACFCOMP(g_trac_test,"Testing string alignment: %s %s", "Hostboot2", "Software3");
-
- TRACFCOMP(g_trac_test,"%s %s %s %s", "Four", "strings", "by", "themselves");
-
- TRACFCOMP(g_trac_test,"Testing special characters: %s",
- "?!@#$%^&*()\"/\'\\<>.,:;");
-
- TRACFCOMP(g_trac_test,"Testing percent: %% %%%d %%%s 100%%", 50, "hello");
-
- TRACFCOMP(g_trac_test, INFO_MRK"Testing all number types (s,c,u,X,d): %s, %c %u 0x%X %d",
- "hello",'a',10,11,12);
- TRACFCOMP(g_trac_test, "Testing all number types (c,u,s,X,d): %c %u %s 0x%X %d",
- 'b',13,"world!",14,15);
- TRACFCOMP(g_trac_test, "Testing all number types (c,u,X,d,s): %c %u 0x%X %d %s",
- 'c',16,17,18,"Hostboot");
- TRACFCOMP(g_trac_test, "Testing all number types (s,c,s,u,s,X): %s %c %s %u %s 0x%X",
- "Astring",'d',"Bstring12",19,"Cstring123",20);
- }
- }
-
- /**
- * @test Test max number of buffers
- */
- void testTracMaxBuffers(void)
- {
- trace_desc_t *g_trac_test = NULL;
- char l_comp[8] = "TRACE";
-
- for (uint32_t i=0; i < 26; i++)
- {
- sprintf (l_comp, "TRACE%d", i);
-
- g_trac_test = NULL;
- TRAC_INIT_BUFFER(&g_trac_test, l_comp, 4096);
-
- if(g_trac_test == NULL)
- {
- TS_FAIL("g_trac_test was returned as NULL!");
- }
- else
- {
- TRACFCOMP(g_trac_test, INFO_MRK"Testing max buffers %u", i);
- }
- }
- }
-};
-
-#endif
-
OpenPOWER on IntegriCloud