Skip to content

Commit 8a39211

Browse files
author
dave
committed
tests moved to IoAbstraction SimpleTest
1 parent 21bbe4f commit 8a39211

File tree

10 files changed

+134
-129
lines changed

10 files changed

+134
-129
lines changed

tests/taskMgrTests/ESPMultiThreadedTest.cpp

Lines changed: 0 additions & 62 deletions
This file was deleted.

tests/taskMgrTests/HighThroughputTestCases.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
#include <AUnit.h>
2+
#include <testing/SimpleTest.h>
33
#include <TaskManagerIO.h>
44
#include "test_utils.h"
55

6-
using namespace aunit;
6+
using namespace SimpleTest;
77

88
int counts[6];
99

@@ -41,7 +41,7 @@ void testCall5() {
4141
// schedules, this is the most important test to pass in the whole suite.
4242
//
4343

44-
class HighThroughputFixture : public TestOnce {
44+
class HighThroughputFixture : public UnitTestExecutor {
4545
public:
4646
/**
4747
* This method checks that taskmanager tasks are in proper and stable order. And that only running tasks
@@ -103,12 +103,12 @@ testF(HighThroughputFixture, taskManagerHighThroughputTest) {
103103

104104
Serial.print("Dumping threads"); Serial.println(taskManager.checkAvailableSlots(slotData, sizeof slotData));
105105

106-
assertEqual(counts[5], 10); // should be 10 runs as it's manually repeating
107-
assertMore(counts[1], 140); // should be at least 140 runs, scheduled every 100 millis,
108-
assertMore(counts[3], 14); // should be at least 14 runs, as this test lasts about 20 seconds.
109-
assertMore(counts[0], 1400); // should be at least 1400 runs it's scheduled every 10 millis
110-
assertEqual(counts[4], 1); // should have been triggered once
111-
assertNotEqual(counts[2], 0); // meaningless to count micros calls. check it happened
106+
assertEquals(10, counts[5]); // should be 10 runs as it's manually repeating
107+
assertMoreThan(140, counts[1]); // should be at least 140 runs, scheduled every 100 millis,
108+
assertMoreThan(14, counts[3]); // should be at least 14 runs, as this test lasts about 20 seconds.
109+
assertMoreThan(1400, counts[0]); // should be at least 1400 runs it's scheduled every 10 millis
110+
assertEquals(1, counts[4]); // should have been triggered once
111+
assertNotEquals(0, counts[2]); // meaningless to count micros calls. check it happened
112112
}
113113

114114
//
@@ -152,7 +152,7 @@ testF(HighThroughputFixture, testCancellingsTasksWithinAnotherTask) {
152152

153153
// the cancelled job should have run at least once before cancellation
154154
// and then must have been cancelled. Tasks should be in order
155-
assertNotEqual(0, counts[0]);
155+
assertNotEquals(0, counts[0]);
156156
assertTrue(taskCancelled);
157157

158158
count = 500;
@@ -170,7 +170,7 @@ testF(HighThroughputFixture, testCancellingsTasksWithinAnotherTask) {
170170
Serial.print("Dumping threads"); Serial.println(taskManager.checkAvailableSlots(slotData, sizeof slotData));
171171
}
172172

173-
assertNotEqual(counts[1], storedCount1);
174-
assertNotEqual(counts[2], storedCount1);
173+
assertNotEquals(counts[1], storedCount1);
174+
assertNotEquals(counts[2], storedCount1);
175175
}
176176

tests/taskMgrTests/InterruptTestCases.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
#include <AUnit.h>
2+
#include <testing/SimpleTest.h>
33
#include "TaskManagerIO.h"
44
#include "test_utils.h"
55

6-
using namespace aunit;
6+
using namespace SimpleTest;
77

88
class MockedInterruptAbstraction : public InterruptAbstraction {
99
private:
@@ -54,8 +54,8 @@ testF(TimingHelpFixture, interruptSupportMarshalling) {
5454
taskManager.addInterrupt(&interruptAbs, 2, CHANGE);
5555

5656
// make sure the interrupt is properly registered.
57-
assertEqual(pintype_t(2), interruptAbs.getInterruptPin());
58-
assertEqual(CHANGE, interruptAbs.getTheMode());
57+
assertEquals(pintype_t(2), interruptAbs.getInterruptPin());
58+
assertEquals(CHANGE, interruptAbs.getTheMode());
5959
assertFalse(interruptAbs.isIntHandlerNull());
6060

6161
// now pretend the interrupt took place.
@@ -65,5 +65,5 @@ testF(TimingHelpFixture, interruptSupportMarshalling) {
6565
assertThatTaskRunsOnTime(0, 250);
6666

6767
// and the pin should be 2
68-
assertEqual(2, pinNo);
68+
assertEquals(2, pinNo);
6969
}

tests/taskMgrTests/avrClockRollTests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
#ifdef __AVR__
33

4-
#include <AUnit.h>
4+
#include <testing/SimpleTest.h>
55
#include <util/atomic.h>
66
#include "TaskManagerIO.h"
77

8-
using namespace aunit;
8+
using namespace SimpleTest;
99

1010
// We can only reset the clock to a new value on AVR, this is very useful and allows us to ensure the
1111
// rollover cases work properly at least for milliseconds. As millisecond and microsecond logic are very
@@ -67,13 +67,13 @@ test(testClockRollover) {
6767
dumpTaskTiming();
6868

6969
// the one second task should have executed exactly once.
70-
assertEqual(avrCount1, 1);
71-
assertMore(avrCount2, 1000);
70+
assertEquals(1, avrCount1);
71+
assertMoreThan(1000, avrCount2);
7272

7373
// make sure millis has wrapped now.
7474
assertTrue(millis() < 10000UL);
7575

76-
// and make sure the microsecond job is still going..
76+
// and make sure the microsecond job is still going.
7777
int avrCount2Then = avrCount2;
7878
taskManager.yieldForMicros(10000);
7979
assertTrue(avrCount2Then != avrCount2);

tests/taskMgrTests/eventTestCases.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2-
#include <AUnit.h>
2+
#include <testing/SimpleTest.h>
33
#include <ExecWithParameter.h>
44
#include "TaskManagerIO.h"
55
#include "test_utils.h"
66

7-
using namespace aunit;
7+
using namespace SimpleTest;
88

99
bool taskWithinEvent;
1010

@@ -124,7 +124,7 @@ testF(TimingHelpFixture, testNotifyEventThatStartsAnotherTask) {
124124
externalEvent.markTriggeredAndNotify();
125125
taskManager.yieldForMicros(100);
126126
assertTrue(runScheduleUntilMatchOrTimeout([] { return taskWithinEvent; }));
127-
assertEqual(i + 1, externalEvent.getExecCalls());
127+
assertEquals(i + 1, externalEvent.getExecCalls());
128128
}
129129

130130
// now we let the task complete and after one more cycle it should be removed by task manager.
@@ -137,7 +137,7 @@ testF(TimingHelpFixture, testNotifyEventThatStartsAnotherTask) {
137137
externalEvent.markTriggeredAndNotify();
138138
taskManager.yieldForMicros(200);
139139
assertFalse(externalEvent.wasNextCheckCalled());
140-
assertEqual(0, externalEvent.getExecCalls());
140+
assertEquals(0, externalEvent.getExecCalls());
141141

142142
// it should not be in task manager any longer.
143143
assertFalse(taskManager.getTask(taskId)->isEvent());

tests/taskMgrTests/reentrantLockingTests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2-
#include <AUnit.h>
2+
#include <testing/SimpleTest.h>
33
#include <SimpleSpinLock.h>
44
#include "TaskManagerIO.h"
55
#include "test_utils.h"
66

7-
using namespace aunit;
7+
using namespace SimpleTest;
88

99
SimpleSpinLock testLock;
1010
taskid_t runTaskId1;
@@ -24,7 +24,7 @@ test(testGettingRunningTaskAlwaysCorrect) {
2424
runCount1 = runCount2 = runCount3 = 0;
2525

2626
taskManager.reset();
27-
assertEqual(nullptr, taskManager.getRunningTask());
27+
assertEquals(nullptr, taskManager.getRunningTask());
2828

2929
serdebugF("Starting running task check");
3030

@@ -48,12 +48,12 @@ test(testGettingRunningTaskAlwaysCorrect) {
4848
unsigned long then = millis();
4949
taskManager.yieldForMicros(millisToMicros(100));
5050
int diff = int(millis() - then);
51-
assertMore(diff, 90);
51+
assertMoreThan(90, diff);
5252

5353
serdebugF("Finished running task check, asserting.");
5454

5555
assertTrue(task1RunningPtrCheck);
5656
assertTrue(task2RunningPtrCheck);
57-
assertMore(runCount1, 30);
58-
assertMore(runCount2, 250);
57+
assertMoreThan(30, runCount1);
58+
assertMoreThan(250, runCount2);
5959
}

tests/taskMgrTests/taskManagerCoreTests.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2-
#include <AUnit.h>
2+
#include <testing/SimpleTest.h>
33
#include <ExecWithParameter.h>
44
#include "TaskManagerIO.h"
55
#include "test_utils.h"
66

7-
using namespace aunit;
7+
using namespace SimpleTest;
88

99
void dumpTasks() {
1010
Serial.println("Dumping the task queue contents");
@@ -57,10 +57,10 @@ class TestingExec : public Executable {
5757
TestingExec exec;
5858

5959
testF(TimingHelpFixture, testRunningUsingExecutorClass) {
60-
taskManager.scheduleFixedRate(10, &exec);
60+
taskManager.scheduleFixedRate(10, &::exec);
6161
taskManager.scheduleOnce(250, recordingJob);
6262
assertThatTaskRunsOnTime(250000L, MILLIS_ALLOWANCE);
63-
assertMore(exec.noOfTimesRun, 10);
63+
assertMoreThan(10, ::exec.noOfTimesRun);
6464
}
6565

6666
testF(TimingHelpFixture, schedulingTaskOnceInMicroseconds) {
@@ -96,7 +96,7 @@ testF(TimingHelpFixture, enableAndDisableSupport) {
9696
static int myTaskCounter = 0;
9797
auto myTaskId = taskManager.scheduleFixedRate(1, [] { myTaskCounter++; }, TIME_MILLIS);
9898
taskManager.yieldForMicros(20000);
99-
assertNotEqual(0, myTaskCounter);
99+
assertNotEquals(0, myTaskCounter);
100100

101101
// "turn off" the task
102102
taskManager.setTaskEnabled(myTaskId, false);
@@ -107,32 +107,32 @@ testF(TimingHelpFixture, enableAndDisableSupport) {
107107

108108
// now run the task for some time, it should never get scheduled.
109109
taskManager.yieldForMicros(20000);
110-
assertEqual(myTaskCounter, oldTaskCount);
110+
assertEquals(myTaskCounter, oldTaskCount);
111111

112112
// "turn on" the task and see if it increases again
113113
taskManager.setTaskEnabled(myTaskId, true);
114114
taskManager.yieldForMicros(20000);
115-
assertNotEqual(myTaskCounter, oldTaskCount);
115+
assertNotEquals(myTaskCounter, oldTaskCount);
116116

117117
}
118118

119119
testF(TimingHelpFixture, scheduleFixedRateTestCase) {
120-
assertEqual(taskManager.getFirstTask(), NULL);
120+
assertEquals(taskManager.getFirstTask(), NULL);
121121

122122
auto taskId1 = taskManager.scheduleFixedRate(10, recordingJob, TIME_MILLIS);
123123
auto taskId2 = taskManager.scheduleFixedRate(100, recordingJob2, TIME_MICROS);
124124

125125
// now check the task registration in detail.
126-
assertNotEqual(taskId1, TASKMGR_INVALIDID);
126+
assertNotEquals(taskId1, TASKMGR_INVALIDID);
127127
TimerTask* task = taskManager.getFirstTask();
128-
assertNotEqual(task, NULL);
128+
assertNotEquals(task, NULL);
129129
assertFalse(task->isMillisSchedule());
130130
assertTrue(task->isMicrosSchedule());
131131

132132
// now check the task registration in detail.
133-
assertNotEqual(taskId2, TASKMGR_INVALIDID);
133+
assertNotEquals(taskId2, TASKMGR_INVALIDID);
134134
task = task->getNext();
135-
assertNotEqual(task, NULL);
135+
assertNotEquals(task, NULL);
136136
assertTrue(task->isMillisSchedule());
137137
assertFalse(task->isMicrosSchedule());
138138

@@ -145,26 +145,26 @@ testF(TimingHelpFixture, scheduleFixedRateTestCase) {
145145
dumpTasks();
146146

147147
// make sure the yield timings were in range.
148-
assertLess(timeTaken, (uint32_t) 25);
149-
assertMoreOrEqual(timeTaken, (uint32_t) 20);
148+
assertLessThan((uint32_t) 25, timeTaken);
149+
assertMoreThan((uint32_t) 19, timeTaken);
150150

151151
// now make sure that we got in the right ball park of calls.
152-
assertMore(count, 1);
153-
assertMore(count2, 150);
152+
assertMoreThan(1, count);
153+
assertMoreThan(150, count2);
154154
}
155155

156156
testF(TimingHelpFixture, cancellingAJobAfterCreation) {
157-
assertEqual(taskManager.getFirstTask(), NULL);
157+
assertEquals(taskManager.getFirstTask(), nullptr);
158158

159159
auto taskId = taskManager.scheduleFixedRate(10, recordingJob, TIME_MILLIS);
160160

161161
// now check the task registration in detail.
162-
assertNotEqual(taskId, TASKMGR_INVALIDID);
162+
assertNotEquals(taskId, TASKMGR_INVALIDID);
163163
TimerTask* task = taskManager.getFirstTask();
164-
assertNotEqual(task, NULL);
164+
assertNotEquals(task, NULL);
165165
assertTrue(task->isMillisSchedule());
166166
assertFalse(task->isMicrosSchedule());
167-
assertMore(task->microsFromNow(), 8000UL);
167+
assertMoreThan(8000UL, task->microsFromNow());
168168

169169
assertThatTaskRunsOnTime(10000, MILLIS_ALLOWANCE);
170170

@@ -174,5 +174,5 @@ testF(TimingHelpFixture, cancellingAJobAfterCreation) {
174174
taskManager.yieldForMicros(100); // needs to run the cancellation task.
175175
assertTasksSpacesTaken(0);
176176

177-
assertEqual(taskManager.getFirstTask(), NULL);
177+
assertEquals(taskManager.getFirstTask(), NULL);
178178
}
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11

22
#include <Arduino.h>
3-
#include <AUnit.h>
3+
#include <testing/SimpleTest.h>
44
#include <Wire.h>
55

6-
using namespace aunit;
6+
using namespace SimpleTest;
77

88
void setup() {
99
Serial.begin(115200);
1010
while (!Serial);
11+
startTesting();
1112
}
1213

13-
void loop() {
14-
TestRunner::setTimeout(60);
15-
TestRunner::run();
16-
}
14+
DEFAULT_TEST_RUNLOOP

0 commit comments

Comments
 (0)