#!/bin/bash

# This script is for the use with 'start_test' as the system-wide prediff
# when GASNet is used and may produce "Receive buffer full" wwarnings.
# To use (assuming bash):
#
#  CHPL_SYSTEM_PREDIFF=$CHPL_HOME/util/test/prediff-for-amudp-warning \
#    start_test ...


# certain tests' outputs are better left alone
skipit=false
case "$1" in
  # binary output, no newline
  ( mandelbrot-complex | mandelbrot-dist | mandelbrot-fancy)
  skipit=true ;;
  # text output, no newline - which ones?
  ( declprintint | fwriteIntFile | fwriteMultipleInts | fwriteIntStdout )
  skipit=true ;;
esac

if $skipit; then
  echo prediff-for-amudp-warning : not processing "$2"
  exit
fi

outfile=$2
RE='^\*\*\* AMUDP WARNING: Receive buffer full - unable to drain network (this is usually caused by retransmissions)$'

grep -v "$RE" $outfile > $outfile.tmp
mv $outfile.tmp $outfile
