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