summaryrefslogtreecommitdiff
path: root/tests/rpmquery.at
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rpmquery.at')
-rw-r--r--tests/rpmquery.at385
1 files changed, 385 insertions, 0 deletions
diff --git a/tests/rpmquery.at b/tests/rpmquery.at
new file mode 100644
index 0000000..b7b800a
--- /dev/null
+++ b/tests/rpmquery.at
@@ -0,0 +1,385 @@
+# rpmquery.at: test rpmquery
+#
+# Copyright (C) 2007 Ralf Corsépius <corsepiu@fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+AT_BANNER([RPM queries])
+
+# ------------------------------
+AT_SETUP([rpm --qf -p *.i386.rpm])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ -q --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" \
+ -p "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+],
+[0],
+[hello-1.0-1.i386
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([rpm --qf -p *.src.rpm])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ -q --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" \
+ -p "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
+],
+[0],
+[hello-1.0-1.i386
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([rpm -ql -p *.src.rpm])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ -ql \
+ -p "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
+],
+[0],
+[hello-1.0.tar.gz
+hello.spec
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([rpmspec -q])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpmspec \
+ -q --qf "%{name}" "${abs_srcdir}"/data/SPECS/hello.spec
+],
+[0],
+[hello],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([rpm -ql -p *.i386.rpm])
+AT_KEYWORDS([query])
+AT_CHECK([
+rpm \
+ -ql \
+ -p "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+],
+[0],
+[/usr/local/bin/hello
+/usr/share/doc/hello-1.0
+/usr/share/doc/hello-1.0/FAQ
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Test query on manifest
+AT_SETUP([rpm -qp <manifest>])
+AT_KEYWORDS([query])
+AT_CHECK([
+cat << EOF > query.mft
+"${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+"${abs_srcdir}"/data/RPMS/hello-1.0-1.ppc64.rpm
+"${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+EOF
+run rpm -qp --qf "%{nvr}\n" query.mft
+],
+[0],
+[hello-1.0-1
+hello-1.0-1
+foo-1.0-1
+],
+[])
+AT_CLEANUP
+
+# ------------------------------
+# Try to check "scripts"
+# * Gets rpmpopt-$(VERSION) involved
+AT_SETUP([rpm -q --scripts -p *.i386.rpm])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ -q --scripts \
+ -p "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+],
+[0],
+[preinstall program: /bin/sh
+postinstall program: /bin/sh
+preuninstall program: /bin/sh
+postuninstall program: /bin/sh
+],
+[ignore])
+AT_CLEANUP
+
+
+# ------------------------------
+# install a package into a local rpmdb
+# * Shall only work with relocation
+# * Use --ignorearch because we don't know the arch
+AT_SETUP([rpm -qil hello])
+AT_KEYWORDS([rpmdb install query])
+
+AT_CHECK([
+RPMDB_CLEAR
+RPMDB_INIT
+
+tpkg="hello-1.0-1.ppc64.rpm"
+cp "${RPMDATA}/RPMS/$tpkg" "${RPMTEST}"
+
+runroot rpm \
+ --noscripts --nodeps --ignorearch --relocate=/usr="${abs_builddir}"/testing/check \
+ -i "${tpkg}"
+],
+[0])
+
+AT_CHECK([
+runroot rpm \
+ -q hello
+],
+[0],
+[hello-1.0-1.ppc64
+],
+[ignore])
+
+cat > expout << _ATEOF
+${abs_builddir}/testing/check/local/bin/hello
+${abs_builddir}/testing/check/share/doc/hello-1.0
+${abs_builddir}/testing/check/share/doc/hello-1.0/FAQ
+_ATEOF
+
+AT_CHECK([
+runroot rpm \
+ -ql hello
+],
+[0],
+[expout],
+[ignore])
+
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([integer array query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="[[%{filemodes}\n]]" \
+ -qp "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+],
+[0],
+[33257
+16877
+33188
+],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([formatted filesbypkg query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="[[%-10{=NAME} %{FILENAMES}\n]]" \
+ -qp "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+],
+[0],
+[hello /usr/local/bin/hello
+hello /usr/share/doc/hello-1.0
+hello /usr/share/doc/hello-1.0/FAQ
+],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([hex formatted integer array extension query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="[[%5{longfilesizes:hex}\n]]" \
+ -qp "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+],
+[0],
+[ b40
+ 1000
+ 24
+],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([base64 extension query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="%{pkgid:base64}" \
+ -qp "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+],
+[0],
+[qt8W635v5FKy1pILrW+0uw==
+],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([integer array perms format query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="[[%{filemodes:perms}\n]]" \
+ -qp "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+],
+[0],
+[-rwxr-x--x
+drwxr-xr-x
+-rw-r--r--
+],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([string array query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="[[%{basenames} ]]" \
+ -qp "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+],
+[0],
+[hello hello-1.0 FAQ ],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([empty string array query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="[[%{basenames}]]" \
+ -qp "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+],
+[0],
+[],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([empty string array extension array format])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="[[%{filenames}]]" \
+ -qp "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+],
+[0],
+[],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([empty string array extension query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="%{filenames}" \
+ -qp "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+],
+[0],
+[(none)],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([different sizes arrays query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="[[%{basenames} %{changelogname}]]" \
+ -qp "${abs_srcdir}"/data/RPMS/hello-1.0-1.i386.rpm
+],
+[0],
+[],
+[error: incorrect format: array iterator used with different sized arrays
+])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([non-existent string tag])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="%{vendor}" \
+ -qp "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+],
+[0],
+[(none)],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([non-existent integer tag query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="%{installcolor}" \
+ -qp "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+],
+[0],
+[(none)],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([conditional queryformat])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="%|name?{%{name}}:{no}| %|installtime?{%{installtime}}:{(not installed)}|" \
+ -qp "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+],
+[0],
+[foo (not installed)],
+[])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([invalid tag query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="%{notag}" \
+ -qp "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+],
+[0],
+[],
+[error: incorrect format: unknown tag
+])
+AT_CLEANUP
+
+# ------------------------------
+AT_SETUP([invalid data for format query])
+AT_KEYWORDS([query])
+AT_CHECK([
+run rpm \
+ --queryformat="%{name:depflags}" \
+ -qp "${abs_srcdir}"/data/RPMS/foo-1.0-1.noarch.rpm
+],
+[0],
+[(not a number)],
+[])
+AT_CLEANUP