1#!/bin/bash
2#
3# @echo off
4#
5# Prepare bdemo summary files of one multi-results directory for all modes:
6#
7# - 32-bit norm mode
8# - 64-bit norm mode
9# - 32-bit slack mode
10# - 64-bit slack mode
11#
12# Each line of the summary files represents the state of the relevant bug
13# reported by the relevant bdemo test.
14#
15# Parameters:
16#
17# arg1 - multi-result directory
18#
19# (for comments see Do and asltsrun utilities).
20
21# Includes
22
23. common
24. settings
25
26# arg1 - file "__STATUS_OF_TESTS"
27# arg2 - the name of system and modeid (system:modeid) the tests were run on
28get_summary()
29{
30	local pass=0 fail=0 blck=0 skip=0
31
32	number=
33	prev_num=
34	bdemo_started=
35
36	OLD_IFS=$IFS
37	IFS=":"
38
39	cat "$1" |\
40	while [ 1 ]
41	do
42		read s0 s1 s2 s3 s4 s5 line
43		if [ $? -ne 0 ] ; then
44			SUMMARY[$prev_num]="$prev_num:$2:$fail:$blck:$pass:$skip"
45			do_report_summary
46			break
47		fi
48
49		if [[ "$s2" == *bug-demo* ]]; then
50			bdemo_started=yes
51			number=`echo "$s3" | awk -F" " '{ print $4}'`
52
53			if [[ "$number" != "$prev_num" ]]; then
54				if [[ "$prev_num" != "" ]]; then
55					SUMMARY[$prev_num]="$prev_num:$2:$fail:$blck:$pass:$skip"
56					pass=0
57					fail=0
58					blck=0
59					skip=0
60				fi
61				prev_num=$number
62			fi
63
64			if [[ "$s5" == PASS ]]; then
65				pass=$[ $pass + 1 ]
66			elif [[ "$s5" == FAIL ]]; then
67				fail=$[ $fail + 1 ]
68			elif [[ "$s5" == BLOCKED ]]; then
69				blck=$[ $blck + 1 ]
70			elif [[ "$s5" == SKIPPED ]]; then
71				skip=$[ $skip + 1 ]
72			fi
73
74		elif [[ $bdemo_started == yes ]]; then
75			SUMMARY[$prev_num]="$prev_num:$2:$fail:$blck:$pass:$skip"
76			do_report_summary
77			break
78		fi
79	done
80
81	IFS=$OLD_IFS
82}
83
84# arg1   - multi-result directory
85# arg2   - the name of system the tests were run on
86# arg3   - mode of run
87# Result - file "__STATUS_OF_BDEMO_TESTS"
88do_summary()
89{
90	local path0 path1 modepart0 modename0 system
91
92	modepart0=`get_mode_string $3 0`
93	modename0=`get_mode_string $3 1`
94
95	path0="$1/$modepart0/__STATUS_OF_TESTS"
96	path1="$1/$modepart0/__STATUS_OF_BDEMO_TESTS"
97	system="$2"
98
99	echo "Extracting bdemo-results of <$system, $modename0>:"
100
101	if [ -f "$path1" ]; then
102		echo "Do nothing, file exists already:"
103		echo "   $path1"
104	elif [ -f "$path0" ]; then
105
106		modeid=`get_mode_id $3`
107
108		get_summary "$path0" "$system:$modeid" > "$path1"
109	else
110		echo "File doesn't exists:"
111		echo "   $path0"
112	fi
113}
114
115do_report_summary()
116{
117	index=0
118
119	while [ 1 ]
120	do
121		if [[ $index -ge $MAXBDEMO ]]; then
122			break
123		fi
124
125		echo "${SUMMARY[$index]}"
126
127		index=$[ $index + 1 ]
128	done
129}
130
131# ############################## MAIN ###############################
132
133DIR0="$1"
134UTILSTATUS=0
135SUMMARY=
136
137# Initialization
138
139INIT_MAX_BDEMO
140
141echo "Preparing the bdemo summary files of one multi-results directory for all modes:"
142echo "   $DIR0"
143
144echo "The number of bdemo-tests is equal to $MAXBDEMO"
145
146# Do all summaries of bdemos
147
148check_dir "$DIR0"
149
150COMMONLOGFILE="$DIR0/Summary"
151if [ ! -f "$COMMONLOGFILE" ]; then
152	do_exit 1 "COMMONLOGFILE is not file: <$COMMONLOGFILE>"
153else
154	system=`get_name_of_system "$COMMONLOGFILE"`
155fi
156
157do_summary "$DIR0" "$system" $NORM32
158do_summary "$DIR0" "$system" $NORM64
159do_summary "$DIR0" "$system" $SLACK32
160do_summary "$DIR0" "$system" $SLACK64
161
162exit $UTILSTATUS
163
164
165
166