11#! /bin/bash
22
3+ python_pkg=" python36" 
34# 
45#  To make sure.
56# 
6- alternatives --set python /usr/bin/python3
7+ exit_out ()
8+ {
9+ 	echo  $1 
10+ 	exit  $2 
11+ }
12+ 
713usage ()
814{
915	echo  " $1  Usage:" 
1016	source  test_tools/general_setup --usage
11-         exit  0 
17+         exit  1 
1218}
1319
1420install_tools ()
@@ -45,8 +51,7 @@ install_tools()
4551	if  [ !  -d  " test_tools" ;  then 
4652		git clone $tools_git  test_tools
4753		if  [ $?  -ne  0 ];  then 
48- 			echo  pulling git $tools_git  failed.
49- 			exit 
54+ 			exit_out " pulling git $tools_git  failed." 
5055		fi 
5156	fi 
5257
@@ -97,6 +102,22 @@ generate_csv_file()
97102	printf  " %s:%12.2f:%s\n" $test_name  $results  $unit  >>  ${1} .csv
98103}
99104
105+ dnf_install ()
106+ {
107+ 	dnf install -y $1 
108+ 	if  [ $?  -ne  0 ];  then 
109+ 		exit_out " dnf install of $1  failed" 
110+ 	fi 
111+ }
112+ 
113+ pip3_install ()
114+ {
115+ 	pip3 install $1 
116+ 	if  [ $?  -ne  0 ];  then 
117+ 		exit_out " pip3 install of $1  failed." 
118+ 	fi 
119+ }
120+ 
100121# 
101122#  Variables set by general setup.
102123# 
@@ -137,9 +158,15 @@ if [ ! -f "/tmp/pyperf.out" ]; then
137158        command=" ${0}  $@ " 
138159        echo  $command 
139160        $command  & >  /tmp/pyperf.out
140-         cat /tmp/pyperf.out
141-         rm /tmp/pyperf.out
142-         exit 
161+ 	rtc=$? 
162+ 	if  [ -f  /tmp/pyperf.out ];  then 
163+ 		echo  =================================
164+ 		echo  Output from the test.
165+ 		echo  =================================
166+         	cat /tmp/pyperf.out
167+         	rm /tmp/pyperf.out
168+ 	fi 
169+         exit  $rtc 
143170fi 
144171
145172
@@ -151,18 +178,26 @@ if [ -d "workloads" ]; then
151178	# 
152179	start_dir=` pwd` 
153180	cd  workloads
154- 	ln -s $start_dir /*  . 
181+ 	for  file  in  ` ls ${start_dir} ` ;  do 
182+ 		if  [[ !  -f  $file  ]] &&  [[ !  -d  $file  ]];  then 
183+ 			ln -s $start_dir /*  . 
184+ 		fi 
185+ 	done 
155186fi 
156187
157188source  test_tools/general_setup " $@ " 
158189
190+ ARGUMENT_LIST=(
191+         " python_pkg" 
192+ )
193+ 
159194NO_ARGUMENTS=(
160-         " powers_2" 
161195        " usage" 
162196)
163197
164198#  read arguments
165199opts=$( getopt \
200+ 	--longoptions " $( printf " %s:," " ${ARGUMENT_LIST[@]} " ) "  
166201        --longoptions " $( printf " %s," " ${NO_ARGUMENTS[@]} " ) "  
167202        --name " $( basename " $0 " ) "  
168203        --options " h"  
@@ -173,6 +208,10 @@ eval set --$opts
173208
174209while  [[ $#  -gt  0 ]];  do 
175210	case  " $1 " in 
211+ 		--python_pkg)
212+ 			python_pkg=$2 
213+ 			shift  2
214+ 		;;
176215		--usage)
177216			usage $0 
178217		;;
@@ -189,19 +228,29 @@ while [[ $# -gt 0 ]]; do
189228	esac 
190229done 
191230
192- 
193231if  [ $to_pbench  -eq  0 ];  then 
194232	rm -rf pyperformance
195233	git clone https://github.com/python/pyperformance
234+ 	if  [ $?  -ne  0 ];  then 
235+ 		exit_out " Cloning of https://github.com/python/pyperformance failed." 
236+ 	fi 
196237	cd  pyperformance
197238	git checkout tags/1.0.4
198- 	dnf install -y python36 python36-devel
199- 	dnf install -y python38 python38-devel
200- 	pip3 install psutil
201- 	pip3 install packaging
202- 	pip3 install pyparsing
203- 	pip3 install pyperf
204- 	pip3 install toml
239+ 	if  [ $?  -ne  0 ];  then 
240+ 		exit_out " Checkout of 1.0.4 failed." 
241+ 	fi 
242+ 	dnf_install " ${python_pkg} " 
243+ 	dnf_install " ${python_pkg} -devel" 
244+ 	# 
245+ 	#  Install pip/pip3
246+ 	# 
247+ 	wget https://bootstrap.pypa.io/get-pip.py
248+ 	python3 ./get-pip.py
249+ 	pip3_install psutil
250+ 	pip3_install packaging
251+ 	pip3_install pyparsing
252+ 	pip3_install pyperf
253+ 	pip3_install toml
205254
206255	cpus=` cat /proc/cpuinfo |  grep processor |  wc -l` 
207256	cous=1
@@ -211,16 +260,24 @@ if [ $to_pbench -eq 0 ]; then
211260	pwd  >  /tmp/dave_debug
212261	echo  python3 -m pyperformance run --output  ${pyresults} .json >>  /tmp/dave_debug
213262	python3 -m pyperformance run --output  ${pyresults} .json
263+ 	if  [ $?  -ne  0 ];  then 
264+ 		exit_out " Failed: python3 -m pyperformance run --output  ${pyresults} .json" 
265+ 	fi 
214266	echo  python3 -m pyperf dump  ${pyresults} .json >>  /tmp/dave_debug
215267	python3 -m pyperf dump  ${pyresults} .json >  ${pyresults} .results
216- 
268+ 	if  [ $?  -ne  0 ];  then 
269+ 		echo  " Failed: python3 -m pyperf dump  ${pyresults} .json > ${pyresults} .results" 
270+ 	fi 
217271	generate_csv_file ${pyresults} 
218272else 
219273	source  ~ /.bashrc
220274	arguments=" ${arguments}  --test_iterations ${to_times_to_run} " 
221275	cd  $curdir 
222276	echo  $TOOLS_BIN /execute_via_pbench --cmd_executing " $0 " $arguments  --test ${test_name_run}  --spacing 11 --pbench_stats $to_pstats 
223277	$TOOLS_BIN /execute_via_pbench --cmd_executing " $0 " $arguments  --test ${test_name_run}  --spacing 11 --pbench_stats $to_pstats 
278+ 	if  [ $?  -ne  0  ];  then 
279+ 		exit_out " Failed: $TOOLS_BIN /execute_via_pbench --cmd_executing " $0 "  $arguments  --test ${test_name_run}  --spacing 11 --pbench_stats $to_pstats " 
280+ 	fi 
224281fi 
225282
226283
0 commit comments