completely removed libt2n-examples again. examples and build script are now in libt2n
authorJens Thiele <jens.thiele@intra2net.com>
Wed, 20 Dec 2006 16:24:48 +0000 (16:24 +0000)
committerJens Thiele <jens.thiele@intra2net.com>
Wed, 20 Dec 2006 16:24:48 +0000 (16:24 +0000)
test-build-install-use [new file with mode: 0755]

diff --git a/test-build-install-use b/test-build-install-use
new file mode 100755 (executable)
index 0000000..2d281a4
--- /dev/null
@@ -0,0 +1,98 @@
+#!/bin/bash -x
+set -o errexit
+set -o nounset
+
+# where is the source? (todo: we could checkout from svn)
+
+LIBT2NSRC="$PWD"
+LIBT2N_EXAMPLES="$PWD/examples-codegen"
+EXAMPLES=2
+
+# general settings
+
+# todo: safe temp dir creation
+INSTDIR="/tmp/jens-delme"
+BUILDDIR="$INSTDIR/build"
+mkdir "$INSTDIR"
+mkdir "$BUILDDIR"
+INSTPREFIX="$INSTDIR/usr"
+MAKE="dmake"
+DOCLEAN="false"
+
+function prepend() {
+       if [ "x$1" = "x" ]; then
+               echo "$2"
+       else
+               echo "$2:$1"
+       fi
+}
+
+function build() {
+    autoreconf -f -i $@
+    ./configure --prefix="$INSTPREFIX"
+    if $DOCLEAN; then
+       $MAKE distclean
+       ./configure --prefix="$INSTPREFIX"
+       $MAKE clean
+       # ensure make clean works twice (did not work at some point)
+       $MAKE clean
+
+       # todo: at the moment distcheck does not work on a distclean source
+       $MAKE
+       $MAKE clean
+       $MAKE distcheck
+    else
+       $MAKE dist
+    fi
+
+    $MAKE install
+}
+
+# 1. build and install lib and codegen
+cd "$LIBT2NSRC"
+build
+echo "OK: library and code generator compiled and installed"
+
+# prepare environment to use installed libt2n and code generator in non-standard directory
+# temporarily disable nounset
+
+set +o nounset
+export PATH=$(prepend "$PATH" "$INSTPREFIX/bin")
+export LD_LIBRARY_PATH=$(prepend "$LD_LIBRARY_PATH" "$INSTPREFIX/lib")
+export PKG_CONFIG_PATH=$(prepend "$PKG_CONFIG_PATH" "$INSTPREFIX/lib/pkgconfig")
+set -o nounset
+
+for EXAMPLE in $(seq 1 $EXAMPLES); do
+
+    # 2. build example
+
+    cp -af "$LIBT2N_EXAMPLES/example$EXAMPLE" "$BUILDDIR"
+    cd "$BUILDDIR/example$EXAMPLE"
+    build -M "$INSTPREFIX/share/aclocal"
+    echo "OK: example $EXAMPLE using installed libt2n works"
+
+    # 3. compile client using the now installed default lib
+    cp -af "$LIBT2N_EXAMPLES/example$EXAMPLE-client" "$BUILDDIR"
+    cd "$BUILDDIR/example$EXAMPLE-client"
+    build -M "$INSTPREFIX/share/aclocal"
+    echo "OK: example $EXAMPLE using installed example lib works"
+
+    # 4. test installed server and client
+    libt2n-example$EXAMPLE-server &
+    SPID="$!"
+    # ugly
+    sleep 1
+    if libt2n-example$EXAMPLE-client; then
+       echo "installed client and server work"
+       RET="0"
+    else
+       echo "installed client and server don't work"
+       RET="1"
+    fi
+    kill "$SPID"
+    if [ "$RET" = "1" ]; then
+       exit 1
+    fi
+done
+
+echo Everything is fine