machinarium: add new test-suite implementation

This commit is contained in:
Dmitry Simonenko 2017-05-15 16:21:56 +03:00
parent cb588f4973
commit 40420f7714
4 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,18 @@
/*
* machinarium.
*
* Cooperative multitasking engine.
*/
#include <machinarium.h>
#include <machinarium_test.h>
extern void test_init(void);
int
main(int argc, char *argv[])
{
machinarium_test(test_init);
return 0;
}

View File

@ -0,0 +1,26 @@
#ifndef MACHINARIUM_TEST_H
#define MACHINARIUM_TEST_H
/*
* machinarium.
*
* cooperative multitasking engine.
*/
#define machinarium_test(FUNCTION) \
do { \
(FUNCTION)(); \
fprintf(stdout, "%s: ok\n", #FUNCTION); \
} while (0);
#define test(expression) \
do { \
if (! (expression)) { \
fprintf(stdout, "%s: fail (%s:%d) %s\n", \
__func__, __FILE__, __LINE__, #expression); \
fflush(stdout); \
abort(); \
} \
} while (0);
#endif

15
test-suite/makefile Normal file
View File

@ -0,0 +1,15 @@
CC = gcc
RM = rm
CFLAGS = -I. -Wall -g -O0 -I../src
LFLAGS_LIB = ../src/libmachinarium.a -pthread -lssl -lcrypto
LFLAGS = $(LFLAGS_LIB)
OBJECTS = machinarium_test.o \
test_init.o
all: clean $(OBJECTS) machinarium_test
machinarium_test:
$(CC) $(OBJECTS) $(LFLAGS) -o machinarium_test
.c.o:
$(CC) $(CFLAGS) -c $<
clean:
$(RM) -f $(OBJECTS) machinarium_test

16
test-suite/test_init.c Normal file
View File

@ -0,0 +1,16 @@
/*
* machinarium.
*
* Cooperative multitasking engine.
*/
#include <machinarium.h>
#include <machinarium_test.h>
void
test_init(void)
{
machinarium_init();
machinarium_free();
}