From c0fb6442e30c44490b42e6072151ee739b944e56 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 30 Jan 2021 10:55:28 +0100 Subject: Run tests with both C (c99, c11) and C++ (c++11, c++20) compilers --- test/compile-c++11.sh | 3 +++ test/compile-c++20.sh | 4 ++++ test/compile-c11.sh | 3 +++ test/compile-c99.sh | 3 +++ test/compile.sh | 3 --- test/inflate-app.c | 4 ++-- test/test.sh | 18 +++++++++++------- 7 files changed, 26 insertions(+), 12 deletions(-) create mode 100755 test/compile-c++11.sh create mode 100755 test/compile-c++20.sh create mode 100755 test/compile-c11.sh create mode 100755 test/compile-c99.sh delete mode 100755 test/compile.sh (limited to 'test') diff --git a/test/compile-c++11.sh b/test/compile-c++11.sh new file mode 100755 index 0000000..cb13625 --- /dev/null +++ b/test/compile-c++11.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec g++ -std=c++11 -Wall -Wextra -pedantic -I../src -o inflate inflate-app.c ../src/inflate.c diff --git a/test/compile-c++20.sh b/test/compile-c++20.sh new file mode 100755 index 0000000..502063b --- /dev/null +++ b/test/compile-c++20.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# g++ as provided by Debian Buster (used for CI tests) does not support c++20 +exec g++ -std=c++2a -Wall -Wextra -pedantic -I../src -o inflate inflate-app.c ../src/inflate.c diff --git a/test/compile-c11.sh b/test/compile-c11.sh new file mode 100755 index 0000000..87ec632 --- /dev/null +++ b/test/compile-c11.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec gcc -std=c11 -Wall -Wextra -pedantic -I../src -o inflate inflate-app.c ../src/inflate.c diff --git a/test/compile-c99.sh b/test/compile-c99.sh new file mode 100755 index 0000000..4583ebf --- /dev/null +++ b/test/compile-c99.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec gcc -std=c99 -Wall -Wextra -pedantic -I../src -o inflate inflate-app.c ../src/inflate.c diff --git a/test/compile.sh b/test/compile.sh deleted file mode 100755 index 3d6306f..0000000 --- a/test/compile.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec gcc -ggdb -Wall -Wextra -pedantic -I../src -o inflate inflate-app.c ../src/inflate.c diff --git a/test/inflate-app.c b/test/inflate-app.c index dddc807..988a3f1 100644 --- a/test/inflate-app.c +++ b/test/inflate-app.c @@ -9,8 +9,8 @@ unsigned char *outbuf; int main(void) { // 16 MB - inbuf = malloc(4096 * 4096); - outbuf = malloc(4096 * 4096); + inbuf = (unsigned char*)malloc(4096 * 4096); + outbuf = (unsigned char*)malloc(4096 * 4096); if (inbuf == NULL || outbuf == NULL) { return 1; diff --git a/test/test.sh b/test/test.sh index dda32aa..44104d5 100755 --- a/test/test.sh +++ b/test/test.sh @@ -4,14 +4,18 @@ set -eu cd "$(dirname "$0")" -./compile.sh +for std in c++11 c++20 c99 c11; do + + "./compile-${std}.sh" + + for file in $(find .. -type f -size -32760c); do + if ! ./deflate $file | ./inflate > tmp; then + echo "inflate error at $file" + ./deflate $file | ./inflate > tmp + fi + diff $file tmp + done -for file in $(find .. -type f -size -32760c); do - if ! ./deflate $file | ./inflate > tmp; then - echo "inflate error at $file" - ./deflate $file | ./inflate > tmp - fi - diff $file tmp done rm -f tmp -- cgit v1.2.3