summaryrefslogtreecommitdiff
path: root/tests/test-Tasks.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-Tasks.cc')
-rw-r--r--tests/test-Tasks.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test-Tasks.cc b/tests/test-Tasks.cc
index 1faa194..bdafa8d 100644
--- a/tests/test-Tasks.cc
+++ b/tests/test-Tasks.cc
@@ -22,6 +22,12 @@ class TestTask : public Task {
}
};
+static void yieldingFunction() {
+ Events::Timeout timeout(0.2);
+ Task::yield(&timeout);
+ Assert(timeout.gotSignal());
+}
+
void MainTask::Do() {
customPrinter = new CustomPrinter();
Printer::log(M_STATUS, "Test::Tasks running.");
@@ -39,6 +45,15 @@ void MainTask::Do() {
yield();
Assert(timeout.gotSignal());
+ timeout.set(0.1);
+ timeout.reset();
+ setPreemptible(false);
+ yieldingFunction();
+ Assert(!timeout.gotSignal());
+ waitFor(&timeout);
+ yield();
+ Assert(timeout.gotSignal());
+
Printer::log(M_STATUS, "Test::Tasks passed.");
Printer::log(M_DEBUG, "You shouldn't see that message.");
}