#!/bin/bash

set -e

# pvbatch is similar to `pvpython --force-offscreen-rendering`
# i.e. offline without image window pop-ups

# but we actually want "headless" not "offscreen"
# to avoid warnings about DISPLAY= sent to stderr "bad X server connection. DISPLAY="
export VTK_DEFAULT_OPENGL_WINDOW=vtkEGLRenderWindow

# test default mode (paraview is build with MPI support)
pvbatch -m paraview.tests

# test serial mode without MPI
pvbatch --no-mpi -m paraview.tests

# test explicit MPI mode

# avoid oversubscribe and other warnings
export PRTE_MCA_plm_ssh_agent=/bin/false
export PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe
export OMPI_MCA_btl_base_warn_component_unused=0
export OMPI_MCA_btl_tcp_if_include=lo

mpirun -n 4 pvbatch --mpi -m paraview.tests
