Skip to content

Commit

Permalink
Add a test for C++ compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoisin committed Jun 21, 2024
1 parent 520e7e4 commit 8f8e5c1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ clang: CFLAGS+=-I/usr/include/x86_64-linux-musl
clang: CFLAGS+=-I../x86_64-linux-musl-native/include/
clang: CFLAGS+=-Ix86_64-linux-musl-native/include/
clang: CFLAGS+=-nostdinc
clang: comptime $(RUNTIME_TARGETS)
clang: CXX=clang++
clang: CXXFLAGS=$(CFLAGS)
clang: comptime $(RUNTIME_TARGETS) cpp

coverage: CFLAGS += -fprofile-arcs -ftest-coverage
coverage: CC=../x86_64-linux-musl-native/bin/gcc
Expand All @@ -173,6 +175,10 @@ all: gcc
$(RUNTIME_TARGETS): %: %.c
$(CC) $(CFLAGS) -o $@ $<

cpp: test_compile.cc
$(CXX) $(CXXFLAGS) test_compile.cc -o ./test_compile_cc
timeout 1s ./test_compile_cc 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \

run: $(RUNTIME_TARGETS)
$(foreach EXE, $(RUNTIME_TARGETS), \
timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \
Expand All @@ -187,5 +193,6 @@ clean:
$(foreach EXE, $(RUNTIME_TARGETS) $(COMPTIME_TARGETS), \
rm -f ./$(EXE) \
)
rm -f ./test_compile_cc
rm -rf ./*.gcno ./*.gcda ./*.gcov ./coverage.info ./coverage

18 changes: 18 additions & 0 deletions tests/test_compile.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "common.h"

#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <wchar.h>

#include <sys/select.h>
#include <sys/socket.h>
#include <sys/stat.h>

// Check that all headers are compiling.
int main(int argc, char** argv) {
return 0;
}

0 comments on commit 8f8e5c1

Please sign in to comment.