summaryrefslogtreecommitdiff
path: root/test/Makefile
blob: e0086be30fbc4d1a9e4441a3603a3f1793b4f247 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
CC = gcc

CFLAGS = -std=gnu99 -Wall -DFAKE_STAT -Werror -Wextra $(FAKETIME_COMPILE_CFLAGS)
LDFLAGS = -lrt -lpthread

SRC = timetest.c
OBJ = ${SRC:.c=.o}

TEST_SNIPPETS = $(notdir $(basename $(wildcard snippets/*.c)))
EXPECTATIONS= $(notdir $(basename $(wildcard snippets/*.variable)))

all: timetest test

.c.o:
	${CC} -c ${CFLAGS} $<

timetest: ${OBJ}
	${CC} -o $@ ${OBJ} ${LDFLAGS}

test: timetest functest
	@echo
	@./test.sh

# run functional tests
functest:
	./testframe.sh functests

%_test: %_test.c
	${CC} -o $@ ${CFLAGS} $<

randomtest: repeat_random
	./randomtest.sh

## test variables

test_variable_data: test_variable_data.sh $(foreach f,${EXPECTATIONS},run_${f})
	./test_variable_data.sh ${EXPECTATIONS}

run_%: _run_test.c snippets/%.c
	sed s/SNIPPET_NAME/$*/g < _run_test.c | ${CC} -o $@ ${CFLAGS} -x c - 

## testing when interception points get called in library constructors:

test_library_constructors: test_constructors.sh $(foreach f,${TEST_SNIPPETS},use_lib_${f} lib${f}.so)
	true $(foreach f,${TEST_SNIPPETS},&& ./test_constructors.sh ${f})

lib%.so: _libtest.c snippets/%.c
	sed s/SNIPPET_NAME/$*/g < _libtest.c | ${CC} -shared -o $@ -fpic ${CFLAGS} -x c -

use_lib_%: _use_lib_test.c snippets/%.c lib%.so
	sed s/SNIPPET_NAME/$*/g < _use_lib_test.c | ${CC} -L. -o $@ ${CFLAGS} -x c - -l$*


## cleanup and metainformation

clean:
	@rm -f ${OBJ} timetest getrandom_test syscall_test $(foreach f,${TEST_SNIPPETS},use_lib_${f} lib${f}.so run_${f})

distclean: clean
	@echo

.PHONY: all test clean distclean randomtest