summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-01-30 10:55:28 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-01-30 10:55:28 +0100
commitc0fb6442e30c44490b42e6072151ee739b944e56 (patch)
tree48cd5bd004ffacebee7d8d139d09e34d3976fd42
parent8768a30f73a8ad5ab00476401626993958845ad7 (diff)
Run tests with both C (c99, c11) and C++ (c++11, c++20) compilers
-rw-r--r--README.md7
-rwxr-xr-xtest/compile-c++11.sh3
-rwxr-xr-xtest/compile-c++20.sh4
-rwxr-xr-xtest/compile-c11.sh3
-rwxr-xr-xtest/compile-c99.sh3
-rwxr-xr-xtest/compile.sh3
-rw-r--r--test/inflate-app.c4
-rwxr-xr-xtest/test.sh18
8 files changed, 29 insertions, 16 deletions
diff --git a/README.md b/README.md
index 6844251..1d60782 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,9 @@
**zlib-deflate-nostdlib** provides a zlib decompressor (RFC 1950) and deflate
reader (RFC 1951) suitable for 8- and 16-bit microcontrollers. It works
fine on MCUs as small as ATMega328P (used, for example, in the Arduino Nano)
-and MSP430FR5994. It is compatible with both C (e.g. c99) and C++
-(e.g. c++20). Apart from type definitions for (u)int8\_t, (u)int16\_t,
-and (u)int32\_t, which are typically provided by stdint.h, it has no external
-dependencies.
+and MSP430FR5994. It is compatible with both C (from c99 on) and C++. Apart
+from type definitions for (u)int8\_t, (u)int16\_t, and (u)int32\_t, which are
+typically provided by stdint.h, it has no external dependencies.
zlib-deflate-nostdlib is focused on a low memory footprint. It is not optimized
for speed and uses a pretty naive implementation right now.
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