diff --git a/tests/event.c b/tests/event.c new file mode 100644 index 0000000..03d972d --- /dev/null +++ b/tests/event.c @@ -0,0 +1,53 @@ +/* $Id$ */ +/* Copyright (c) 2015 Pierre Pronchery */ +/* This file is part of DeforaOS System libSystem */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#include +#include "System/event.h" + + +/* event */ +static int _event_on_idle(void * data); + +static int _event(char const * progname) +{ + int ret; + Event * event; + + printf("%s: Testing event_new()\n", progname); + if((event = event_new()) == NULL) + return -1; + printf("%s: Testing event_loop()\n", progname); + event_register_idle(event, _event_on_idle, event); + ret = event_loop(event); + event_delete(event); + return ret; +} + +static int _event_on_idle(void * data) +{ + Event * event = data; + + event_loop_quit(event); + return 0; +} + + +/* main */ +int main(int argc, char * argv[]) +{ + return (_event(argv[0]) == 0) ? 0 : 2; +} diff --git a/tests/project.conf b/tests/project.conf index 827703b..96e782d 100644 --- a/tests/project.conf +++ b/tests/project.conf @@ -1,4 +1,4 @@ -targets=array,config,includes,pylint.log,string,variable,tests.log +targets=array,config,event,includes,pylint.log,string,variable,tests.log cppflags_force=-I ../include cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector-all ldflags_force=-L../src -L$(OBJDIR)../src -Wl,-rpath,$(OBJDIR)../src -lSystem @@ -19,6 +19,13 @@ sources=config.c [config.c] depends=../src/config.c +[event] +type=binary +sources=event.c + +[event.c] +depends=../src/event.c + [includes] type=binary sources=includes.c @@ -38,7 +45,7 @@ depends=../src/string.c [tests.log] type=script script=./tests.sh -depends=$(OBJDIR)array,$(OBJDIR)config,config.conf,config-noeol.conf,$(OBJDIR)includes,python.sh,$(OBJDIR)string,tests.sh,$(OBJDIR)variable,$(OBJDIR)../src/libSystem.a +depends=$(OBJDIR)array,$(OBJDIR)config,config.conf,config-noeol.conf,$(OBJDIR)event,$(OBJDIR)includes,python.sh,$(OBJDIR)string,tests.sh,$(OBJDIR)variable,$(OBJDIR)../src/libSystem.a [variable] type=binary diff --git a/tests/tests.sh b/tests/tests.sh index 11e8b5b..b7e0e78 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -102,6 +102,7 @@ FAILED= echo "Performing tests:" 1>&2 _test "array" _test "config" +_test "event" _test "includes" _test "string" _test "variable"