]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - test/run-stp-tests.sh
Fix test suite with shared libraries on macOS.
[thirdparty/cups.git] / test / run-stp-tests.sh
index ae902972330b7705c18a61e3fee0602d73000749..74157129cf5f6b6183b1ea36d3f8dc6d19128c51 100755 (executable)
@@ -520,6 +520,7 @@ AccessLog $BASE/log/access_log
 ErrorLog $BASE/log/error_log
 PageLog $BASE/log/page_log
 
+PassEnv DYLD_INSERT_LIBRARIES
 PassEnv DYLD_LIBRARY_PATH
 PassEnv LD_LIBRARY_PATH
 PassEnv LD_PRELOAD
@@ -563,7 +564,7 @@ else
 fi
 
 #
-# Setup the paths...
+# Create a helper script to run programs with...
 #
 
 echo "Setting up environment variables for test..."
@@ -574,13 +575,10 @@ else
        LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/ppdc:$LD_LIBRARY_PATH"
 fi
 
-export LD_LIBRARY_PATH
-
 LD_PRELOAD="$root/cups/libcups.so.2:$root/cups/libcupsimage.so.2:$root/cgi-bin/libcupscgi.so.1:$root/scheduler/libcupsmime.so.1:$root/ppdc/libcupsppdc.so.1"
 if test `uname` = SunOS -a -r /usr/lib/libCrun.so.1; then
        LD_PRELOAD="/usr/lib/libCrun.so.1:$LD_PRELOAD"
 fi
-export LD_PRELOAD
 
 if test -f $root/cups/libcups.2.dylib; then
         if test "x$DYLD_INSERT_LIBRARIES" = x; then
@@ -588,8 +586,6 @@ if test -f $root/cups/libcups.2.dylib; then
         else
                 DYLD_INSERT_LIBRARIES="$root/cups/libcups.2.dylib:$root/cups/libcupsimage.2.dylib:$root/cgi-bin/libcupscgi.1.dylib:$root/scheduler/libcupsmime.1.dylib:$root/ppdc/libcupsppdc.1.dylib:$DYLD_INSERT_LIBRARIES"
         fi
-
-        export DYLD_INSERT_LIBRARIES
 fi
 
 if test "x$DYLD_LIBRARY_PATH" = x; then
@@ -598,23 +594,51 @@ else
        DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/ppdc:$DYLD_LIBRARY_PATH"
 fi
 
-export DYLD_LIBRARY_PATH
-
 if test "x$SHLIB_PATH" = x; then
        SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/ppdc"
 else
        SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/ppdc:$SHLIB_PATH"
 fi
 
-export SHLIB_PATH
-
+# These get exported because they don't have side-effects...
 CUPS_DISABLE_APPLE_DEFAULT=yes; export CUPS_DISABLE_APPLE_DEFAULT
 CUPS_SERVER=localhost:$port; export CUPS_SERVER
 CUPS_SERVERROOT=$BASE; export CUPS_SERVERROOT
 CUPS_STATEDIR=$BASE; export CUPS_STATEDIR
 CUPS_DATADIR=$BASE/share; export CUPS_DATADIR
+IPP_PORT=$port; export IPP_PORT
 LOCALEDIR=$BASE/share/locale; export LOCALEDIR
 
+echo "Creating wrapper script..."
+
+runcups="$BASE/runcups"; export runcups
+
+echo "#!/bin/sh" >$runcups
+echo "# Helper script for running CUPS test instance." >>$runcups
+echo "" >>$runcups
+echo "# Set required environment variables..." >>$runcups
+echo "CUPS_DATADIR=\"$CUPS_DATADIR\"; export CUPS_DATADIR" >>$runcups
+echo "CUPS_SERVER=\"$CUPS_SERVER\"; export CUPS_SERVER" >>$runcups
+echo "CUPS_SERVERROOT=\"$CUPS_SERVERROOT\"; export CUPS_SERVERROOT" >>$runcups
+echo "CUPS_STATEDIR=\"$CUPS_STATEDIR\"; export CUPS_STATEDIR" >>$runcups
+echo "DYLD_INSERT_LIBRARIES=\"$DYLD_INSERT_LIBRARIES\"; export DYLD_INSERT_LIBRARIES" >>$runcups
+echo "DYLD_LIBRARY_PATH=\"$DYLD_LIBRARY_PATH\"; export DYLD_LIBRARY_PATH" >>$runcups
+# IPP_PORT=$port; export IPP_PORT
+echo "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"; export LD_LIBRARY_PATH" >>$runcups
+echo "LD_PRELOAD=\"$LD_PRELOAD\"; export LD_PRELOAD" >>$runcups
+echo "LOCALEDIR=\"$LOCALEDIR\"; export LOCALEDIR" >>$runcups
+echo "SHLIB_PATH=\"$SHLIB_PATH\"; export SHLIB_PATH" >>$runcups
+if test "x$CUPS_DEBUG_LEVEL" != x; then
+       echo "CUPS_DEBUG_FILTER='$CUPS_DEBUG_FILTER'; export CUPS_DEBUG_FILTER" >>$runcups
+       echo "CUPS_DEBUG_LEVEL=$CUPS_DEBUG_LEVEL; export CUPS_DEBUG_LEVEL" >>$runcups
+       echo "CUPS_DEBUG_LOG='$CUPS_DEBUG_LOG'; export CUPS_DEBUG_LOG" >>$runcups
+fi
+echo "" >>$runcups
+echo "# Run command..." >>$runcups
+echo "exec \"\$@\"" >>$runcups
+
+chmod +x $runcups
+
 #
 # Set a new home directory to avoid getting user options mixed in...
 #
@@ -637,7 +661,7 @@ export LC_MESSAGES
 #
 
 echo "Starting scheduler:"
-echo "    $VALGRIND ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &"
+echo "    $runcups $VALGRIND ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &"
 echo ""
 
 if test `uname` = Darwin -a "x$VALGRIND" = x; then
@@ -647,9 +671,9 @@ if test `uname` = Darwin -a "x$VALGRIND" = x; then
                 insert="/usr/lib/libgmalloc.dylib:$DYLD_INSERT_LIBRARIES"
         fi
 
-       DYLD_INSERT_LIBRARIES="$insert" MallocStackLogging=1 ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &
+       DYLD_INSERT_LIBRARIES="$insert" MallocStackLogging=1 $runcups ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &
 else
-       $VALGRIND ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &
+       $runcups $VALGRIND ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &
 fi
 
 cupsd=$!
@@ -659,33 +683,6 @@ if test "x$testtype" = x0; then
        echo "Scheduler is PID $cupsd and is listening on port $port."
        echo ""
 
-       # Create a helper script to run programs with...
-       runcups="$BASE/runcups"
-
-       echo "#!/bin/sh" >$runcups
-       echo "# Helper script for running CUPS test instance." >>$runcups
-       echo "" >>$runcups
-       echo "# Set required environment variables..." >>$runcups
-       echo "CUPS_DATADIR=\"$CUPS_DATADIR\"; export CUPS_DATADIR" >>$runcups
-       echo "CUPS_SERVER=\"$CUPS_SERVER\"; export CUPS_SERVER" >>$runcups
-       echo "CUPS_SERVERROOT=\"$CUPS_SERVERROOT\"; export CUPS_SERVERROOT" >>$runcups
-       echo "CUPS_STATEDIR=\"$CUPS_STATEDIR\"; export CUPS_STATEDIR" >>$runcups
-       echo "DYLD_LIBRARY_PATH=\"$DYLD_LIBRARY_PATH\"; export DYLD_LIBRARY_PATH" >>$runcups
-       echo "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"; export LD_LIBRARY_PATH" >>$runcups
-       echo "LD_PRELOAD=\"$LD_PRELOAD\"; export LD_PRELOAD" >>$runcups
-       echo "LOCALEDIR=\"$LOCALEDIR\"; export LOCALEDIR" >>$runcups
-       echo "SHLIB_PATH=\"$SHLIB_PATH\"; export SHLIB_PATH" >>$runcups
-       if test "x$CUPS_DEBUG_LEVEL" != x; then
-               echo "CUPS_DEBUG_FILTER='$CUPS_DEBUG_FILTER'; export CUPS_DEBUG_FILTER" >>$runcups
-               echo "CUPS_DEBUG_LEVEL=$CUPS_DEBUG_LEVEL; export CUPS_DEBUG_LEVEL" >>$runcups
-               echo "CUPS_DEBUG_LOG='$CUPS_DEBUG_LOG'; export CUPS_DEBUG_LOG" >>$runcups
-       fi
-       echo "" >>$runcups
-       echo "# Run command..." >>$runcups
-       echo "exec \"\$@\"" >>$runcups
-
-       chmod +x $runcups
-
        echo "The $runcups helper script can be used to test programs"
        echo "with the server."
        exit 0
@@ -701,10 +698,8 @@ else
        sleep 2
 fi
 
-IPP_PORT=$port; export IPP_PORT
-
 while true; do
-       running=`../systemv/lpstat -r 2>/dev/null`
+       running=`$runcups ../systemv/lpstat -r 2>/dev/null`
        if test "x$running" = "xscheduler is running"; then
                break
        fi
@@ -741,6 +736,7 @@ fail=0
 for file in 4*.test ipp-2.1.test; do
        echo $ac_n "Performing $file: $ac_c"
        echo "" >>$strfile
+        echo $ac_n "`date '+[%d/%b/%Y:%H:%M:%S %z]'` $ac_c" >>$strfile
 
        if test $file = ipp-2.1.test; then
                uri="ipp://localhost:$port/printers/Test1"
@@ -749,7 +745,7 @@ for file in 4*.test ipp-2.1.test; do
                uri="ipp://localhost:$port/printers"
                options=""
        fi
-       $VALGRIND ./ipptool -tI $options $uri $file >> $strfile
+       $runcups $VALGRIND ./ipptool -tI $options $uri $file >> $strfile
        status=$?
 
        if test $status != 0; then
@@ -778,7 +774,7 @@ echo "    <pre>" >>$strfile
 for file in 5*.sh; do
        echo $ac_n "Performing $file: $ac_c"
        echo "" >>$strfile
-       echo "\"$file\":" >>$strfile
+        echo "`date '+[%d/%b/%Y:%H:%M:%S %z]'` \"$file\":" >>$strfile
 
        sh $file $pjobs $pprinters >> $strfile
        status=$?
@@ -805,20 +801,20 @@ fi
 
 echo $ac_n "Performing restart test: $ac_c"
 echo "" >>$strfile
-echo "\"5.10-restart\":" >>$strfile
+echo "`date '+[%d/%b/%Y:%H:%M:%S %z]'` \"5.10-restart\":" >>$strfile
 
 kill -HUP $cupsd
 
 while true; do
        sleep 10
 
-       running=`../systemv/lpstat -r 2>/dev/null`
+       running=`$runcups ../systemv/lpstat -r 2>/dev/null`
        if test "x$running" = "xscheduler is running"; then
                break
        fi
 done
 
-description="`../systemv/lpstat -l -p Test1 | grep Description | sed -e '1,$s/^[^:]*: //g'`"
+description="`$runcups ../systemv/lpstat -l -p Test1 | grep Description | sed -e '1,$s/^[^:]*: //g'`"
 if test "x$description" != "xTest Printer 1"; then
        echo "Failed, printer-info for Test1 is '$description', expected 'Test Printer 1'." >>$strfile
        echo "FAIL (got '$description', expected 'Test Printer 1')"