aboutsummaryrefslogtreecommitdiffstats
path: root/service/src/test.sh
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2021-05-04 11:07:45 +0200
committerLouis Burda <quent.burda@gmail.com>2021-05-04 11:07:45 +0200
commita0d6bf48a185026589288fd9aa94506b321301d8 (patch)
tree579d27d143a43f252148a221dde7e4225a6c0987 /service/src/test.sh
parent93107ebd417e75efed4e2173feeea1030ce6cd02 (diff)
downloadenowars5-service-stldoctor-a0d6bf48a185026589288fd9aa94506b321301d8.tar.gz
enowars5-service-stldoctor-a0d6bf48a185026589288fd9aa94506b321301d8.zip
further improved parsing and related tests
Diffstat (limited to 'service/src/test.sh')
-rw-r--r--service/src/test.sh35
1 files changed, 34 insertions, 1 deletions
diff --git a/service/src/test.sh b/service/src/test.sh
index 51f43cc..6d58ad6 100644
--- a/service/src/test.sh
+++ b/service/src/test.sh
@@ -1,9 +1,42 @@
#!/bin/sh
+set -e
+
+announce() {
+ count=$(echo "$1" | wc -c)
+ python3 -c "
+import math
+s = '$1'
+c = 80
+print()
+print('#'*c)
+print('#' + ' '*math.floor((c - len(s))/2-1) + s + ' '*math.ceil((c - len(s))/2-1) + '#')
+print('#'*c)
+print()
+ "
+}
+
+checkleaks() {
+ valgrind --leak-check=full ./printdoc 2>&1 | tee /tmp/testlog
+ if [ -z "$(grep "no leaks are possible" /tmp/testlog)" ]; then
+ echo "Valgrind exited with errors!"
+ exit 1
+ fi
+}
+
+announce "Trying ASCII STL"
(
echo "help"
echo "submit"
cat tests/sample-ascii.stl | wc -c
cat tests/sample-ascii.stl
-) | valgrind --leak-check=full ./printdoc
+) | checkleaks
+
+announce "Trying BIN STL"
+(
+ echo "help"
+ echo "submit"
+ cat tests/sample-binary.stl | wc -c
+ cat tests/sample-binary.stl
+) | checkleaks