Add some basic tests for config file behavior
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 21 Nov 2008 23:15:20 +0000 (01:15 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 21 Nov 2008 23:15:20 +0000 (01:15 +0200)
tests/Makefile.am
tests/data/SPECS/configtest.spec [new file with mode: 0644]
tests/rpmconfig.at [new file with mode: 0644]
tests/rpmtests.at

index 54e2b86..f777640 100644 (file)
@@ -21,6 +21,7 @@ TESTSUITE_AT += rpmbuild.at
 TESTSUITE_AT += rpmi.at
 TESTSUITE_AT += rpmvercmp.at
 TESTSUITE_AT += rpmconflict.at
+TESTSUITE_AT += rpmconfig.at
 EXTRA_DIST += $(TESTSUITE_AT)
 
 ## testsuite data
@@ -28,6 +29,7 @@ EXTRA_DIST += data/SPECS/hello.spec
 EXTRA_DIST += data/SPECS/foo.spec
 EXTRA_DIST += data/SPECS/versiontest.spec
 EXTRA_DIST += data/SPECS/conflicttest.spec
+EXTRA_DIST += data/SPECS/configtest.spec
 EXTRA_DIST += data/SOURCES/hello-1.0.tar.gz
 EXTRA_DIST += data/RPMS/foo-1.0-1.noarch.rpm
 EXTRA_DIST += data/RPMS/hello-1.0-1.i386.rpm
diff --git a/tests/data/SPECS/configtest.spec b/tests/data/SPECS/configtest.spec
new file mode 100644 (file)
index 0000000..5ea7cae
--- /dev/null
@@ -0,0 +1,23 @@
+Name:          configtest
+Version:       %{ver}
+Release:       1
+Summary:       Testing config file behavior
+
+Group:         Testing
+License:       GPL
+BuildArch:     noarch
+
+%description
+%{summary}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}
+echo "%{filedata}" > $RPM_BUILD_ROOT/%{_sysconfdir}/my.conf
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%config %{_sysconfdir}/my.conf
diff --git a/tests/rpmconfig.at b/tests/rpmconfig.at
new file mode 100644 (file)
index 0000000..db16307
--- /dev/null
@@ -0,0 +1,93 @@
+#    rpmvercmp.at: rpm config file behavior tests
+
+# ------------------------------
+# (Build and) upgrade package with config file, no backup here
+AT_SETUP([rpm -U to package with unchanged config file])
+AT_CHECK([
+RPMDB_CLEAR
+rm -rf "${TOPDIR}"
+rm -rf "${RPMTEST}/etc/my.conf"
+
+for v in "1.0" "2.0"; do
+    run rpmbuild --quiet -bb \
+        --define "ver $v" \
+       --define "filedata foo" \
+          ${RPMDATA}/SPECS/configtest.spec
+done
+
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
+],
+[0],
+)
+AT_CLEANUP
+#
+# ------------------------------
+# Upgrade package with locally modified config file, unchanged in pkg
+AT_SETUP([rpm -U to package with locally modified config file])
+AT_CHECK([
+RPMDB_CLEAR
+rm -rf "${TOPDIR}"
+rm -rf "${RPMTEST}/etc/my.conf"
+
+for v in "1.0" "2.0"; do
+    run rpmbuild --quiet -bb \
+        --define "ver $v" \
+       --define "filedata foo" \
+          ${RPMDATA}/SPECS/configtest.spec
+done
+
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
+echo "otherstuff" > "${RPMTEST}"/etc/my.conf
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
+],
+[0],
+)
+AT_CLEANUP
+
+# ------------------------------
+# Upgrade package with unmodified config file, changed in pkg
+AT_SETUP([rpm -U to package with unchanged config file])
+AT_CHECK([
+RPMDB_CLEAR
+rm -rf "${TOPDIR}"
+rm -rf "${RPMTEST}/etc/my.conf"
+
+for v in "1.0" "2.0"; do
+    run rpmbuild --quiet -bb \
+        --define "ver $v" \
+       --define "filedata foo-$v" \
+          ${RPMDATA}/SPECS/configtest.spec
+done
+
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
+],
+[0],
+)
+AT_CLEANUP
+
+# ------------------------------
+# Upgrade package with locally modified config file, changed in pkg
+AT_SETUP([rpm -U to package with modified config file])
+AT_CHECK([
+RPMDB_CLEAR
+rm -rf "${TOPDIR}"
+rm -rf "${RPMTEST}/etc/my.conf"
+
+for v in "1.0" "2.0"; do
+    run rpmbuild --quiet -bb \
+        --define "ver $v" \
+       --define "filedata foo-$v" \
+          ${RPMDATA}/SPECS/configtest.spec
+done
+
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
+echo "otherstuff" > "${RPMTEST}"/etc/my.conf
+runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
+],
+[0],
+[ignore],
+[warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
+)
+AT_CLEANUP
index ebcb0c6..f18b789 100644 (file)
@@ -5,3 +5,4 @@ m4_include([rpmi.at])
 m4_include([rpmbuild.at])
 m4_include([rpmvercmp.at])
 m4_include([rpmconflict.at])
+m4_include([rpmconfig.at])