 contrib/sepgsql/test_sepgsql | 46 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/contrib/sepgsql/test_sepgsql b/contrib/sepgsql/test_sepgsql
index 8d1a35c..5d46600 100755
--- a/contrib/sepgsql/test_sepgsql
+++ b/contrib/sepgsql/test_sepgsql
@@ -14,6 +14,10 @@
 
 PG_BINDIR=`pg_config --bindir`
 
+# It must move to contrib/sepgsql directory to read sql commands and
+# write its results on the expected directory.
+cd `dirname $0`
+
 echo
 echo "============== checking selinux environment           =============="
 
@@ -133,7 +137,47 @@ if [ ! -e "${SELINUX_MNT}/booleans/sepgsql_regression_test_mode" ]; then
     echo ""
     exit 1
 fi
-echo "ok"
+EXPECTED_POLVER="1.07"
+REGTEST_POLVER="`sudo semodule -l | awk '/^sepgsql-regtest/ {print $2}'`"
+if [ -z "$REGTEST_POLVER" ]; then
+	echo "uncertain"
+	echo
+	echo "The 'sepgsql-regtest' policy module version ${EXPECTED_POLVER} has"
+	echo "to be installed, however, it takes root privilege to confirm this."
+	echo "We expected sudo is configured on the current user, but it didn't"
+	echo "works well. If regression test generates some difference towards"
+	echo "expected one, please ensure the version of installed policy module."
+	echo
+    echo "To confirm that the policy package is installed, use this command:"
+    echo ""
+    echo "  \$ sudo semodule -l | grep sepgsql"
+    echo ""
+	echo "Expected result is:"
+	echo "  sepgsql-regtest ${EXPECTED_POLVER}"
+	echo
+elif [ "$REGTEST_POLVER" != "$EXPECTED_POLVER" ]; then
+	echo "failed"
+	echo
+	echo "The 'sepgsql-regtest' policy module version ${EXPECTED_POLVER} has"
+	echo "to be installed to run this regression test as expected,"
+	echo "but version ${REGTEST_POLVER} was installed here."
+    echo "You can install this module using the following commands:"
+    echo ""
+    echo "  \$ make -f /usr/share/selinux/devel/Makefile clean"
+    echo "  \$ make -f /usr/share/selinux/devel/Makefile"
+    echo "  \$ sudo semodule -u sepgsql-regtest.pp"
+    echo ""
+    echo "To confirm that the policy package is installed, use this command:"
+    echo ""
+    echo "  \$ sudo semodule -l | grep sepgsql"
+    echo ""
+	echo "Expected result is:"
+	echo "  sepgsql-regtest ${EXPECTED_POLVER}"
+	echo
+	exit 1
+else
+	echo "found version ${REGTEST_POLVER}"
+fi
 
 # Verify that sepgsql_regression_test_mode is active.
 echo -n "checking whether policy is enabled  ... "
