Commit 18cf85a0 authored by Christian Dietrich's avatar Christian Dietrich

app/bcc1/alarm3: make testcases less racy

Somes these testcases produced

  5{<><><>}33x

instead of

  5{<><><>}3x

This is not a application or OS bug, but a race condition with the
waiting times.

Change-Id: I1e847e13188b15d567ce4efd92f473a4f39a666b
parent b5016fc8
......@@ -43,3 +43,9 @@ DOSEK_BINARY(
e.cc
)
set_tests_properties(bcc1_alarm3a PROPERTIES TIMEOUT 30)
set_tests_properties(bcc1_alarm3b PROPERTIES TIMEOUT 30)
set_tests_properties(bcc1_alarm3c PROPERTIES TIMEOUT 30)
set_tests_properties(bcc1_alarm3d PROPERTIES TIMEOUT 30)
set_tests_properties(bcc1_alarm3e PROPERTIES TIMEOUT 30)
#include "os.h"
#include "test/test.h"
#include "alarm3_common.h"
DeclareTask(H1);
DeclareTask(H2);
......@@ -24,13 +25,12 @@ const unsigned long long max_count = 200000000;
#else
const unsigned long long max_count = 1;
#endif
volatile unsigned long long counter = max_count + 1;
char irq_marker = 'x';
volatile bool stop = false;
TASK(H3) {
irq_marker = '3';
counter = max_count + 1;
if (stop == false)
test_trace('3');
stop = true;
TerminateTask();
}
......@@ -42,18 +42,15 @@ TASK(H4) {
TASK(H5) {
test_trace('5');
test_trace('[');
for (counter = 0; counter < max_count; counter++) {}
test_trace(irq_marker);
WAIT_FOR_IRQ();
test_trace(']');
DisableAllInterrupts();
test_trace('{');
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
test_trace('}');
irq_marker = 'y';
EnableAllInterrupts();
for (counter = 0; counter < max_count; counter++) {}
test_trace(irq_marker);
WAIT_FOR_IRQ();
test_trace('x');
TerminateTask();
}
......
#ifndef __ALARM3_COMMON_H__
#define __ALARM3_COMMON_H__
#define WAIT_FOR_IRQ() do{ stop = false; \
for (volatile unsigned long long counter = 0, stop = false; \
stop == false && counter < max_count; \
counter++) {} \
} while(0);
#endif
#include "os.h"
#include "test/test.h"
#include "alarm3_common.h"
DeclareTask(H1);
DeclareTask(H2);
......@@ -19,7 +21,7 @@ TASK(H2) {
TerminateTask();
}
volatile unsigned long long counter = 0;
volatile bool stop;
#ifndef FAIL
const unsigned long long max_count = 200000000;
#else
......@@ -27,8 +29,9 @@ const unsigned long long max_count = 1;
#endif
TASK(H3) {
test_trace('3');
counter = max_count + 1;
if (stop == false)
test_trace('3');
stop = true;
TerminateTask();
}
......@@ -42,19 +45,18 @@ TASK(H5) {
SuspendAllInterrupts();
test_trace('{');
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
SuspendAllInterrupts();
test_trace('<');
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
test_trace('>');
ResumeAllInterrupts();
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
test_trace('}');
ResumeAllInterrupts();
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
test_trace('x');
TerminateTask();
}
......
#include "os.h"
#include "alarm3_common.h"
#include "test/test.h"
DeclareTask(H1);
......@@ -19,7 +20,7 @@ TASK(H2) {
TerminateTask();
}
volatile unsigned long long counter = 0;
volatile bool stop;
#ifndef FAIL
const unsigned long long max_count = 200000000;
......@@ -28,8 +29,9 @@ const unsigned long long max_count = 1;
#endif
TASK(H3) {
test_trace('3');
counter = max_count + 1;
if (stop == false)
test_trace('3');
stop = true;
TerminateTask();
}
......@@ -41,7 +43,7 @@ TASK(H4) {
extern "C" void bar() {
SuspendAllInterrupts();
test_trace('<');
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
test_trace('>');
ResumeAllInterrupts();
}
......@@ -59,7 +61,7 @@ TASK(H5) {
test_trace('}');
ResumeAllInterrupts();
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
test_trace('x');
TerminateTask();
}
......
#include "os.h"
#include "test/test.h"
#include "alarm3_common.h"
DeclareTask(H1);
DeclareTask(H2);
......@@ -19,7 +21,7 @@ TASK(H2) {
TerminateTask();
}
volatile unsigned long long counter = 0;
volatile bool stop;
#ifndef FAIL
const unsigned long long max_count = 200000000;
#else
......@@ -27,8 +29,9 @@ const unsigned long long max_count = 1;
#endif
TASK(H3) {
test_trace('3');
counter = max_count + 1;
if (stop == false)
test_trace('3');
stop = true;
TerminateTask();
}
......@@ -42,19 +45,19 @@ TASK(H5) {
SuspendAllInterrupts();
test_trace('{');
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
SuspendOSInterrupts();
test_trace('<');
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
test_trace('>');
ResumeOSInterrupts();
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
test_trace('}');
ResumeAllInterrupts();
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
test_trace('x');
TerminateTask();
}
......
#include "os.h"
#include "test/test.h"
#include "alarm3_common.h"
DeclareTask(H1);
DeclareTask(H2);
......@@ -19,7 +20,7 @@ TASK(H2) {
TerminateTask();
}
volatile unsigned long long counter = 0;
volatile bool stop;
#ifndef FAIL
const unsigned long long max_count = 200000000;
#else
......@@ -27,8 +28,9 @@ const unsigned long long max_count = 1;
#endif
TASK(H3) {
test_trace('3');
counter = max_count + 1;
if (stop == false)
test_trace('3');
stop = true;
TerminateTask();
}
......@@ -43,8 +45,8 @@ TASK(H5) {
SuspendAllInterrupts();
test_trace('{');
for (counter = 0; counter < max_count; counter++) {}
if (counter == max_count) {
WAIT_FOR_IRQ();
if (stop == false) { // We ran into the timeout
test_trace('+');
ResumeAllInterrupts();
test_trace('}');
......@@ -53,7 +55,7 @@ TASK(H5) {
ResumeAllInterrupts();
test_trace('}');
}
for (counter = 0; counter < max_count; counter++) {}
WAIT_FOR_IRQ();
test_trace('x');
TerminateTask();
}
......
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 to comment