Skip to content
Snippets Groups Projects
Commit e5ed5803 authored by Guy Zana's avatar Guy Zana
Browse files

Add a basic unit-test for the partly implemented callout interface

parent c913ab05
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
#/tests/tst-ramdisk.so: ./tests/tst-ramdisk.so
#/tests/tst-vblk.so: ./tests/tst-vblk.so
#/tests/tst-bsd-evh.so: ./tests/tst-bsd-evh.so
/tests/tst-bsd-callout.so: ./tests/tst-bsd-callout.so
/testrunner.so: ./tests/testrunner.so
/java/Hello.class: ./tests/hello/Hello.class
/java.so: java/java.so
......
......@@ -71,7 +71,7 @@ do-sys-includes = $(foreach inc, $(sys-includes), -isystem $(inc))
tests := tests/tst-pthread.so tests/tst-ramdisk.so tests/hello/Hello.class
tests += tests/tst-vblk.so tests/bench/bench.jar
tests += tests/tst-bsd-evh.so
tests += tests/tst-bsd-evh.so tests/tst-bsd-callout.so
tests/hello/Hello.class: javabase=tests/hello
......@@ -81,6 +81,7 @@ tests/tst-pthread.so: tests/tst-pthread.o
tests/tst-ramdisk.so: tests/tst-ramdisk.o
tests/tst-vblk.so: tests/tst-vblk.o
tests/tst-bsd-evh.so: tests/tst-bsd-evh.o
tests/tst-bsd-callout.so: tests/tst-bsd-callout.o
all: loader.img loader.bin
......
#include <stdio.h>
#include <unistd.h>
#include <bsd/porting/callout.h>
struct callout c1, c2;
int ctr;
void aaa(void *unused)
{
ctr++;
printf("TICK %d\n", ctr);
callout_reset(&c1, hz, aaa, NULL);
}
void bbb(void *unused)
{
// Stop aaa
printf("SHUT-UP\n");
_callout_stop_safe(&c1, 1);
}
void test1(void)
{
printf("BSD Callout Test\n");
ctr = 0;
callout_init(&c1, 1);
callout_reset(&c1, hz, aaa, NULL);
callout_init(&c2, 1);
callout_reset(&c2, 10.1*hz, bbb, NULL);
sleep(11);
printf("BSD Callout Test Done\n");
}
int main(int argc, char **argv)
{
test1();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment