Mageia Bugzilla – Attachment 1239 Details for
Bug 3744
2_a1: /sbin/halt.pre failed to run upon shutdown/reboot
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
shutdown_test.sh regression test
shutdown_test.sh (text/plain), 3.69 KB, created by
Bit Twister
on 2011-12-14 17:20:56 CET
(
hide
)
Description:
shutdown_test.sh regression test
Filename:
MIME Type:
Creator:
Bit Twister
Created:
2011-12-14 17:20:56 CET
Size:
3.69 KB
patch
obsolete
>#!/bin/bash > >#***************************************************************** >#* >#* shutdown_test.sh - /sbin/halt.(local, pre) regression test >#* >#* Script creates /sbin/halt.(local, pre) which create files >#* in the regression test directory. User reboots/halts system >#* and runs script again. Scripts reports if /sbin/halt.(local, pre) >#* fails or passes creating the file. >#* >#* Usage shutdown_test.sh [-i] [-c] >#* -c clean out/remove regression tests and test results >#* -i initialize/rmove previous test results >#* >#* Version 2.0 >#* >#***************************************************************** > > _exe=$0 > _app=$(basename $_exe) > _app=${_app%.sh} > _cmd_line_args="$@" > > set -u > _reg_dir=$HOME/regression_test_results > mkdir -p $_reg_dir > > set -- $(tr '()' ' ' < /etc/release) > > if [ "$1" = "Mandriva" ] ; then > _release=$4 > _branch=$5 > _arch=$7 > fi > > if [ "$1" = "Mageia" ] ; then > _release=$3 > _branch=$4 > _arch=$6 > fi > > _rpt_fn=$_reg_dir/${_app}_${_release}_${_branch}_${_arch}.rpt > _reboot_flg=0 > > > function ck_4_halt_local() > { > _fn=$1 > #***************************************************************** > #* function to create /sbin/halt.(local, pre) if it does not exist > #***************************************************************** > > if [ "$USER" = "root" ] ; then > _halt_fn=/sbin/$_fn > else # we are just debugging script > _halt_fn=$_reg_dir/sbin_$_fn > fi > > set -- $_cmd_line_args > if [ $# -gt 0 ] ; then > case $1 in > -i) # initialize/rmove previous test results > for fn in halt.pre halt.local ; do > /bin/rm -f $_reg_dir/$_fn > done > ;; > -c) # clean out regression tests and test results > for fn in halt.pre halt.local ; do > /bin/rm -f /sbin/$_halt_fn > /bin/rm -f $_reg_dir/* > done > ;; > *) echo "Unknown argument: $1" ; exit 1 ;; > esac > fi > > if [ ! -e "$_halt_fn" ] ; then > echo "#!/bin/bash > #*********************************************** > #* $_halt_fn created by $_exe > #*********************************************** > > _reg_dir=$_reg_dir > mkdir -p \$_reg_dir > echo \"\$0 works\" > \$_reg_dir/$_fn > #*********** end of $_halt_fn ************************************ > " > $_halt_fn > chmod +x $_halt_fn > > echo " > Created $_halt_fn > " >> $_rpt_fn > cat $_halt_fn >> $_rpt_fn > _reboot_flg=1 > fi > } # end function ck_4_halt_local > > > echo "$_rpt_fn > from $_exe > $(date) > > " > $_rpt_fn > > for fn in halt.pre halt.local ; do > ck_4_halt_local $fn > done > > if [ $_reboot_flg -eq 1 ] ; then > echo " > Run \"reboot\" then after system is up, run $_exe > again to test that reboot executed > /sbin/halt.(local, pre) scripts. > > run $_exe -i > > run \"shutdown\", powerup to test that > halt executed /sbin/halt.(pre, local) > " >> $_rpt_fn > cat $_rpt_fn > exit 0 > fi > > for fn in halt.pre halt.local ; do > _fn=$_reg_dir/$fn > if [ ! -e $_fn ] ; then > echo "/sbin/$fn failed to run upon shutdown/reboot" >> $_rpt_fn > echo "We know this because $_fn was not created > by /sbin/$fn during shutdown or reboot > " >> $_rpt_fn > else > echo "/sbin/$fn test passed" >> $_rpt_fn > fi > done > > echo " > Run $_exe -c to remove /sbin/halt.(pre, local) > and test results" >> $_rpt_fn > cat $_rpt_fn > set - > >#************** end shutdown_test.sh *********************************
#!/bin/bash #***************************************************************** #* #* shutdown_test.sh - /sbin/halt.(local, pre) regression test #* #* Script creates /sbin/halt.(local, pre) which create files #* in the regression test directory. User reboots/halts system #* and runs script again. Scripts reports if /sbin/halt.(local, pre) #* fails or passes creating the file. #* #* Usage shutdown_test.sh [-i] [-c] #* -c clean out/remove regression tests and test results #* -i initialize/rmove previous test results #* #* Version 2.0 #* #***************************************************************** _exe=$0 _app=$(basename $_exe) _app=${_app%.sh} _cmd_line_args="$@" set -u _reg_dir=$HOME/regression_test_results mkdir -p $_reg_dir set -- $(tr '()' ' ' < /etc/release) if [ "$1" = "Mandriva" ] ; then _release=$4 _branch=$5 _arch=$7 fi if [ "$1" = "Mageia" ] ; then _release=$3 _branch=$4 _arch=$6 fi _rpt_fn=$_reg_dir/${_app}_${_release}_${_branch}_${_arch}.rpt _reboot_flg=0 function ck_4_halt_local() { _fn=$1 #***************************************************************** #* function to create /sbin/halt.(local, pre) if it does not exist #***************************************************************** if [ "$USER" = "root" ] ; then _halt_fn=/sbin/$_fn else # we are just debugging script _halt_fn=$_reg_dir/sbin_$_fn fi set -- $_cmd_line_args if [ $# -gt 0 ] ; then case $1 in -i) # initialize/rmove previous test results for fn in halt.pre halt.local ; do /bin/rm -f $_reg_dir/$_fn done ;; -c) # clean out regression tests and test results for fn in halt.pre halt.local ; do /bin/rm -f /sbin/$_halt_fn /bin/rm -f $_reg_dir/* done ;; *) echo "Unknown argument: $1" ; exit 1 ;; esac fi if [ ! -e "$_halt_fn" ] ; then echo "#!/bin/bash #*********************************************** #* $_halt_fn created by $_exe #*********************************************** _reg_dir=$_reg_dir mkdir -p \$_reg_dir echo \"\$0 works\" > \$_reg_dir/$_fn #*********** end of $_halt_fn ************************************ " > $_halt_fn chmod +x $_halt_fn echo " Created $_halt_fn " >> $_rpt_fn cat $_halt_fn >> $_rpt_fn _reboot_flg=1 fi } # end function ck_4_halt_local echo "$_rpt_fn from $_exe $(date) " > $_rpt_fn for fn in halt.pre halt.local ; do ck_4_halt_local $fn done if [ $_reboot_flg -eq 1 ] ; then echo " Run \"reboot\" then after system is up, run $_exe again to test that reboot executed /sbin/halt.(local, pre) scripts. run $_exe -i run \"shutdown\", powerup to test that halt executed /sbin/halt.(pre, local) " >> $_rpt_fn cat $_rpt_fn exit 0 fi for fn in halt.pre halt.local ; do _fn=$_reg_dir/$fn if [ ! -e $_fn ] ; then echo "/sbin/$fn failed to run upon shutdown/reboot" >> $_rpt_fn echo "We know this because $_fn was not created by /sbin/$fn during shutdown or reboot " >> $_rpt_fn else echo "/sbin/$fn test passed" >> $_rpt_fn fi done echo " Run $_exe -c to remove /sbin/halt.(pre, local) and test results" >> $_rpt_fn cat $_rpt_fn set - #************** end shutdown_test.sh *********************************
View Attachment As Raw
Actions:
View
Attachments on
bug 3744
: 1239