summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-06-11 19:08:07 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-11 19:08:07 +0300
commitd794f1a315af407da245f078e24d497d650595cc (patch)
tree94c3dcbd3ee8eaa82f65b12ee57e1dda932c07d6 /tools
parent3741b075052c801fca2b65589a5fc0bb263015f5 (diff)
downloaddeheader-d794f1a315af407da245f078e24d497d650595cc.tar.gz
deheader-d794f1a315af407da245f078e24d497d650595cc.tar.bz2
deheader-d794f1a315af407da245f078e24d497d650595cc.tar.xz
deheader-d794f1a315af407da245f078e24d497d650595cc.zip
Add basic ci testing.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/ci/jobs/deheader.sh24
-rwxr-xr-xtools/ci/jobs/deheadererror.sh33
-rwxr-xr-xtools/ci/jobs/deheaderok.sh30
-rw-r--r--tools/ci/samples/include1.h6
-rw-r--r--tools/ci/samples/test1.cpp6
-rw-r--r--tools/ci/samples/test1.h6
-rw-r--r--tools/ci/samples/test2.cpp8
-rw-r--r--tools/ci/samples/test2.h6
-rw-r--r--tools/ci/samples/test3.cpp10
-rw-r--r--tools/ci/samples/test3.h6
-rwxr-xr-xtools/ci/scripts/init.sh213
11 files changed, 348 insertions, 0 deletions
diff --git a/tools/ci/jobs/deheader.sh b/tools/ci/jobs/deheader.sh
new file mode 100755
index 0000000..7f14a7b
--- /dev/null
+++ b/tools/ci/jobs/deheader.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+export LOGFILE=deheader.log
+
+source ./tools/ci/scripts/init.sh
+
+#aptget_install python wget \
+# gcc-5 g++-5 \
+# libphysfs-dev \
+# libxml2-dev libcurl4-gnutls-dev libpng-dev \
+# libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
+
+export dir=$(pwd)
+export var=$2
+export name=${var%.*}
+export name=${name#./src/}
+export name=${name##*./}.h
+
+echo $2 >>${LOGFILE}
+echo $2
+
+${dir}/deheader -q \
+-m "$1 -c -std=gnu++1z -Werror -Wall -Wextra -Wundef -Wmissing-declarations -I/usr/include -I${dir}/tools/ci/samples" ${dir}/tools/ci/samples/$2 \
+| grep -v "portability requires" | tee -a ${LOGFILE}
diff --git a/tools/ci/jobs/deheadererror.sh b/tools/ci/jobs/deheadererror.sh
new file mode 100755
index 0000000..2f72e0d
--- /dev/null
+++ b/tools/ci/jobs/deheadererror.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+export LOGFILE=deheader.log
+export LOGFILE2=deheader2.log
+
+export DATA=$(cat ${LOGFILE})
+if [[ -z "${DATA}" ]]; then
+ echo "Empty output. Probably wrong search flags."
+ exit 1
+fi
+
+export DATA=$(grep "error:" ${LOGFILE})
+if [[ -n "${DATA}" ]]; then
+ echo "Compilation error found"
+ exit 1
+fi
+
+grep "deheader:" ${LOGFILE} \
+| grep -v "deheader: remove <climits> from ./src/being/localplayer.cpp" \
+| grep -v "deheader: remove <fstream> from ./src/utils/files.cpp" \
+| grep -v "deheader: remove <climits> from ./src/resources/map/map.cpp" \
+| grep -v "deheader: remove <sys/time.h> from ./src/resources/wallpaper.cpp" \
+| grep -v "deheader: remove <climits> from ./src/units.cpp" | grep "$1" > ${LOGFILE2}
+
+export DATA=$(cat ${LOGFILE2})
+
+if [[ -n "${DATA}" ]]; then
+ echo "Removed include is ok"
+ echo ${DATA}
+else
+ echo "Removed include files not found"
+ exit 1
+fi
diff --git a/tools/ci/jobs/deheaderok.sh b/tools/ci/jobs/deheaderok.sh
new file mode 100755
index 0000000..eaac93c
--- /dev/null
+++ b/tools/ci/jobs/deheaderok.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+export LOGFILE=deheader.log
+export LOGFILE2=deheader2.log
+
+export DATA=$(cat ${LOGFILE})
+if [[ -z "${DATA}" ]]; then
+ echo "Empty output. Probably wrong search flags."
+ exit 1
+fi
+
+export DATA=$(grep "error:" ${LOGFILE})
+if [[ -n "${DATA}" ]]; then
+ echo "Compilation error found"
+ exit 1
+fi
+
+grep "deheader:" ${LOGFILE} \
+| grep -v "deheader: remove <climits> from ./src/being/localplayer.cpp" \
+| grep -v "deheader: remove <fstream> from ./src/utils/files.cpp" \
+| grep -v "deheader: remove <climits> from ./src/resources/map/map.cpp" \
+| grep -v "deheader: remove <sys/time.h> from ./src/resources/wallpaper.cpp" \
+| grep -v "deheader: remove <climits> from ./src/units.cpp" > ${LOGFILE2}
+
+export DATA=$(cat ${LOGFILE2})
+if [[ -n "${DATA}" ]]; then
+ echo "Wrong include files found"
+ echo ${DATA}
+ exit 1
+fi
diff --git a/tools/ci/samples/include1.h b/tools/ci/samples/include1.h
new file mode 100644
index 0000000..f8223b0
--- /dev/null
+++ b/tools/ci/samples/include1.h
@@ -0,0 +1,6 @@
+#ifndef INCLUDE1
+#define INCLUDE1
+
+void function2();
+
+#endif // INCLUDE1 \ No newline at end of file
diff --git a/tools/ci/samples/test1.cpp b/tools/ci/samples/test1.cpp
new file mode 100644
index 0000000..074a33c
--- /dev/null
+++ b/tools/ci/samples/test1.cpp
@@ -0,0 +1,6 @@
+#include "test1.h"
+
+int function1()
+{
+ return 0;
+}
diff --git a/tools/ci/samples/test1.h b/tools/ci/samples/test1.h
new file mode 100644
index 0000000..cc8042e
--- /dev/null
+++ b/tools/ci/samples/test1.h
@@ -0,0 +1,6 @@
+#ifndef TEST1
+#define TEST1
+
+int function1();
+
+#endif // TEST1 \ No newline at end of file
diff --git a/tools/ci/samples/test2.cpp b/tools/ci/samples/test2.cpp
new file mode 100644
index 0000000..eda7000
--- /dev/null
+++ b/tools/ci/samples/test2.cpp
@@ -0,0 +1,8 @@
+#include "test2.h"
+
+#include "include1.h"
+
+int function1()
+{
+ return 0;
+}
diff --git a/tools/ci/samples/test2.h b/tools/ci/samples/test2.h
new file mode 100644
index 0000000..4cc2335
--- /dev/null
+++ b/tools/ci/samples/test2.h
@@ -0,0 +1,6 @@
+#ifndef TEST2
+#define TEST2
+
+int function1();
+
+#endif // TEST2 \ No newline at end of file
diff --git a/tools/ci/samples/test3.cpp b/tools/ci/samples/test3.cpp
new file mode 100644
index 0000000..264693e
--- /dev/null
+++ b/tools/ci/samples/test3.cpp
@@ -0,0 +1,10 @@
+#include "test3.h"
+
+#ifndef QQQ
+#include "include1.h"
+#endif // QQQ
+
+int function1()
+{
+ return 0;
+}
diff --git a/tools/ci/samples/test3.h b/tools/ci/samples/test3.h
new file mode 100644
index 0000000..4cc2335
--- /dev/null
+++ b/tools/ci/samples/test3.h
@@ -0,0 +1,6 @@
+#ifndef TEST2
+#define TEST2
+
+int function1();
+
+#endif // TEST2 \ No newline at end of file
diff --git a/tools/ci/scripts/init.sh b/tools/ci/scripts/init.sh
new file mode 100755
index 0000000..a1a22f9
--- /dev/null
+++ b/tools/ci/scripts/init.sh
@@ -0,0 +1,213 @@
+#!/bin/bash
+
+pwd
+mkdir logs
+
+export dir=$(pwd)
+export ERRFILE=${dir}/logs/${LOGFILE}
+
+cat /etc/os-release
+
+rm ${ERRFILE}
+
+function do_init {
+ $CC --version
+ check_error $?
+ $CXX --version
+ check_error $?
+}
+
+function aptget_update {
+ echo "apt-get update"
+ apt-get update
+ if [ "$?" != 0 ]; then
+ sleep 1s
+ apt-get update
+ if [ "$?" != 0 ]; then
+ sleep 2s
+ apt-get update
+ if [ "$?" != 0 ]; then
+ sleep 5s
+ apt-get update
+ if [ "$?" != 0 ]; then
+ sleep 10s
+ apt-get update
+ if [ "$?" != 0 ]; then
+ sleep 15s
+ apt-get update
+ fi
+ fi
+ fi
+ fi
+ fi
+}
+
+function aptget_install {
+ echo "apt-get -y -qq install $*"
+ apt-get -y -qq install $*
+ if [ "$?" != 0 ]; then
+ sleep 1s
+ apt-get -y -qq install $*
+ if [ "$?" != 0 ]; then
+ sleep 2s
+ apt-get -y -qq install $*
+ if [ "$?" != 0 ]; then
+ sleep 5s
+ apt-get -y -qq install $*
+ if [ "$?" != 0 ]; then
+ sleep 10s
+ apt-get -y -qq install $*
+ if [ "$?" != 0 ]; then
+ sleep 15s
+ apt-get -y -qq install $*
+ fi
+ fi
+ fi
+ fi
+ fi
+}
+
+function gitclone {
+ git clone $*
+ if [ "$?" != 0 ]; then
+ sleep 1s
+ git clone $*
+ if [ "$?" != 0 ]; then
+ sleep 3s
+ git clone $*
+ if [ "$?" != 0 ]; then
+ sleep 5s
+ git clone $*
+ if [ "$?" != 0 ]; then
+ sleep 10s
+ git clone $*
+ if [ "$?" != 0 ]; then
+ sleep 15s
+ git clone $*
+ if [ "$?" != 0 ]; then
+ sleep 20s
+ git clone $*
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ check_error $?
+}
+
+function check_error {
+ if [ "$1" != 0 ]; then
+ cat $ERRFILE
+ exit $1
+ fi
+}
+
+function run_configure_simple {
+ rm $ERRFILE
+ echo "autoreconf -i"
+ autoreconf -i 2>$ERRFILE
+ check_error $?
+ rm $ERRFILE
+ echo "./configure $*"
+ ./configure $* 2>$ERRFILE
+ check_error $?
+}
+
+function run_configure {
+ run_configure_simple $*
+
+ rm $ERRFILE
+ cd po
+ echo "make update-gmo"
+ make update-gmo 2>$ERRFILE
+ check_error $?
+ cd ..
+
+ rm $ERRFILE
+ cd po
+ echo "make update-po"
+ make update-po 2>$ERRFILE
+ check_error $?
+ cd ..
+}
+
+function run_cmake {
+ rm $ERRFILE
+ echo "cmake ."
+ cmake . 2>$ERRFILE
+ check_error $?
+}
+
+function run_make {
+ rm $ERRFILE
+ echo "make -j2 V=0 $*"
+ make -j2 V=0 $* 2>$ERRFILE
+ check_error $?
+}
+
+function run_make_check {
+ rm $ERRFILE
+ echo "make -j2 V=0 check $*"
+ make -j2 V=0 check $* 2>$ERRFILE
+ export ERR=$?
+ if [ "${ERR}" != 0 ]; then
+ cat $ERRFILE
+ cat src/manaplustests.log
+ exit ${ERR}
+ fi
+ valgrind -q --read-var-info=yes --track-origins=yes --malloc-fill=11 --free-fill=55 --show-reachable=yes --leak-check=full --leak-resolution=high --partial-loads-ok=yes --error-limit=no ./src/manaplustests 2>valg.log
+ export DATA=$(grep "invalid" valg.log)
+ if [ "$DATA" != "" ];
+ then
+ cat valg.log
+ echo "valgrind error"
+ exit 1
+ fi
+ cat valg.log
+ echo "valgrind check"
+}
+
+function run_check_warnings {
+ DATA=$(cat $ERRFILE)
+ if [ "$DATA" != "" ];
+ then
+ cat $ERRFILE
+ exit 1
+ fi
+}
+
+function run_h {
+ rm $ERRFILE
+ echo "$CC -c -x c++ $* $includes */*/*/*.h */*/*.h */*.h *.h"
+ $CC -c -x c++ $* $includes */*/*/*.h */*/*.h */*.h *.h 2>$ERRFILE
+ DATA=$(cat $ERRFILE)
+ if [ "$DATA" != "" ];
+ then
+ cat $ERRFILE
+ exit 1
+ fi
+}
+
+function run_tarball {
+ rm $ERRFILE
+ echo "make dist-xz"
+ make dist-xz 2>$ERRFILE
+ check_error $?
+
+ mkdir $1
+ cd $1
+ echo "tar xf ../*.tar.xz"
+ tar xf ../*.tar.xz
+ cd manaplus*
+}
+
+function run_mplint {
+ rm $ERRFILE
+ echo "mplint/src/mplint $*"
+ mplint/src/mplint $* >$ERRFILE
+ check_error $?
+ run_check_warnings
+}
+
+#aptget_update