Skip to content

Commit

Permalink
Split scriptlet failure tests to separate sub-cases for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatilai committed Dec 12, 2023
1 parent 57dddfc commit 386ccfc
Showing 1 changed file with 140 additions and 58 deletions.
198 changes: 140 additions & 58 deletions tests/rpmscript.at
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ AT_BANNER([RPM scriptlets])

AT_SETUP([basic script failures 1])
AT_KEYWORDS([script])
RPMTEST_CHECK([
RPMDB_INIT

runroot rpmbuild --quiet -bb /data/SPECS/fakeshell.spec
Expand All @@ -20,125 +19,208 @@ pkg2="${pkgname}-2.0-1"
pkgfile1="/build/RPMS/noarch/${pkg1}.noarch.rpm"
pkgfile2="/build/RPMS/noarch/${pkg2}.noarch.rpm"

RPMTEST_CHECK([
echo PRETRANSFAIL
runroot rpm -U --define "exitpretrans 1" ${pkgfile1} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
],
[1],
[PRETRANSFAIL
error: %pretrans(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
error: scriptfail-1.0-1.noarch: install skipped
1
package scriptfail is not installed
],
[])

RPMTEST_CHECK([
echo PRETRANS
runroot rpm -U --define "exitpretrans 0" ${pkgfile1} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
runroot rpm -e ${pkgname} 2>&1
],
[0],
[PRETRANS
0
scriptfail-1.0-1.noarch
],
[])

RPMTEST_CHECK([
echo PREFAIL
runroot rpm -U --define "exitpre 1" ${pkgfile1} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
],
[1],
[PREFAIL
error: %prein(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
error: scriptfail-1.0-1.noarch: install failed
1
package scriptfail is not installed
],
[])

RPMTEST_CHECK([
echo PRE
runroot rpm -U --define "exitpre 0" ${pkgfile1} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
],
[0],
[PRE
0
scriptfail-1.0-1.noarch
],
[])

RPMTEST_CHECK([
echo PREUNFAIL
runroot rpm -e --define "exitpreun 1" ${pkgname} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
],
[0],
[PREUNFAIL
error: %preun(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
error: scriptfail-1.0-1.noarch: erase failed
1
scriptfail-1.0-1.noarch
],
[])

RPMTEST_CHECK([
echo PREUNTRANSFAIL
runroot rpm -e --define "exitpreuntrans 1" ${pkgname} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
],
[0],
[PREUNTRANSFAIL
error: %preuntrans(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
error: scriptfail-1.0-1.noarch: erase skipped
1
scriptfail-1.0-1.noarch
],
[])

RPMTEST_CHECK([
echo PREUN
runroot rpm -e --define "exitpreun 0" ${pkgname} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
],
[1],
[PREUN
0
package scriptfail is not installed
],
[])

RPMTEST_CHECK([
echo POSTFAIL
runroot rpm -U ${pkgfile1} 2>&1
runroot rpm -U --define "exitpost 1" ${pkgfile2} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
runroot rpm -e ${pkgname} 2>&1
],
[0],
[POSTFAIL
warning: %post(scriptfail-2.0-1.noarch) scriptlet failed, exit status 1
0
scriptfail-2.0-1.noarch
],
[])

RPMTEST_CHECK([
echo POST
runroot rpm -U ${pkgfile1} 2>&1
runroot rpm -U --define "exitpost 0" ${pkgfile2} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
runroot rpm -e ${pkgname} 2>&1
],
[0],
[POST
0
scriptfail-2.0-1.noarch
],
[])

RPMTEST_CHECK([
echo POSTTRANSFAIL
runroot rpm -U --define "exitposttrans 1" ${pkgfile1} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
runroot rpm -e ${pkgname} 2>&1
],
[0],
[POSTTRANSFAIL
warning: %posttrans(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
0
scriptfail-1.0-1.noarch
],
[])

RPMTEST_CHECK([
echo POSTTRANS
runroot rpm -U --define "exitposttrans 0" ${pkgfile1} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
runroot rpm -e ${pkgname} 2>&1
],
[0],
[POSTTRANS
0
scriptfail-1.0-1.noarch
],
[])

RPMTEST_CHECK([
echo POSTUNFAIL
runroot rpm -U ${pkgfile1} 2>&1
runroot rpm -U --define "exitpostun 1" ${pkgfile2} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
runroot rpm -e ${pkgname} 2>&1
],
[0],
[POSTUNFAIL
warning: %postun(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
0
scriptfail-2.0-1.noarch
],
[])

RPMTEST_CHECK([
echo POSTUNTRANSFAIL
runroot rpm -U ${pkgfile1} 2>&1
runroot rpm -U --define "exitpostuntrans 1" ${pkgfile2} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
runroot rpm -e ${pkgname} 2>&1
],
[0],
[POSTUNTRANSFAIL
warning: %postuntrans(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
0
scriptfail-2.0-1.noarch
],
[])

RPMTEST_CHECK([
echo POSTUN
runroot rpm -U ${pkgfile1} 2>&1
runroot rpm -U --define "exitpostun 0" ${pkgfile2} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
runroot rpm -e ${pkgname} 2>&1
],
[0],
[POSTUN
0
scriptfail-2.0-1.noarch
],
[])

RPMTEST_CHECK([
echo POSTUNTRANS
runroot rpm -U ${pkgfile1} 2>&1
runroot rpm -U --define "exitpostuntrans 0" ${pkgfile2} 2>&1; echo $?
runroot rpm -q ${pkgname} 2>&1
runroot rpm -e ${pkgname} 2>&1

exit 0
],
[],
[PRETRANSFAIL
error: %pretrans(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
error: scriptfail-1.0-1.noarch: install skipped
1
package scriptfail is not installed
PRETRANS
0
scriptfail-1.0-1.noarch
PREFAIL
error: %prein(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
error: scriptfail-1.0-1.noarch: install failed
1
package scriptfail is not installed
PRE
0
scriptfail-1.0-1.noarch
PREUNFAIL
error: %preun(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
error: scriptfail-1.0-1.noarch: erase failed
1
scriptfail-1.0-1.noarch
PREUNTRANSFAIL
error: %preuntrans(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
error: scriptfail-1.0-1.noarch: erase skipped
1
scriptfail-1.0-1.noarch
PREUN
0
package scriptfail is not installed
POSTFAIL
warning: %post(scriptfail-2.0-1.noarch) scriptlet failed, exit status 1
0
scriptfail-2.0-1.noarch
POST
0
scriptfail-2.0-1.noarch
POSTTRANSFAIL
warning: %posttrans(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
0
scriptfail-1.0-1.noarch
POSTTRANS
0
scriptfail-1.0-1.noarch
POSTUNFAIL
warning: %postun(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
0
scriptfail-2.0-1.noarch
POSTUNTRANSFAIL
warning: %postuntrans(scriptfail-1.0-1.noarch) scriptlet failed, exit status 1
0
scriptfail-2.0-1.noarch
POSTUN
0
scriptfail-2.0-1.noarch
POSTUNTRANS
[POSTUNTRANS
0
scriptfail-2.0-1.noarch
],
Expand Down

0 comments on commit 386ccfc

Please sign in to comment.