12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #!/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.
- # \brief Local message file test
- #
- # Checks that a local message file can override the definitions in the message
- # dictionary.
- testname="Local message file test"
- echo $testname
- failcount=0
- localmes=@abs_builddir@/localdef_mes_$$
- tempfile=@abs_builddir@/run_time_init_test_tempfile_$$
- passfail() {
- if [ $1 -eq 0 ]; then
- echo " pass"
- else
- echo " FAIL"
- failcount=`expr $failcount + $1`
- fi
- }
- # Create the local message file for testing
- cat > $localmes << .
- % MSG_NOTHERE this message is not in the global dictionary
- % MSG_READERR replacement read error, parameters: '%1' and '%2'
- % MSG_RDLOCMES replacement read local message file, parameter is '%1'
- .
- echo -n "1. Local message replacement:"
- cat > $tempfile << .
- WARN [example.log] MSG_IDNOTFND could not replace message text for 'MSG_NOTHERE': no such message
- FATAL [example] MSG_WRITERR error writing to test1: 42
- ERROR [example] MSG_RDLOCMES replacement read local message file, parameter is 'dummy/file'
- WARN [example] MSG_BADSTREAM bad log console output stream: example
- WARN [example.alpha] MSG_READERR replacement read error, parameters: 'a.txt' and 'dummy reason'
- FATAL [example.beta] MSG_BADSEVERITY unrecognized log severity: beta_fatal
- ERROR [example.beta] MSG_BADDESTINATION unrecognized log destination: beta_error
- WARN [example.beta] MSG_BADSTREAM bad log console output stream: beta_warn
- .
- ./logger_example -c stdout -s warn $localmes | cut -d' ' -f3- | diff $tempfile -
- passfail $?
- echo -n "2. Report error if unable to read local message file:"
- cat > $tempfile << .
- ERROR [example.log] MSG_OPENIN unable to open message file $localmes for input: No such file or directory
- FATAL [example] MSG_WRITERR error writing to test1: 42
- ERROR [example] MSG_RDLOCMES reading local message file dummy/file
- WARN [example] MSG_BADSTREAM bad log console output stream: example
- WARN [example.alpha] MSG_READERR error reading from message file a.txt: dummy reason
- FATAL [example.beta] MSG_BADSEVERITY unrecognized log severity: beta_fatal
- ERROR [example.beta] MSG_BADDESTINATION unrecognized log destination: beta_error
- WARN [example.beta] MSG_BADSTREAM bad log console output stream: beta_warn
- .
- rm -f $localmes
- ./logger_example -c stdout -s warn $localmes | cut -d' ' -f3- | diff $tempfile -
- passfail $?
- 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
|