#! /bin/sh

dir=`dirname $0`

./filter_stderr |

perl -p -e 's/^Open AF_UNIX socket [0-9]*: <unknown>/Open AF_UNIX socket ...: <unknown>/' |
perl -p -e 's/^Open (AF_UNIX socket|file descriptor) [0-9]*: \/dev\/null/Open $1 ...: \/dev\/null/' |
# Solaris-specific, translate /devices/pseudo/mm@0:null to /dev/null
perl -p -e 's/^Open (AF_UNIX socket|file descriptor) [0-9]*: \/devices\/pseudo\/mm\@0:null/Open $1 ...: \/dev\/null/' |
# Nb: on Darwin, /tmp is a symlink to /private/tmp, so sometimes it's
# necessary to filter out the "/private" part.
perl -p -e 's/^Open (AF_UNIX socket|file descriptor) [0-9]*: (\/private)?\/tmp\/(sock|data1|data2|file)\.[0-9]*/Open $1 ...: \/tmp\/$3/' |
perl -p -e 's/^Open file descriptor [0-9]*: .*/Open file descriptor ...: .../' |
perl -p -e 's/^Open file descriptor [0-9]*:$/Open file descriptor ...:/' |
perl -p -e 's/127.0.0.1:[0-9]*/127.0.0.1:.../g' |

# Stack traces showing where fds were created have lots of variations:
# different numbers of entries, line numbers or not depending on whether
# libc debug info is present, 'main' vs. '(below main)', etc.  
#
# So we just cut out the entire stack trace.  It's coarse but effective;
# before we did this we had a plethora of expected outputs, with only
# painfully minor variations between them.
perl -p -0 -e 's/(Open[^\n]*\n)(   (at|by)[^\n]*\n)+/$1   ...\n/gs'


