summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2024-06-21 16:25:40 +0200
committerjvoisin2024-06-21 16:40:26 +0200
commit8f8e5c1a7854f05bfa94fc41033706bc14682223 (patch)
tree264128ebf99ff382fdabd6a102b53d5306535aef
parent520e7e4a631cc038b3e867b2255235da35a98ece (diff)
Add a test for C++ compilation
-rw-r--r--tests/Makefile9
-rw-r--r--tests/test_compile.cc18
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile
index d6f5b5d..56455bd 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -156,7 +156,9 @@ clang: CFLAGS+=-I/usr/include/x86_64-linux-musl
156clang: CFLAGS+=-I../x86_64-linux-musl-native/include/ 156clang: CFLAGS+=-I../x86_64-linux-musl-native/include/
157clang: CFLAGS+=-Ix86_64-linux-musl-native/include/ 157clang: CFLAGS+=-Ix86_64-linux-musl-native/include/
158clang: CFLAGS+=-nostdinc 158clang: CFLAGS+=-nostdinc
159clang: comptime $(RUNTIME_TARGETS) 159clang: CXX=clang++
160clang: CXXFLAGS=$(CFLAGS)
161clang: comptime $(RUNTIME_TARGETS) cpp
160 162
161coverage: CFLAGS += -fprofile-arcs -ftest-coverage 163coverage: CFLAGS += -fprofile-arcs -ftest-coverage
162coverage: CC=../x86_64-linux-musl-native/bin/gcc 164coverage: CC=../x86_64-linux-musl-native/bin/gcc
@@ -173,6 +175,10 @@ all: gcc
173$(RUNTIME_TARGETS): %: %.c 175$(RUNTIME_TARGETS): %: %.c
174 $(CC) $(CFLAGS) -o $@ $< 176 $(CC) $(CFLAGS) -o $@ $<
175 177
178cpp: test_compile.cc
179 $(CXX) $(CXXFLAGS) test_compile.cc -o ./test_compile_cc
180 timeout 1s ./test_compile_cc 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \
181
176run: $(RUNTIME_TARGETS) 182run: $(RUNTIME_TARGETS)
177 $(foreach EXE, $(RUNTIME_TARGETS), \ 183 $(foreach EXE, $(RUNTIME_TARGETS), \
178 timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \ 184 timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \
@@ -187,5 +193,6 @@ clean:
187 $(foreach EXE, $(RUNTIME_TARGETS) $(COMPTIME_TARGETS), \ 193 $(foreach EXE, $(RUNTIME_TARGETS) $(COMPTIME_TARGETS), \
188 rm -f ./$(EXE) \ 194 rm -f ./$(EXE) \
189 ) 195 )
196 rm -f ./test_compile_cc
190 rm -rf ./*.gcno ./*.gcda ./*.gcov ./coverage.info ./coverage 197 rm -rf ./*.gcno ./*.gcda ./*.gcov ./coverage.info ./coverage
191 198
diff --git a/tests/test_compile.cc b/tests/test_compile.cc
new file mode 100644
index 0000000..edbbb27
--- /dev/null
+++ b/tests/test_compile.cc
@@ -0,0 +1,18 @@
1#include "common.h"
2
3#include <poll.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <strings.h>
8#include <unistd.h>
9#include <wchar.h>
10
11#include <sys/select.h>
12#include <sys/socket.h>
13#include <sys/stat.h>
14
15// Check that all headers are compiling.
16int main(int argc, char** argv) {
17 return 0;
18}