1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
  
     | 
    
      set test "xulrunner"
# Test sdt support in xulrunner.
global env
# deprecate as xulrunner is no longer supported
untested "$test test is deprecated"
return
if {! [info exists env(SYSTEMTAP_TESTAPPS)] || (
    ! [string match "xulrunner" $env(SYSTEMTAP_TESTAPPS)] &&
    ! [string match "all" $env(SYSTEMTAP_TESTAPPS)])} {
    untested "$test sdt app"
    return
}
########## Create /tmp/stap-xul.stp ########## 
set xulrelease "41.0.1"
set xuldir "[pwd]/xul/"
set testsuite "[pwd]"
set fp [open "$testsuite/stap-xul.stp" "w"]
puts $fp "
global funcinfo
global objinfo
probe process(@1).mark(\"function__info\")
{
  file = user_string (\$arg1)
  func = user_string (\$arg3)
  funcinfo\[file,func\] <<< 1
}
probe process(@1).mark(\"object__create\")
{
  file = user_string (\$arg1)
  class = user_string (\$arg2)
  objinfo\[file,class\] <<< 1
}
probe end
{
  foreach (\[i,j\] in funcinfo+)
  {
     printf (\"probes: %-20s %-25s %d\\n\", substr(i,strlen(i)-20,strlen(i)), j, @count(funcinfo\[i,j\]))
  }
  foreach (\[i,j\] in objinfo+)
  {
     printf (\"probes: %-20s %-25s %d\\n\", substr(i,strlen(i)-20,strlen(i)), j, @count(funcinfo\[i,j\]))
  }
}
"
close $fp
########## Begin /tmp/stap-xul.sh ########## 
set fp [open "$testsuite/stap-xul.sh" "w"]
puts $fp "
##### begin run_tests #####
function run_tests \{
cd $testsuite/xul/bld/js/src
pwd
for i in \$(find $xuldir/src/js/src/tests -mindepth 2 -name 'regress*' -prune \
	   -o -name 'shell.js' -prune -o \\( -name '*js' -print \\)) ; do
   $env(SYSTEMTAP_PATH)/stap -c \"./js -f $xuldir/src/js/src/tests/shell.js -f \$i\" \
   $testsuite/stap-xul.stp ./js
done | tee $testsuite/stap-xul-markers.log
PROBES=\$(grep 'probes: ' $testsuite/stap-xul-markers.log | wc -l)
TESTS=\$(grep '-FAIL' $testsuite/stap-xul-markers.log)
echo PROBES=\$PROBES TESTS=\$TESTS
if \[ \$PROBES -gt 400 \] ; then
   echo PASS: xulrunner javascript markers \$1
else
   echo FAIL: xulrunner javascript markers \$1
fi
if \[ -z \$TESTS \] ; then
   echo PASS: xulrunner javascript testsuite \$1
else
   echo FAIL: xulrunner javascript testsuite \$1
fi
\}
##### end run_tests #####
if \[ ! -r xulrunner-$xulrelease.source.tar.xz \] ; then
wget -q http://ftp.mozilla.org/pub/xulrunner/releases/$xulrelease/source/xulrunner-$xulrelease.source.tar.xz
# wget -q http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/latest/source/xulrunner-$xulrelease.source.tar.xz
fi
if \[ ! -r xulrunner-$xulrelease.source.tar.xz \] ; then
   echo UNTESTED: wget xulrunner-$xulrelease.source.tar.xz
   exit
fi
if \[ ! -d xul/src \] ; then
unxz xulrunner-$xulrelease.source.tar.xz
tar -x -f xulrunner-$xulrelease.source.tar
mkdir xul
mv mozilla-* xul/src
fi
if \[ ! -f xul/bld/js/src/js \] ; then
mkdir xul/bld
cd xul/bld
JAVA=`yum info available 'java*openjdk' |& awk '/Name/ {print \$3}'`
for P in glib-devel gtk+ ORBit-devel \$JAVA ; do 
    if rpm -q \$P ; then :
    else echo UNTESTED: Need to: dnf install \$P
         exit
    fi
done
JAVA_HOME=/usr/lib/jvm/\$JAVA.`uname -i` \
CXXFLAGS='-g -I$env(SYSTEMTAP_INCLUDES)' \
CFLAGS='-g -I$env(SYSTEMTAP_INCLUDES)' \
PATH=$env(SYSTEMTAP_PATH)/:\$PATH \
../src/configure --prefix=$xuldir --enable-dtrace \
--enable-application=xulrunner --disable-necko-wifi --disable-gconf \
--disable-dbus --disable-alsa --disable-pulseaudio --disable-webm --without-intl-api
if \[ \$\? -eq 0 \] ; then true ; else
   # configure failure possibly due to gtk+-2.0 requirement
   echo UNTESTED: xulrunner configure failed
   exit
fi
sed -i '/include.*rules.mk/a\\
ifdef HAVE_DTRACE\\
PROGOBJS += ../mozjs-dtrace.\$(OBJ_SUFFIX)\\
endif\\
' js/src/shell/Makefile
sed -i '/include.*rules.mk/a\\
ifdef HAVE_DTRACE\\
PROGOBJS += ../mozjs-dtrace.\$(OBJ_SUFFIX)\\
endif\\
' js/src/jsapi-tests/Makefile
J=\$(getconf _NPROCESSORS_CONF)
make
if \[ \$\? -eq 0 \] ; then true ; else
   echo UNTESTED: xulrunner build failed
   exit
fi
fi
run_tests uprobe
"
########## End /tmp/stap-xul.sh ########## 
close $fp
########## /tmp/stap-xul.sh does most of the work ########## 
verbose -log Running xul testsuite
spawn sh stap-xul.sh 2>&1
expect {
    -timeout 10000
    -re {UNTESTED: [a-z_ ]+} { regexp " .*$" $expect_out(0,string) s; 
	untested "$s"; exp_continue }
    -re {FAIL: [a-z_ ]+} { regexp " .*$" $expect_out(0,string) s; 
	fail "$s"; exp_continue }
    -re {PASS: [a-z_ ]+} { regexp " .*$" $expect_out(0,string) s; 
	pass "$s"; exp_continue }
    -re {UNSUPPORTED: [a-zA-Z_/: ]+} { regexp " .*$" $expect_out(0,string) s; 
	verbose -log "$s"
	unsupported "$s"; exp_continue }
    timeout { fail "$test (timeout)" }
    eof { }
}
catch {close}; catch {wait}
if { $verbose == 0 } {
catch {exec rm -rf $testsuite/stap-xul.stp xulrunner-$xulrelease-source.tar \
	   $testsuite/stap-xul-markers.log $testsuite/stap-xul.sh }
catch {exec rm -rf xul}
}
 
     |