#!/bin/sh # Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC") # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. # The logger supports the idea of a "console" logger than logs to either stdout # or stderr. This test checks that both these options work. export B10_FROM_SOURCE=@abs_top_srcdir@ testname="Console output test" echo $testname failcount=0 tempfile=@abs_builddir@/console_test_tempfile_$$ # Look at tempfile and check that the count equals the expected count passfail() { count=`wc -l $tempfile | awk '{print $1}'` if [ $count -eq $1 ]; then echo " pass" else echo " FAIL" failcount=`expr $failcount + $1` fi } echo -n "1. Checking that console output to stdout goes to stdout:" rm -f $tempfile ./logger_example -c stdout -s error 1> $tempfile 2> /dev/null passfail 4 echo -n "2. Checking that console output to stdout does not go to stderr:" rm -f $tempfile ./logger_example -c stdout -s error 1> /dev/null 2> $tempfile passfail 0 echo -n "3. Checking that console output to stderr goes to stderr:" rm -f $tempfile ./logger_example -c stderr -s error 1> /dev/null 2> $tempfile passfail 4 echo -n "4. Checking that console output to stderr does not go to stdout:" rm -f $tempfile ./logger_example -c stderr -s error 1> $tempfile 2> /dev/null passfail 0 if [ $failcount -eq 0 ]; then echo "PASS: $testname" elif [ $failcount -eq 1 ]; then echo "FAIL: $testname - 1 test failed" else echo "FAIL: $testname - $failcount tests failed" fi # Tidy up rm -f $tempfile exit $failcount