blob: 78433fe432dd17068d4d62942a7457cd582f5e6a (
plain) (
blame)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# Makefile for running the unittests of libfixmath.
CC = gcc
# Basic CFLAGS for debugging
CFLAGS = -g -O0 -I../libfixmath -Wall -Wextra -Werror
# The files required for tests
FIX16_SRC = ../libfixmath/fix16.c ../libfixmath/fix16_sqrt.c ../libfixmath/fix16_str.c \
../libfixmath/fix16_exp.c ../libfixmath/fix16.h
all: run_fix16_unittests run_fix16_exp_unittests run_fix16_str_unittests run_fix16_macros_unittests
clean:
rm -f fix16_unittests_????
rm -f fix16_str_unittests_default
rm -f fix16_str_unittests_no_ctype
rm -f fix16_exp_unittests
rm -f fix16_macros_unittests
# The library is tested automatically under different compilations
# options.
#
# Test naming:
# r = rounding, n = no rounding
# o = overflow detection, n = no overflow detection
# 64 = int64_t math, 32 = int32_t math
run_fix16_unittests: \
fix16_unittests_ro64 fix16_unittests_no64 \
fix16_unittests_rn64 fix16_unittests_nn64 \
fix16_unittests_ro32 fix16_unittests_no32 \
fix16_unittests_rn32 fix16_unittests_nn32 \
fix16_unittests_ro08 fix16_unittests_no08 \
fix16_unittests_rn08 fix16_unittests_nn08
$(foreach test, $^, \
echo $(test) && \
./$(test) > /dev/null && \
) true
fix16_unittests_no64: DEFINES=-DFIXMATH_NO_ROUNDING
fix16_unittests_rn64: DEFINES=-DFIXMATH_NO_OVERFLOW
fix16_unittests_nn64: DEFINES=-DFIXMATH_NO_ROUNDING -DFIXMATH_NO_OVERFLOW
fix16_unittests_ro32: DEFINES=-DFIXMATH_NO_64BIT
fix16_unittests_no32: DEFINES=-DFIXMATH_NO_ROUNDING -DFIXMATH_NO_64BIT
fix16_unittests_rn32: DEFINES=-DFIXMATH_NO_OVERFLOW -DFIXMATH_NO_64BIT
fix16_unittests_nn32: DEFINES=-DFIXMATH_NO_OVERFLOW -DFIXMATH_NO_ROUNDING -DFIXMATH_NO_64BIT
fix16_unittests_ro08: DEFINES=-DFIXMATH_OPTIMIZE_8BIT
fix16_unittests_no08: DEFINES=-DFIXMATH_NO_ROUNDING -DFIXMATH_OPTIMIZE_8BIT
fix16_unittests_rn08: DEFINES=-DFIXMATH_NO_OVERFLOW -DFIXMATH_OPTIMIZE_8BIT
fix16_unittests_nn08: DEFINES=-DFIXMATH_NO_OVERFLOW -DFIXMATH_NO_ROUNDING -DFIXMATH_OPTIMIZE_8BIT
fix16_str_unittests_no_ctype: DEFINES=-DFIXMATH_NO_CTYPE
fix16_unittests_% : fix16_unittests.c $(FIX16_SRC)
$(CC) $(CFLAGS) $(DEFINES) -o $@ $^ -lm
# Tests for the exponential function, run only in default config
run_fix16_exp_unittests: fix16_exp_unittests
./fix16_exp_unittests > /dev/null
fix16_exp_unittests: fix16_exp_unittests.c $(FIX16_SRC)
$(CC) $(CFLAGS) $(DEFINES) -o $@ $^ -lm
# Tests for string conversion, run only in default config and no ctype
run_fix16_str_unittests: fix16_str_unittests_default fix16_str_unittests_no_ctype
./fix16_str_unittests_default > /dev/null
./fix16_str_unittests_no_ctype > /dev/null
fix16_str_unittests_%: fix16_str_unittests.c $(FIX16_SRC)
$(CC) $(CFLAGS) $(DEFINES) -o $@ $^ -lm
# Tests for literal macros, run only in default config
run_fix16_macros_unittests: fix16_macros_unittests
./fix16_macros_unittests > /dev/null
fix16_macros_unittests: fix16_macros_unittests.c $(FIX16_SRC)
$(CC) $(CFLAGS) $(DEFINES) -o $@ $^ -lm
|