Minor fixes to callout tests
@@ -13,9 +13,11 @@ static void callout_simple(void *arg) {
static int test_callout_simple() {
callout_t callout;
- callout_setup_relative(&callout, 10, callout_simple, NULL);
+ critical_enter();
+ callout_setup_relative(&callout, 5, callout_simple, NULL);
sleepq_wait(callout_simple, "callout_simple");
+ critical_leave();
return KTEST_SUCCESS;
}
@@ -25,9 +27,10 @@ static int test_callout_simple() {
static int current = 0;
static void callout_ordered(void *arg) {
- int n = (int)arg;
- assert(current == n);
+ /* Atomic increment */
+ critical_enter();
current++;
+ critical_leave();
if (current == 10)
sleepq_signal(callout_ordered);
@@ -42,11 +45,12 @@ static int test_callout_order() {
base time! */
critical_enter();
for (int i = 0; i < 10; i++)
- callout_setup_relative(&callouts[i], 20 + order[i] * 15, callout_ordered,
+ callout_setup_relative(&callouts[i], 5 + order[i] * 5, callout_ordered,
(void *)order[i]);
- critical_leave();
sleepq_wait(callout_ordered, "callout_ordered");
+ critical_leave();
+
assert(current == 10);
return KTEST_SUCCESS;
@@ -64,8 +68,11 @@ static void callout_good(void *arg) {
static int test_callout_stop() {
current = 0;
callout_t callout1, callout2;
- callout_setup_relative(&callout1, 40, callout_bad, NULL);
- callout_setup_relative(&callout2, 60, callout_good, NULL);
+
+ critical_enter();
+
+ callout_setup_relative(&callout1, 5, callout_bad, NULL);
+ callout_setup_relative(&callout2, 10, callout_good, NULL);
/* Remove callout1, hope that callout_bad won't be called! */
callout_stop(&callout1);
@@ -73,6 +80,8 @@ static int test_callout_stop() {
/* Give some time for callout_bad, wait for callout_good. */
sleepq_wait(callout_good, "callout_good");
+ critical_leave();
+
return KTEST_SUCCESS;
}
