summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-07 14:36:22 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-14 08:46:49 +0100
commit53ad908a646eb6fd67f9b4586f4b484e8255b9d3 (patch)
tree7dd408879d01a507e6052f375ec6e14ab3f8965d /testsuites/sptests
parentscore: Add per-CPU profiling (diff)
downloadrtems-53ad908a646eb6fd67f9b4586f4b484e8255b9d3.tar.bz2
score: Add SMP lock profiling support
Diffstat (limited to 'testsuites/sptests')
-rw-r--r--testsuites/sptests/sp37/init.c8
-rw-r--r--testsuites/sptests/spcache01/init.c4
-rw-r--r--testsuites/sptests/spnsext01/init.c2
-rw-r--r--testsuites/sptests/spprofiling01/init.c92
4 files changed, 97 insertions, 9 deletions
diff --git a/testsuites/sptests/sp37/init.c b/testsuites/sptests/sp37/init.c
index 4a3e08c862..1097dc8fab 100644
--- a/testsuites/sptests/sp37/init.c
+++ b/testsuites/sptests/sp37/init.c
@@ -160,11 +160,11 @@ static void test_isr_level( void )
static void test_isr_locks( void )
{
ISR_Level normal_interrupt_level = _ISR_Get_level();
- ISR_lock_Control initialized = ISR_LOCK_INITIALIZER;
+ ISR_lock_Control initialized = ISR_LOCK_INITIALIZER("test");
ISR_lock_Control lock;
ISR_lock_Context lock_context;
- _ISR_lock_Initialize( &lock );
+ _ISR_lock_Initialize( &lock, "test" );
rtems_test_assert( memcmp( &lock, &initialized, sizeof( lock ) ) == 0 );
_ISR_lock_ISR_disable_and_acquire( &lock, &lock_context );
@@ -197,11 +197,11 @@ static rtems_mode get_interrupt_level( void )
static void test_interrupt_locks( void )
{
rtems_mode normal_interrupt_level = get_interrupt_level();
- rtems_interrupt_lock initialized = RTEMS_INTERRUPT_LOCK_INITIALIZER;
+ rtems_interrupt_lock initialized = RTEMS_INTERRUPT_LOCK_INITIALIZER("test");
rtems_interrupt_lock lock;
rtems_interrupt_lock_context lock_context;
- rtems_interrupt_lock_initialize( &lock );
+ rtems_interrupt_lock_initialize( &lock, "test" );
rtems_test_assert( memcmp( &lock, &initialized, sizeof( lock ) ) == 0 );
rtems_interrupt_lock_acquire( &lock, &lock_context );
diff --git a/testsuites/sptests/spcache01/init.c b/testsuites/sptests/spcache01/init.c
index 4c0c3c3f61..92ea4ec599 100644
--- a/testsuites/sptests/spcache01/init.c
+++ b/testsuites/sptests/spcache01/init.c
@@ -48,7 +48,7 @@ static void test_data_flush_and_invalidate(void)
printf("data cache flush and invalidate test\n");
- rtems_interrupt_lock_initialize(&lock);
+ rtems_interrupt_lock_initialize(&lock, "test");
rtems_interrupt_lock_acquire(&lock, &lock_context);
for (i = 0; i < n; ++i) {
@@ -168,7 +168,7 @@ static void test_timing(void)
uint32_t cache_level;
size_t cache_size;
- rtems_interrupt_lock_initialize(&lock);
+ rtems_interrupt_lock_initialize(&lock, "test");
printf(
"data cache line size %zi bytes\n"
diff --git a/testsuites/sptests/spnsext01/init.c b/testsuites/sptests/spnsext01/init.c
index b445679fb9..2ffd237ce6 100644
--- a/testsuites/sptests/spnsext01/init.c
+++ b/testsuites/sptests/spnsext01/init.c
@@ -51,7 +51,7 @@ static rtems_task Init(rtems_task_argument argument)
n = (3 * n) / 2;
- rtems_interrupt_lock_initialize(&lock);
+ rtems_interrupt_lock_initialize(&lock, "test");
rtems_interrupt_lock_acquire(&lock, &lock_context);
sc = rtems_clock_get_uptime(&uptime);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
diff --git a/testsuites/sptests/spprofiling01/init.c b/testsuites/sptests/spprofiling01/init.c
index a1af66bba2..a1f6cd7f3c 100644
--- a/testsuites/sptests/spprofiling01/init.c
+++ b/testsuites/sptests/spprofiling01/init.c
@@ -21,10 +21,97 @@
#include <rtems.h>
#include <stdio.h>
+#include <string.h>
#include "tmacros.h"
-static void test(void)
+typedef struct {
+ rtems_interrupt_lock a;
+ rtems_interrupt_lock b;
+ rtems_interrupt_lock c;
+ rtems_interrupt_lock d;
+ enum {
+ WAIT_FOR_A,
+ EXPECT_B,
+ EXPECT_D,
+ DONE
+ } state;
+} visitor_context;
+
+static bool is_equal(const rtems_profiling_smp_lock *psl, const char *name)
+{
+ return strcmp(psl->name, name) == 0;
+}
+
+static void visitor(void *arg, const rtems_profiling_data *data)
+{
+ visitor_context *ctx = arg;
+
+ if (data->header.type == RTEMS_PROFILING_SMP_LOCK) {
+ const rtems_profiling_smp_lock *psl = &data->smp_lock;
+
+ switch (ctx->state) {
+ case WAIT_FOR_A:
+ rtems_test_assert(!is_equal(psl, "b"));
+ rtems_test_assert(!is_equal(psl, "c"));
+ rtems_test_assert(!is_equal(psl, "d"));
+
+ if (is_equal(psl, "a")) {
+ ctx->state = EXPECT_B;
+ }
+ break;
+ case EXPECT_B:
+ rtems_test_assert(is_equal(psl, "b"));
+ rtems_interrupt_lock_destroy(&ctx->c);
+ ctx->state = EXPECT_D;
+ break;
+ case EXPECT_D:
+ rtems_test_assert(is_equal(psl, "d"));
+ ctx->state = DONE;
+ break;
+ case DONE:
+ rtems_test_assert(!is_equal(psl, "a"));
+ rtems_test_assert(!is_equal(psl, "b"));
+ rtems_test_assert(!is_equal(psl, "c"));
+ rtems_test_assert(!is_equal(psl, "d"));
+ break;
+ }
+ }
+}
+
+static void lock_init(rtems_interrupt_lock *lock, const char *name)
+{
+ rtems_interrupt_lock_context lock_context;
+
+ rtems_interrupt_lock_initialize(lock, name);
+ rtems_interrupt_lock_acquire(lock, &lock_context);
+ rtems_interrupt_lock_release(lock, &lock_context);
+}
+
+static void test_iterate(void)
+{
+ visitor_context ctx_instance;
+ visitor_context *ctx = &ctx_instance;
+
+ ctx->state = WAIT_FOR_A;
+ lock_init(&ctx->a, "a");
+ lock_init(&ctx->b, "b");
+ lock_init(&ctx->c, "c");
+ lock_init(&ctx->d, "d");
+
+ rtems_profiling_iterate(visitor, ctx);
+
+ rtems_interrupt_lock_destroy(&ctx->a);
+ rtems_interrupt_lock_destroy(&ctx->b);
+
+ if (ctx->state != DONE) {
+ rtems_interrupt_lock_destroy(&ctx->c);
+ }
+
+ rtems_interrupt_lock_destroy(&ctx->d);
+}
+
+static void test_report_xml(void)
{
rtems_status_code sc;
int rv;
@@ -40,7 +127,8 @@ static void Init(rtems_task_argument arg)
{
puts("\n\n*** TEST SPPROFILING 1 ***");
- test();
+ test_iterate();
+ test_report_xml();
puts("*** END OF TEST SPPROFILING 1 ***");