1 #!/bin/bash 2 3 # 4 # Copyright (c) International Business Machines Corp., 2009 5 # Author: Matt Helsley <matthltc (at] us.ibm.com> 6 # 7 # This library is free software; you can redistribute it and/or 8 # modify it under the terms of the GNU Lesser General Public 9 # License as published by the Free Software Foundation; either 10 # version 2.1 of the License, or (at your option) any later version. 11 # 12 # This library is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 # Lesser General Public License for more details. 16 # 17 # You should have received a copy of the GNU Lesser General Public 18 # License along with this library; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 22 ### 23 ### LTP framework shim 24 ### 25 export npassed=0 26 export nfailed=0 27 28 function tst_func () 29 { 30 local out_fd=1 31 local tag="<no tag>" 32 local cmd="<no cmd>" 33 local msg="<no msg>" 34 35 if [ $# -gt 0 ]; then 36 cmd="$1" 37 shift 38 fi 39 if [ $# -gt 0 ]; then 40 tag="$1" 41 shift 42 fi 43 if [ $# -gt 0 ]; then 44 msg="$*" 45 fi 46 47 case "$cmd" in 48 tst_resm|tst_brkm|tst_exit) ;; 49 *) 50 out_fd=2 51 msg="(LTP log violation: Uknown LTP cmd: $cmd) $msg" 52 ;; 53 esac 54 55 case "$tag" in 56 TINFO) 57 ;; 58 TPASS) 59 ((npassed++)) 60 ;; 61 TWARN) 62 out_fd=2 63 ;; 64 TBROK) 65 out_fd=2 66 ;; 67 TFAIL) 68 ((nfailed++)) 69 ;; 70 *) 71 out_fd=2 72 msg="(LTP log violation: Uknown LTP log tag: $tag) $msg" 73 ;; 74 esac 75 76 #echo "LTP log: $cmd ${TCID} ${TST_COUNT}/${TST_TOTAL}: $tag $msg" 1>&$out_fd 77 echo "${TCID} ${TST_COUNT}/${TST_TOTAL}: $tag $msg" 1>&$out_fd 78 } 79 80 function tst_resm () 81 { 82 tst_func "tst_resm" "$@" 83 } 84 85 function tst_brkm () 86 { 87 tst_func "tst_brkm" "$@" 88 } 89 90 function tst_exit () 91 { 92 tst_func "tst_exit" "$@" 93 if ((nfailed > 0)); then 94 exit 1 95 else 96 exit 0 97 fi 98 } 99 100 export -f tst_func tst_resm tst_brkm tst_exit 101 export TCID TST_COUNT TST_TOTAL 102