Introduce mock-log.h for unittests.
[platform/upstream/glog.git] / src / logging_striplog_test.sh
1 #! /bin/sh
2 # Copyright 2007 Google, Inc.
3 # All Rights Reserved. 
4 #
5 # Author: Sergey Ioffe
6
7 get_strings () {
8     if test -e ".libs/$1"; then
9         binary=".libs/$1"
10     elif test -e "$1.exe"; then
11         binary="$1.exe"
12     else
13         echo "We coundn't find $1 binary."
14         exit 1
15     fi
16     
17     strings -n 10 $binary | sort | awk '/TESTMESSAGE/ {printf "%s ", $2}'
18 }
19
20 # Die if "$1" != "$2", print $3 as death reason
21 check_eq () {
22     if [ "$1" != "$2" ]; then
23         echo "Check failed: '$1' == '$2' ${3:+ ($3)}"
24         exit 1
25     fi
26 }
27
28 die () {
29     echo $1
30     exit 1
31 }
32
33 # Check that the string literals are appropriately stripped. This will
34 # not be the case in debug mode.
35
36 check_eq "`get_strings logging_striptest0`" "COND ERROR FATAL INFO WARNING "
37 check_eq "`get_strings logging_striptest2`" "COND ERROR FATAL "
38 check_eq "`get_strings logging_striptest10`" ""
39
40 # Check that LOG(FATAL) aborts even for large STRIP_LOG
41
42 ./logging_striptest2 2>/dev/null && die "Did not abort for STRIP_LOG=2"
43 ./logging_striptest10 2>/dev/null && die "Did not abort for STRIP_LOG=10"
44
45 echo "PASS"