diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-03-21 10:04:14 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-03-21 10:10:07 +0200 |
commit | c411382194ab678cfe87b20dd2967a51f2bd412e (patch) | |
tree | 083afd0cdfc47c7dd3382042d21746319b01dec9 /tests | |
parent | 2f20f6e6b2cc6f26794678d1db16659c484a001c (diff) | |
download | rpm-c411382194ab678cfe87b20dd2967a51f2bd412e.tar.gz rpm-c411382194ab678cfe87b20dd2967a51f2bd412e.tar.bz2 rpm-c411382194ab678cfe87b20dd2967a51f2bd412e.zip |
Add test case for scriptlet behavior
- The test-root has a shell but rpm doesn't know about it, add a
fakeshell metapackage that provides it. Should come in handy for
other cases as well, up to now we've been limited to lua scripts only.
- Test that all the "normal" scripts get executed, in expected order
and with expected arguments, on install, upgrade and erase.
- This would've saved the rather embarrassing breakage with commit
274dbf557d1cac90f7c278f9b6d6af05997d92df at least, but better
late than never as they say... It also serves to highlight and
document the arguably broken arguments to %pre- and %posttrans
scripts (ie always 0)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/data/SPECS/fakeshell.spec | 12 | ||||
-rw-r--r-- | tests/data/SPECS/scripts.spec | 31 | ||||
-rw-r--r-- | tests/rpmscript.at | 39 | ||||
-rw-r--r-- | tests/rpmtests.at | 1 |
5 files changed, 86 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 72b17ca16..ff7e49843 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -27,6 +27,7 @@ TESTSUITE_AT += rpmconfig.at TESTSUITE_AT += rpmmacro.at TESTSUITE_AT += rpmpython.at TESTSUITE_AT += rpmdepmatch.at +TESTSUITE_AT += rpmscript.at EXTRA_DIST += $(TESTSUITE_AT) ## testsuite data @@ -42,6 +43,8 @@ EXTRA_DIST += data/SPECS/hlinktest.spec EXTRA_DIST += data/SPECS/symlinktest.spec EXTRA_DIST += data/SPECS/deptest.spec EXTRA_DIST += data/SPECS/verifyscript.spec +EXTRA_DIST += data/SPECS/fakeshell.spec +EXTRA_DIST += data/SPECS/scripts.spec EXTRA_DIST += data/SOURCES/hello-1.0-modernize.patch EXTRA_DIST += data/SOURCES/hello-1.0.tar.gz EXTRA_DIST += data/SOURCES/hello-2.0.tar.gz diff --git a/tests/data/SPECS/fakeshell.spec b/tests/data/SPECS/fakeshell.spec new file mode 100644 index 000000000..88b5fe190 --- /dev/null +++ b/tests/data/SPECS/fakeshell.spec @@ -0,0 +1,12 @@ +Name: fakeshell +Version: 1.0 +Release: 1 +Summary: Fake provides for shell +License: GPL +BuildArch: noarch +Provides: /bin/sh + +%description +%{summary} + +%files diff --git a/tests/data/SPECS/scripts.spec b/tests/data/SPECS/scripts.spec new file mode 100644 index 000000000..fbb9bc989 --- /dev/null +++ b/tests/data/SPECS/scripts.spec @@ -0,0 +1,31 @@ +Name: scripts +Version: 1.0 +Release: %{rel} +Summary: Testing script behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%files +%defattr(-,root,root,-) + +%pretrans +echo %{name}-%{version}-%{release} PRETRANS $* + +%pre +echo %{name}-%{version}-%{release} PRE $* + +%post +echo %{name}-%{version}-%{release} POST $* + +%preun +echo %{name}-%{version}-%{release} PREUN $* + +%postun +echo %{name}-%{version}-%{release} POSTUN $* + +%posttrans +echo %{name}-%{version}-%{release} POSTTRANS $* diff --git a/tests/rpmscript.at b/tests/rpmscript.at new file mode 100644 index 000000000..ab4478504 --- /dev/null +++ b/tests/rpmscript.at @@ -0,0 +1,39 @@ +# rpmscript.at: rpm scriptlet tests + +AT_BANNER([RPM scriptlets]) + +# ------------------------------ +# +AT_SETUP([basic scripts and arguments]) +AT_KEYWORDS([verify]) +AT_CHECK([ +RPMDB_CLEAR +RPMDB_INIT +rm -rf "${TOPDIR}" + +runroot rpmbuild --quiet -bb /data/SPECS/fakeshell.spec +runroot rpmbuild --quiet -bb --define "rel 1" /data/SPECS/scripts.spec +runroot rpmbuild --quiet -bb --define "rel 2" /data/SPECS/scripts.spec + +runroot rpm -U "${TOPDIR}"/RPMS/noarch/fakeshell-1.0-1.noarch.rpm +runroot rpm -U "${TOPDIR}"/RPMS/noarch/scripts-1.0-1.noarch.rpm +runroot rpm -U "${TOPDIR}"/RPMS/noarch/scripts-1.0-2.noarch.rpm +runroot rpm -e scripts +], +[0], +[scripts-1.0-1 PRETRANS 0 +scripts-1.0-1 PRE 1 +scripts-1.0-1 POST 1 +scripts-1.0-1 POSTTRANS 0 +scripts-1.0-2 PRETRANS 0 +scripts-1.0-2 PRE 2 +scripts-1.0-2 POST 2 +scripts-1.0-1 PREUN 1 +scripts-1.0-1 POSTUN 1 +scripts-1.0-2 POSTTRANS 0 +scripts-1.0-2 PREUN 0 +scripts-1.0-2 POSTUN 0 +], +[]) +AT_CLEANUP + diff --git a/tests/rpmtests.at b/tests/rpmtests.at index 7f0807d0b..c1ea9c3cd 100644 --- a/tests/rpmtests.at +++ b/tests/rpmtests.at @@ -4,6 +4,7 @@ m4_include([rpmverify.at]) m4_include([rpmdb.at]) m4_include([rpmi.at]) m4_include([rpmbuild.at]) +m4_include([rpmscript.at]) m4_include([rpmvercmp.at]) m4_include([rpmdeps.at]) m4_include([rpmconflict.at]) |