-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly account for: - X - Y - Z
- Loading branch information
Showing
4 changed files
with
217 additions
and
21 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
examples/tests/multi_alarm_dont_ignore_previous_overflow/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Makefile for user application | ||
|
||
# Specify this directory relative to the current application. | ||
TOCK_USERLAND_BASE_DIR = ../../.. | ||
|
||
# Which files to compile. | ||
C_SRCS := $(wildcard *.c) | ||
|
||
# Include userland master makefile. Contains rules and flags for actually | ||
# building the application. | ||
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk |
29 changes: 29 additions & 0 deletions
29
examples/tests/multi_alarm_dont_ignore_previous_overflow/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Test Multiple Alarms (Ensure previous overflowing alarms aren't ignore) | ||
|
||
This tests the virtual alarms available to userspace. It sets three | ||
alarms alarms. The first two overflow and should result in multiple | ||
alarms under the hood, and a third a 10 second alarm started after the | ||
second. The first alarm is set first, but expires second (1 second | ||
after overflow vs 10ms after overflow). The third alarm should expire | ||
last. | ||
|
||
When successful, the first alarm should fire after a clock overflow + | ||
1 second, while the third should fire after a clock overflow + 10ms + | ||
10 seconds. | ||
|
||
If the virtual alarm library is buggy, this test might fail by never | ||
firing the first alarm or firing it after the third alarm | ||
(specifically almost another clock overflow) because either alarm | ||
insertion or virtual alarm upcall handing misses it after the second | ||
alarm fires. | ||
|
||
# Example Output | ||
|
||
Correct: | ||
|
||
(after an entire clock overflow, ~8 minutes) | ||
|
||
``` | ||
1 10498816 10496827 | ||
2 86100992 86099200 | ||
``` |
24 changes: 24 additions & 0 deletions
24
examples/tests/multi_alarm_dont_ignore_previous_overflow/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include <libtock-sync/services/alarm.h> | ||
|
||
static void event_cb(uint32_t now, uint32_t expiration, void* ud) { | ||
int i = (int)ud; | ||
printf("%d %lu %lu\n", i, now, expiration); | ||
} | ||
|
||
int main(void) { | ||
libtock_alarm_t t1; | ||
libtock_alarm_t t2; | ||
|
||
uint32_t overflow_ms = libtock_alarm_ticks_to_ms(UINT32_MAX); | ||
|
||
libtock_alarm_in_ms(overflow_ms + 1000, event_cb, (void*)1, &t1); | ||
libtocksync_alarm_delay_ms(overflow_ms + 10); | ||
libtock_alarm_in_ms(10000, event_cb, (void*)2, &t2); | ||
|
||
while (1) { | ||
yield(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters