[Pkg-voip-commits] [asterisk] 04/04: test script to run test modules of asterisk

tzafrir at debian.org tzafrir at debian.org
Sat Dec 24 01:02:33 UTC 2016


This is an automated email from the git hooks/post-receive script.

tzafrir pushed a commit to branch test-enable
in repository asterisk.

commit e4856cfd2fbc225718ee691a6cc21288b93237b2
Author: Tzafrir Cohen <tzafrir at debian.org>
Date:   Sat Dec 24 03:00:05 2016 +0200

    test script to run test modules of asterisk
    
    FIXME: checks for FAILEd. Not for NOT RUN.
---
 debian/.gitignore                                 |  4 ++++
 debian/tests/asttestmods                          | 27 +++++++++++++++++++++++
 debian/tests/control                              |  3 +++
 debian/tests/testmods/asterisk                    | 14 ++++++++++++
 debian/tests/testmods/base-conf/http.conf         |  4 ++++
 debian/tests/testmods/base-conf/modules.conf      |  2 ++
 debian/tests/testmods/base-conf/sorcery.conf      |  9 ++++++++
 debian/tests/testmods/base-conf/test_sorcery.conf | 14 ++++++++++++
 8 files changed, 77 insertions(+)

diff --git a/debian/.gitignore b/debian/.gitignore
index f9c0add..c165d9c 100644
--- a/debian/.gitignore
+++ b/debian/.gitignore
@@ -21,4 +21,8 @@ autoreconf.after
 autoreconf.before
 debhelper-build-stamp
 files
+tests/testmods/asterisk.conf
+tests/testmods/conf/
+tests/testmods/output/
 tmp/
+
diff --git a/debian/tests/asttestmods b/debian/tests/asttestmods
new file mode 100755
index 0000000..b411dbd
--- /dev/null
+++ b/debian/tests/asttestmods
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+asterisk="testmods/asterisk"
+output_dir="$PWD/testmods/output" # Writable by Asterisk
+results_file="$output_dir/results.txt"
+
+service asterisk stop
+
+mkdir -p "$output_dir"
+chown asterisk "$output_dir"
+rm -rf testmods/conf
+cp -a testmods/base-conf testmods/conf
+$asterisk -U asterisk
+sleep 1
+$asterisk -rx 'core waitfullybooted'
+$asterisk -rx 'test execute all' 2>&1
+$asterisk -rx "test generate results txt $results_file"
+header=`cat "$results_file" | sed -e '/^$/,$d' `
+failed=`echo "$header" | awk '/^Passed/ {print $3}'`
+if [ "$failed" != '0' ]; then
+	echo >&2 "Some tests failed:"
+	echo >&2 "$header"
+	$asterisk -rx "test show results failed" >&2
+fi
+
+$asterisk -rx 'core stop now'
+service asterisk start
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..d3fcf0b
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,3 @@
+Tests: dummy, asttestmods
+Restrictions: needs-root, isolation-container
+Depends: asterisk, asterisk-tests, realpath
diff --git a/debian/tests/testmods/asterisk b/debian/tests/testmods/asterisk
new file mode 100755
index 0000000..28e799d
--- /dev/null
+++ b/debian/tests/testmods/asterisk
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Run Asterisk using the local configuration directory:
+
+dir=$(realpath `dirname $0`)
+ast_conf="$dir/asterisk.conf"
+if [ ! -r "$ast_conf" ]; then
+	(
+		echo "; File generated by $0"
+		echo "[directories]"
+		echo "astetcdir => $$dir/conf"
+	) > "$ast_conf"
+fi
+exec /usr/sbin/asterisk -C "$ast_conf" "$@"
diff --git a/debian/tests/testmods/base-conf/http.conf b/debian/tests/testmods/base-conf/http.conf
new file mode 100644
index 0000000..492cd60
--- /dev/null
+++ b/debian/tests/testmods/base-conf/http.conf
@@ -0,0 +1,4 @@
+[general]
+enabled=yes
+bindaddr=127.0.0.1
+
diff --git a/debian/tests/testmods/base-conf/modules.conf b/debian/tests/testmods/base-conf/modules.conf
new file mode 100644
index 0000000..6349491
--- /dev/null
+++ b/debian/tests/testmods/base-conf/modules.conf
@@ -0,0 +1,2 @@
+[modules]
+autoload = yes
diff --git a/debian/tests/testmods/base-conf/sorcery.conf b/debian/tests/testmods/base-conf/sorcery.conf
new file mode 100644
index 0000000..9de9693
--- /dev/null
+++ b/debian/tests/testmods/base-conf/sorcery.conf
@@ -0,0 +1,9 @@
+[test_sorcery_section]
+test=memory
+
+[test_sorcery_cache]
+test/cache=test
+test=memory
+
+[res_pjsip_pubsub]
+resource_list=memory
diff --git a/debian/tests/testmods/base-conf/test_sorcery.conf b/debian/tests/testmods/base-conf/test_sorcery.conf
new file mode 100644
index 0000000..c465dbf
--- /dev/null
+++ b/debian/tests/testmods/base-conf/test_sorcery.conf
@@ -0,0 +1,14 @@
+; This is a res_sorcery_config compatible file for the sorcery unit tests
+
+[hey]
+bob=98
+joe=41
+
+[hey2]
+type=zombies
+bob=97
+joe=40
+
+[hey3]
+bob=96
+joe=39

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/asterisk.git



More information about the Pkg-voip-commits mailing list