]> sourceware.org Git - lvm2.git/commitdiff
test: Add prepare_lvmdbusd
authorMarian Csontos <mcsontos@redhat.com>
Tue, 1 Mar 2016 10:49:05 +0000 (11:49 +0100)
committerMarian Csontos <mcsontos@redhat.com>
Wed, 9 Mar 2016 09:58:21 +0000 (10:58 +0100)
- Check for running lvmdbusd at start
- Add teardown for lvmdbusd

test/api/dbustest.sh
test/lib/aux.sh

index ba3173e928209c817d588b6de59e4a286b489818..0ef9a95840a0ef42e5fbe94df7cceed92710d6fb 100644 (file)
@@ -30,6 +30,13 @@ fi
 # Setup the python path so we can run
 export PYTHONPATH=$abs_top_builddir/daemons
 
+if true; then
+
+aux prepare_lvmdbusd
+$abs_top_builddir/test/dbus/lvmdbustest.py -v
+
+else
+
 # Start the dbus service
 $abs_top_builddir/daemons/lvmdbusd/lvmdbusd --debug --udev > debug.log_lvmdbusd 2>&1 &
 
@@ -39,9 +46,10 @@ sleep 1
 
 LVM_DBUS_PID=$(ps aux | grep lvmdbus[d] |  awk '{print $2}')
 if [ "CHK${LVM_DBUS_PID}" == "CHK" ];then
-       echo "Failed to start lsmdbusd daemon"
+       echo "Failed to start lvmdbusd daemon"
        exit 1
 fi
+END
 
 # Run all the unit tests
 $abs_top_builddir/test/dbus/lvmdbustest.py -v || fail=$?
@@ -57,3 +65,5 @@ kill $LVM_DBUS_PID || {
 wait
 
 exit ${fail:-"0"}
+
+fi
index 021eb8155e94856cbb07dd26ba59669aa7a57f46..af6b25a459b82aeb23f0cbe28f2151cec515f571 100644 (file)
@@ -300,6 +300,42 @@ lvmpolld_dump() {
        (echo 'request="dump"'; echo '##') | lvmpolld_talk "$@"
 }
 
+prepare_lvmdbusd() {
+       rm -f debug.log_LVMDBUSD_out
+
+       echo "checking lvmdbusd is NOT running..."
+       if ps -elf | grep lvmdbusd | grep python3; then
+               echo "Cannot run while existing lvmdbusd process exists"
+               return 1
+       fi
+       echo ok
+
+       # skip if we don't have our own lvmdbusd...
+        # TODO: lvmdbusd is not in PATH
+       #(which lvmdbusd 2>/dev/null | grep "$abs_builddir") || skip
+       [[ -x $abs_top_builddir/daemons/lvmdbusd/lvmdbusd ]] || skip
+
+       kill_sleep_kill_ LOCAL_LVMDBUSD 0
+
+       echo "preparing lvmdbusd..."
+       $abs_top_builddir/daemons/lvmdbusd/lvmdbusd --debug --udev > debug.log_LVMDBUSD_out 2>&1 &
+       local pid=$!
+
+       sleep 1
+       echo "checking lvmdbusd IS running..."
+       if ! ps -elf | grep lvmdbusd | grep python3; then
+               echo "Failed to start lvmdbusd daemon"
+               return 1
+       fi
+       # TODO: Is there a better check than wait 1 second and check pid?
+       if ! ps -p $pid -o comm= >/dev/null || [[ $(ps -p $pid -o comm=) != python3 ]]; then
+               echo "Failed to start lvmdbusd daemon"
+               return 1
+       fi
+       echo $pid > LOCAL_LVMDBUSD
+       echo ok
+}
+
 teardown_devs_prefixed() {
        local prefix=$1
        local stray=${2:-0}
@@ -464,6 +500,10 @@ teardown() {
                fi
        }
 
+       kill_sleep_kill_ LOCAL_LVMDBUSD 0
+
+       echo -n .
+
        kill_sleep_kill_ LOCAL_LVMPOLLD ${LVM_VALGRIND_LVMPOLLD:-0}
 
        echo -n .
This page took 0.044603 seconds and 5 git commands to generate.