Browse Source

- really small framework for 'smoke tests' for openser, to test basic
functionality of server and some tools after a build
- add a 'make test' case to the main Makefile


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3066 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt 18 years ago
commit
abe2ee2f98
7 changed files with 191 additions and 0 deletions
  1. 17 0
      test/unit/1.sh
  2. 67 0
      test/unit/2.cfg
  3. 19 0
      test/unit/2.sh
  4. 35 0
      test/unit/3.sh
  5. 27 0
      test/unit/4.sh
  6. 15 0
      test/unit/Makefile
  7. 11 0
      test/unit/README

+ 17 - 0
test/unit/1.sh

@@ -0,0 +1,17 @@
+#!/bin/bash
+# load a minimal config
+
+CFG=1.cfg
+
+# setup config
+echo -e "debug=3" > $CFG
+
+../openser -f $CFG > /dev/null
+ret=$?
+
+sleep 1
+killall -9 openser
+
+rm -f $CFG
+
+exit $ret

+ 67 - 0
test/unit/2.cfg

@@ -0,0 +1,67 @@
+mpath="../modules"
+loadmodule "tm/tm.so"
+loadmodule "acc/acc.so"
+loadmodule "alias_db/alias_db.so"
+loadmodule "auth/auth.so"
+loadmodule "auth_db/auth_db.so"
+loadmodule "avpops/avpops.so"
+loadmodule "benchmark/benchmark.so"
+loadmodule "cfgutils/cfgutils.so"
+loadmodule "dbtext/dbtext.so"
+loadmodule "dialog/dialog.so"
+loadmodule "dispatcher/dispatcher.so"
+loadmodule "diversion/diversion.so"
+loadmodule "domain/domain.so"
+loadmodule "domainpolicy/domainpolicy.so"
+loadmodule "enum/enum.so"
+loadmodule "exec/exec.so"
+loadmodule "flatstore/flatstore.so"
+loadmodule "gflags/gflags.so"
+loadmodule "group/group.so"
+loadmodule "imc/imc.so"
+loadmodule "lcr/lcr.so"
+loadmodule "mangler/mangler.so"
+loadmodule "maxfwd/maxfwd.so"
+loadmodule "mi_datagram/mi_datagram.so"
+loadmodule "mi_fifo/mi_fifo.so"
+loadmodule "msilo/msilo.so"
+loadmodule "mysql/mysql.so"
+loadmodule "nathelper/nathelper.so"
+loadmodule "options/options.so"
+loadmodule "path/path.so"
+loadmodule "pike/pike.so"
+loadmodule "rr/rr.so"
+loadmodule "seas/seas.so"
+loadmodule "siptrace/siptrace.so"
+loadmodule "sl/sl.so"
+loadmodule "sms/sms.so"
+loadmodule "speeddial/speeddial.so"
+loadmodule "sst/sst.so"
+loadmodule "statistics/statistics.so"
+loadmodule "textops/textops.so"
+loadmodule "uac/uac.so"
+loadmodule "uac_redirect/uac_redirect.so"
+loadmodule "uri/uri.so"
+loadmodule "uri_db/uri_db.so"
+loadmodule "usrloc/usrloc.so"
+loadmodule "registrar/registrar.so"
+loadmodule "permissions/permissions.so"
+loadmodule "pdt/pdt.so"
+loadmodule "mediaproxy/mediaproxy.so"
+loadmodule "xlog/xlog.so"
+
+modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")
+modparam("mi_datagram", "socket_name", "/tmp/openser.sock")
+modparam("dialog", "dlg_flag", 10)
+modparam("dispatcher", "list_file", "/home/henning/projects/openser/openser/test/dispatcher.list")
+modparam("lcr", "contact_avp", "$avp(i:711)")
+modparam("lcr|tm", "fr_inv_timer_avp", "$avp(i:704)")
+modparam("lcr", "gw_uri_avp", "$avp(i:709)")
+modparam("lcr", "ruri_user_avp", "$avp(i:500)")
+modparam("^auth$|lcr", "rpid_avp", "$avp(i:302)")
+modparam("lcr", "dm_flag", 25)
+modparam("sms", "modems", "Nokia [d=/dev/ttyS1;b=9600;m=new;l=30] ")
+modparam("sms", "networks", "D1 [m=10] ;d2[ m=20]")
+modparam("sms", "links", "NOKIA[D1;d2]")
+modparam("sst", "sst_flag", 6)
+modparam("usrloc", "nat_bflag", 15)

+ 19 - 0
test/unit/2.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+# load all modules without external dependencies
+
+# Needs a default openser database setup for mysql
+
+CFG=2.cfg
+
+echo "" > dispatcher.list
+
+# start
+../openser -f $CFG > /dev/null
+ret=$?
+
+sleep 1
+killall -9 openser
+
+rm -f dispatcher.list
+
+exit $ret

+ 35 - 0
test/unit/3.sh

@@ -0,0 +1,35 @@
+#!/bin/bash
+# creates a database with openserdbctl and deletes it again
+
+# Needs a mysql database, the root user password must be given
+
+tmp_name=""$RANDOM"_openserdb_tmp"
+
+cd ../scripts
+
+# setup config file
+cp openserctlrc openserctlrc.bak
+sed -i "s/# SIP_DOMAIN=openser.org/SIP_DOMAIN=sip.localhost/g" openserctlrc
+sed -i "s/# DBENGINE=MYSQL/DBENGINE=MYSQL/g" openserctlrc
+sed -i "s/# INSTALL_EXTRA_TABLES=ask/INSTALL_EXTRA_TABLES=yes/g" openserctlrc
+sed -i "s/# INSTALL_PRESENCE_TABLES=ask/INSTALL_PRESENCE_TABLES=yes/g" openserctlrc
+sed -i "s/# INSTALL_SERWEB_TABLES=ask/INSTALL_SERWEB_TABLES=yes/g" openserctlrc
+
+# set the mysql root password
+cp openserdbctl.mysql openserdbctl.mysql.bak
+sed -i "s/#PW=""/PW=""/g" openserdbctl.mysql
+
+./openserdbctl create $tmp_name #> /dev/null
+ret=$?
+
+if [ "$ret" -eq 0 ] ; then
+	./openserdbctl drop $tmp_name #> /dev/null
+	ret=$?
+fi ;
+
+# cleanup
+mv openserctlrc.bak openserctlrc
+cp openserdbctl.mysql.bak openserdbctl.mysql
+
+cd ../test
+exit $ret

+ 27 - 0
test/unit/4.sh

@@ -0,0 +1,27 @@
+#!/bin/bash
+# test basic fifo functionality
+
+CFG=4.cfg
+
+# setup config
+echo -e "loadmodule \"../modules/mi_fifo/mi_fifo.so\"" > $CFG
+echo -e "modparam(\"mi_fifo\", \"fifo_name\", \"/tmp/openser_fifo\")" >> $CFG
+
+../openser -f $CFG > /dev/null
+ret=$?
+
+cd ../scripts
+
+if [ "$ret" -eq 0 ] ; then
+	sleep 1
+	./openserctl ps > /dev/null
+	ret=$?
+fi ;
+
+cd ../test
+
+killall -9 openser
+
+rm -f $CFG
+
+exit $ret

+ 15 - 0
test/unit/Makefile

@@ -0,0 +1,15 @@
+all:
+	-@for FILE in $(wildcard *.sh) ; do \
+		if [ -f $$FILE ] ; then \
+			if [ -x $$FILE ] ; then \
+				echo "run test:" `head "$$FILE" -n 2 | tail -n 1 | cut -c 3-` ; \
+				./$$FILE ; \
+				ret=$$? ; \
+					if [ "$$ret" -eq 0 ] ; then \
+						echo "success" ; \
+					else \
+						echo "failed" ; \
+					fi ; \
+			fi ; \
+		fi ; \
+	done ;

+ 11 - 0
test/unit/README

@@ -0,0 +1,11 @@
+This directory contains some small "smoke tests", that should assure that
+basic functionality of the server work as required. This tests should consists
+of one shell script and a config file if needed. They should not need much time
+for execution, to allow the run of the complete test suite in a few seconds.
+All test scripts must be self-contained, should not have external dependencies
+and must clean up after they are run. The second line in each scripts should
+contain a small comment that describe the task of the test, it should not
+output any messages on successful runs.
+
+
+