481763
#!/usr/bin/bash
481763
481763
812674
function run_tests_wayland {
812674
  # usage: run-tests-wayland [test flavour]
812674
812674
  set -x
812674
812674
  RUN_XPCSHELL_TEST=1
812674
  RUN_REFTEST=1
812674
  RUN_MOCHITEST=1
812674
  RUN_CRASHTEST=1
812674
812674
  while (( "$#" )); do
812674
    SELECTED_TEST=$1
812674
    if [ "$SELECTED_TEST" = "xpcshell" ] ; then
812674
      RUN_XPCSHELL_TEST=1
812674
    elif [ "$SELECTED_TEST" = "reftest" ] ; then
812674
      RUN_REFTEST=1
812674
    elif [ "$SELECTED_TEST" = "mochitest" ] ; then
812674
      RUN_MOCHITEST=1
812674
    elif [ "$SELECTED_TEST" = "crashtest" ] ; then
812674
      RUN_CRASHTEST=1
812674
    fi
812674
    shift
812674
  done
812674
812674
  export MACH_USE_SYSTEM_PYTHON=1
812674
  export MOZ_NODE_PATH=/usr/bin/node
812674
812674
  MOCHITEST_PARAMS="--timeout 1 --chunk-by-dir 4"
812674
  TEST_DIR="test_results"
812674
  mkdir $TEST_DIR
812674
812674
  env | grep "DISPLAY"
812674
812674
  # Fix for system nss
812674
  ln -s /usr/bin/certutil objdir/dist/bin/certutil
812674
  ln -s /usr/bin/pk12util objdir/dist/bin/pk12util
812674
812674
  NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
812674
812674
  export MOZ_ENABLE_WAYLAND=1
812674
812674
  if [ $RUN_XPCSHELL_TEST -ne 0 ] ; then
812674
  #  ./mach xpcshell-test 2>&1 | cat - | tee $TEST_DIR/xpcshell
812674
    ./mach xpcshell-test --enable-webrender 2>&1 | cat - | tee $TEST_DIR/xpcshell-wr
812674
    sleep 60
812674
  fi
812674
812674
  # Basic render testing
812674
  export TEST_PARAMS="--setpref reftest.ignoreWindowSize=true --setpref widget.wayland.test-workarounds.enabled=true"
812674
  #export TEST_FLAVOUR=""
812674
  #if [ $RUN_REFTEST -ne 0 ] ; then
812674
  #  ./mach reftest --marionette localhost:$(($(($RANDOM))+2000)) $TEST_PARAMS 2>&1 | tee $TEST_DIR/reftest$TEST_FLAVOUR
812674
  #fi
812674
  #if [ $RUN_CRASHTEST -ne 0 ] ; then
812674
  #  ./mach crashtest --marionette localhost:$(($(($RANDOM))+2000)) $TEST_PARAMS 2>&1 | tee $TEST_DIR/crashtest$TEST_FLAVOUR
812674
  #fi
812674
  #if [ $RUN_MOCHITEST -ne 0 ] ; then
812674
  #  ./mach mochitest --marionette localhost:$(($(($RANDOM))+2000)) $MOCHITEST_PARAMS $TEST_PARAMS 2>&1 | tee $TEST_DIR/mochitest$TEST_FLAVOUR
812674
  #fi
812674
812674
  # WebRender testing
812674
  export TEST_PARAMS="--enable-webrender $TEST_PARAMS"
812674
  export TEST_FLAVOUR="-wr"
812674
  # Use dom/base/test or dom/base/test/chrome for short version
812674
  export MOCHITEST_DIR='dom'
812674
  if [ $RUN_REFTEST -ne 0 ] ; then
812674
    ./mach reftest $TEST_PARAMS 2>&1 | tee $TEST_DIR/reftest$TEST_FLAVOUR
812674
    sleep 60
812674
  fi
812674
  if [ $RUN_CRASHTEST -ne 0 ] ; then
812674
    ./mach crashtest $TEST_PARAMS 2>&1 | tee $TEST_DIR/crashtest$TEST_FLAVOUR
812674
    sleep 60
812674
  fi
812674
  if [ $RUN_MOCHITEST -ne 0 ] ; then
812674
    ./mach mochitest $MOCHITEST_DIR $MOCHITEST_PARAMS $TEST_PARAMS 2>&1 | tee $TEST_DIR/mochitest$TEST_FLAVOUR
812674
    sleep 60
812674
  fi
812674
812674
  rm -f  objdir/dist/bin/certutil
812674
  rm -f  objdir/dist/bin/pk12util
812674
}
812674
812674
function run_tests_x11() {
812674
  set -x
812674
812674
  export MACH_USE_SYSTEM_PYTHON=1
812674
  export MOZ_NODE_PATH=/usr/bin/node
812674
  export X_PARAMS="-screen 0 1600x1200x24"
812674
  export MOCHITEST_PARAMS="--timeout 1 --chunk-by-dir 4"
812674
  export TEST_DIR="test_results"
812674
812674
  # Fix for system nss
812674
  ln -s /usr/bin/certutil objdir/dist/bin/certutil
812674
  ln -s /usr/bin/pk12util objdir/dist/bin/pk12util
812674
812674
  NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
812674
812674
  # Basic render testing
812674
  export TEST_PARAMS=""
812674
  export TEST_FLAVOUR=""
812674
  #xvfb-run -s "$X_PARAMS" -n 91 ./mach xpcshell-test --sequential $TEST_PARAMS 2>&1 | cat - | tee $TEST_DIR/xpcshell
812674
  #xvfb-run -s "$X_PARAMS" -n 92 ./mach reftest --marionette localhost:$(($(($RANDOM))+2000)) $TEST_PARAMS 2>&1 | tee $TEST_DIR/reftest$TEST_FLAVOUR
812674
  #xvfb-run -s "$X_PARAMS" -n 93 ./mach crashtest --marionette localhost:$(($(($RANDOM))+2000)) $TEST_PARAMS 2>&1 | tee $TEST_DIR/crashtest$TEST_FLAVOUR
812674
  #xvfb-run -s "$X_PARAMS" -n 94 ./mach mochitest --marionette localhost:$(($(($RANDOM))+2000)) $MOCHITEST_PARAMS $TEST_PARAMS 2>&1 | tee $TEST_DIR/mochitest$TEST_FLAVOUR
812674
812674
  # WebRender testing
812674
  export TEST_PARAMS="--enable-webrender $TEST_PARAMS"
812674
  export TEST_FLAVOUR="-wr"
812674
  #xvfb-run -s "$X_PARAMS" -n 95 ./mach xpcshell-test --sequential $TEST_PARAMS 2>&1 | cat - | tee $TEST_DIR/xpcshell-wr
812674
  #sleep 60
812674
  #xvfb-run -s "$X_PARAMS" -n 96 ./mach reftest $TEST_PARAMS 2>&1 | tee $TEST_DIR/reftest$TEST_FLAVOUR
812674
  #sleep 60
812674
  #xvfb-run -s "$X_PARAMS" -n 97 ./mach crashtest $TEST_PARAMS 2>&1 | tee $TEST_DIR/crashtest$TEST_FLAVOUR
812674
  #sleep 60
812674
  #export DISPLAY=:0
812674
  #./mach mochitest dom/base/test/ $MOCHITEST_PARAMS $TEST_PARAMS 2>&1 | tee $TEST_DIR/mochitest$TEST_FLAVOUR
812674
  export DISPLAY=:98
812674
  xvfb-run -s "$X_PARAMS" -n 98 ./mach mochitest dom/base/test/ $MOCHITEST_PARAMS $TEST_PARAMS 2>&1 | tee $TEST_DIR/mochitest$TEST_FLAVOUR
812674
812674
  rm -f  objdir/dist/bin/certutil
812674
  rm -f  objdir/dist/bin/pk12util
812674
}
812674
812674
function run_wayland_compositor() {
812674
  # Run wayland compositor and set WAYLAND_DISPLAY env variable
812674
  set -x
812674
812674
  echo export DESKTOP_SESSION=gnome > $HOME/.xsessionrc
812674
  echo export XDG_CURRENT_DESKTOP=GNOME > $HOME/.xsessionrc
812674
  echo export XDG_SESSION_TYPE=wayland >> $HOME/.xsessionrc
812674
812674
  # Turn off the screen saver and screen locking
812674
  gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
812674
  gsettings set org.gnome.desktop.screensaver lock-enabled false
812674
  gsettings set org.gnome.desktop.screensaver lock-delay 3600
812674
812674
  # Disable the screen saver
812674
  # This starts the gnome-keyring-daemon with an unlocked login keyring. libsecret uses this to
812674
  # store secrets. Firefox uses libsecret to store a key that protects sensitive information like
812674
  # credit card numbers.
812674
  if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
812674
      # if not found, launch a new one
812674
      eval `dbus-launch --sh-syntax`
812674
  fi
812674
  eval `echo '' | /usr/bin/gnome-keyring-daemon -r -d --unlock --components=secrets`
812674
812674
  if [ -z "$XDG_RUNTIME_DIR" ]; then
812674
    export XDG_RUNTIME_DIR=$HOME
481763
  fi
812674
812674
  . xvfb-run -s "-screen 0 1600x1200x24" -n 80 mutter --display=:80 --wayland --nested &
812674
  export DISPLAY=:80
812674
812674
  if [ -z "$WAYLAND_DISPLAY" ] ; then
812674
    export WAYLAND_DISPLAY=wayland-0
812674
  else
812674
    export WAYLAND_DISPLAY=wayland-1
812674
  fi
812674
  sleep 10
812674
  retry_count=0
812674
  max_retries=5
812674
  until [ $retry_count -gt $max_retries ]; do
812674
    if [ -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ]; then
812674
      retry_count=$(($max_retries + 1))
812674
    else
812674
      retry_count=$(($retry_count + 1))
812674
      echo "Waiting for Mutter, retry: $retry_count"
812674
      sleep 2
812674
    fi
812674
  done
812674
812674
  env | grep "DISPLAY"
812674
}
812674
812674
function print_error_reftest() {
812674
  # Print reftest failures and compose them to html
812674
812674
  TEST_DIR="$1"
812674
  TEST_FLAVOUR="$2"
812674
  OUTPUT_FILE="failures-reftest$TEST_FLAVOUR.html"
812674
812674
  grep --text -e "REFTEST TEST-UNEXPECTED-PASS" -e "REFTEST TEST-UNEXPECTED-FAIL" -e "IMAGE 1 (TEST):" -e "IMAGE 2 (REFERENCE):" $TEST_DIR/reftest$TEST_FLAVOUR 2>&1 > $OUTPUT_FILE
812674
  sed -i '/REFTEST   IMAGE 1/a ">' $OUTPUT_FILE
812674
  sed -i '/REFTEST   IMAGE 2/a ">

' $OUTPUT_FILE
812674
  sed -i '/REFTEST TEST/a 
' $OUTPUT_FILE
812674
  sed -i -e 's/^REFTEST   IMAGE 1 (TEST): /
812674
  sed -i -e 's/^REFTEST   IMAGE 2 (REFERENCE): /
812674
}
812674
812674
function print_errors() {
812674
  #!/usr/bin/bash
812674
  # Print failed tests
812674
812674
  TEST_DIR=$1
812674
  TEST_FLAVOUR=$2
812674
812674
  grep "TEST-UNEXPECTED-FAIL" $TEST_DIR/mochitest$TEST_FLAVOUR 2>&1 > failures-mochitest$TEST_FLAVOUR.txt
812674
  grep --text -e "  FAIL " -e "  TIMEOUT " $TEST_DIR/xpcshell$TEST_FLAVOUR 2>&1 > failures-xpcshell$TEST_FLAVOUR.txt
812674
  grep --text -e "REFTEST TEST-UNEXPECTED-PASS" -e "REFTEST TEST-UNEXPECTED-FAIL" $TEST_DIR/reftest$TEST_FLAVOUR 2>&1 > failures-reftest$TEST_FLAVOUR.txt
812674
}
812674
812674
function print_failures() {
812674
  #!/usr/bin/bash
812674
  # Analyze and print test failures
812674
812674
  export TEST_DIR="test_results"
812674
812674
  #./print-errors $TEST_DIR ""
812674
  print_errors $TEST_DIR "-wr"
812674
  #./print-error-reftest $TEST_DIR ""
812674
  print_error_reftest $TEST_DIR "-wr"
812674
}
812674
812674
function psummary() {
812674
  #!/usr/bin/bash
812674
  # Analyze and print specialized (basic/webrender) test results
812674
812674
  TEST_DIR=$1
812674
  TEST_FLAVOUR=$2
812674
812674
  MPASS=`grep "TEST_END: Test OK" $TEST_DIR/mochitest$TEST_FLAVOUR | wc -l`
812674
  MERR=`grep "TEST_END: Test ERROR" $TEST_DIR/mochitest$TEST_FLAVOUR | wc -l`
812674
  MUNEX=`grep "TEST-UNEXPECTED-FAIL" $TEST_DIR/mochitest$TEST_FLAVOUR | wc  -l`
812674
  echo "Mochitest   PASSED: $MPASS FAILED: $MERR UNEXPECTED-FAILURES: $MUNEX"
812674
812674
  XPCPASS=`grep --text "Expected results:" $TEST_DIR/xpcshell$TEST_FLAVOUR | cut -d ' ' -f 3`
812674
  XPCFAIL=`grep --text "Unexpected results:" $TEST_DIR/xpcshell$TEST_FLAVOUR | cut -d ' ' -f 3`
812674
  echo "XPCShell:   PASSED: $XPCPASS FAILED: $XPCFAIL"
812674
812674
  CRPASS=`grep "REFTEST INFO | Successful:" $TEST_DIR/crashtest$TEST_FLAVOUR | cut -d ' ' -f 5`
812674
  CRFAIL=`grep "^REFTEST INFO | Unexpected:" $TEST_DIR/crashtest$TEST_FLAVOUR | cut -d ' ' -f 5`
812674
  echo "Crashtest:  PASSED: $CRPASS FAILED: $CRFAIL"
812674
812674
  RFPASS=`grep --text "REFTEST INFO | Successful:" $TEST_DIR/reftest$TEST_FLAVOUR | cut -d ' ' -f 5`
812674
  RFUN=`grep --text "^REFTEST INFO | Unexpected:" $TEST_DIR/reftest$TEST_FLAVOUR | cut -d ' ' -f 5`
812674
  RFKNOWN=`grep --text "REFTEST INFO | Known problems:" $TEST_DIR/reftest$TEST_FLAVOUR | cut -d ' ' -f 6`
812674
  echo "Reftest:    PASSED: $RFPASS FAILED: $RFUN Known issues: $RFKNOWN"
812674
}
812674
812674
function print_results() {
812674
  #!/usr/bin/bash
812674
  # Analyze and print general test results
812674
812674
  export TEST_DIR="test_results"
812674
812674
  echo "Test results"
812674
  #echo "Basic compositor"
812674
  #./psummary $TEST_DIR ""
812674
  echo "WebRender"
812674
  psummary $TEST_DIR "-wr"
812674
}
812674
812674
set -x
812674
first=$1
812674
shift
812674
$first $*
812674