rpm/tests/rpmverify.at

614 lines
14 KiB
Plaintext

# rpmverify.at: rpm verification tests
AT_BANNER([RPM verification])
# ------------------------------
#
AT_SETUP([dependency problems])
AT_KEYWORDS([verify])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild --quiet -bb \
--define "pkg one" \
--define "reqs deptest-two" \
/data/SPECS/deptest.spec
runroot rpm -U --nodeps /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
runroot rpm -Va --nofiles
],
[1],
[Unsatisfied dependencies for deptest-one-1.0-1.noarch:
deptest-two is needed by (installed) deptest-one-1.0-1.noarch
],
[])
AT_CLEANUP
# Test file verify when no errors expected.
# Ignore dependencies here as we're not testing for them, and
# --nogroup --nouser is required when running tests as non-root.
AT_SETUP([files with no problems])
AT_KEYWORDS([verify])
AT_CHECK([
RPMDB_INIT
runroot rpm -U --nodeps --noscripts --ignorearch --ignoreos \
/data/RPMS/hello-1.0-1.i386.rpm
runroot rpm -Va --nodeps --nouser --nogroup
],
[0],
[],
[])
AT_CLEANUP
# Test file verify when no errors expected in verbose mode.
AT_SETUP([files with no problems in verbose mode])
AT_KEYWORDS([verify])
AT_CHECK([
RPMDB_INIT
runroot rpm -U --nodeps --noscripts --ignorearch --ignoreos \
/data/RPMS/hello-1.0-1.i386.rpm
runroot rpm -Vva --nodeps --nouser --nogroup
],
[0],
[......... /usr/local/bin/hello
......... /usr/share/doc/hello-1.0
......... d /usr/share/doc/hello-1.0/FAQ
],
[])
AT_CLEANUP
# Test file verify when no errors expected in verbose mode.
AT_SETUP([directory replaced with a directory symlink])
AT_KEYWORDS([verify])
AT_CHECK([
RPMDB_INIT
tf="${RPMTEST}"/opt/foo
rm -rf "${RPMTEST}"/opt/*
runroot rpmbuild --quiet -bb \
--define "ver 1.0" \
--define "filetype datadir" \
--define "filedata README1" \
--define "user $(id -u -n)" \
--define "grp $(id -g -n)" \
/data/SPECS/replacetest.spec
runroot rpm -U /build/RPMS/noarch/replacetest-1.0-1.noarch.rpm
mv "${RPMTEST}"/opt/foo "${RPMTEST}"/opt/was
ln -s was "${RPMTEST}"/opt/foo
runroot rpm -Vv replacetest
],
[0],
[......... /opt/foo
......... /opt/foo/README1
......... /opt/goo
......... /opt/zoo
],
[])
AT_CLEANUP
AT_SETUP([directory replaced with an invalid directory symlink])
AT_KEYWORDS([verify])
AT_XFAIL_IF([test `id -u` != 0 ])
AT_CHECK([
RPMDB_INIT
tf="${RPMTEST}"/opt/foo
rm -rf "${RPMTEST}"/opt/*
runroot rpmbuild --quiet -bb \
--define "ver 1.0" \
--define "filetype datadir" \
--define "filedata README1" \
/data/SPECS/replacetest.spec
runroot rpm -U /build/RPMS/noarch/replacetest-1.0-1.noarch.rpm
mv "${RPMTEST}"/opt/foo "${RPMTEST}"/opt/was
ln -s was "${RPMTEST}"/opt/foo
chown -h bin "${RPMTEST}"/opt/foo
runroot rpm -Vv --nouser --nogroup replacetest
],
[1],
[....L.... /opt/foo
......... /opt/foo/README1
......... /opt/goo
......... /opt/zoo
],
[])
AT_CLEANUP
# Test file verify after mutilating the files a bit.
AT_SETUP([verify from db, with problems present])
AT_KEYWORDS([verify])
AT_CHECK([
RPMDB_INIT
runroot rpm -U --nodeps --noscripts --ignorearch --ignoreos \
/data/RPMS/hello-1.0-1.i386.rpm
rm -f "${RPMTEST}"/usr/share/doc/hello-1.0/FAQ
chmod u-x "${RPMTEST}"/usr/local/bin/hello
dd if=/dev/zero of="${RPMTEST}"/usr/local/bin/hello \
conv=notrunc bs=1 seek=5 count=6 2> /dev/null
runroot rpm -Va --nodeps --nouser --nogroup
],
[1],
[.M5....T. /usr/local/bin/hello
missing d /usr/share/doc/hello-1.0/FAQ
],
[])
AT_CLEANUP
# Test file verify from original package after mutilating the files a bit.
AT_SETUP([verify from package, with problems present])
AT_KEYWORDS([verify])
AT_CHECK([
RPMDB_INIT
runroot rpm -U --nodeps --noscripts --ignorearch --ignoreos \
/data/RPMS/hello-1.0-1.i386.rpm
rm -f "${RPMTEST}"/usr/share/doc/hello-1.0/FAQ
chmod u-x "${RPMTEST}"/usr/local/bin/hello
dd if=/dev/zero of="${RPMTEST}"/usr/local/bin/hello \
conv=notrunc bs=1 seek=5 count=6 2> /dev/null
runroot rpm -Vp --nodeps --nouser --nogroup /data/RPMS/hello-1.0-1.i386.rpm
],
[1],
[.M5....T. /usr/local/bin/hello
missing d /usr/share/doc/hello-1.0/FAQ
],
[])
AT_CLEANUP
AT_SETUP([verify file attribute filtering])
AT_KEYWORDS([query])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild -bb --quiet \
/data/SPECS/vattrtest.spec
runroot rpm -U /build/RPMS/noarch/vattrtest-1.0-1.noarch.rpm
runroot_other touch /opt/vattrtest/g
runroot_other chmod 644 /opt/vattrtest/g
cmd="rpm -Vv --nouser --nogroup"
for filter in --noconfig --noghost --noartifact -A -c -d -L; do
echo ${filter}
runroot ${cmd} ${filter} vattrtest
done
],
[ignore],
[--noconfig
......... /opt/vattrtest
......... a /opt/vattrtest/a
......... d /opt/vattrtest/d
......... g /opt/vattrtest/g
......... l /opt/vattrtest/l
......... m /opt/vattrtest/m
......... r /opt/vattrtest/r
--noghost
......... /opt/vattrtest
......... a /opt/vattrtest/a
......... c /opt/vattrtest/c
......... c /opt/vattrtest/cn
......... d /opt/vattrtest/d
......... l /opt/vattrtest/l
......... m /opt/vattrtest/m
......... r /opt/vattrtest/r
--noartifact
......... /opt/vattrtest
......... c /opt/vattrtest/c
......... c /opt/vattrtest/cn
......... d /opt/vattrtest/d
......... g /opt/vattrtest/g
......... l /opt/vattrtest/l
......... m /opt/vattrtest/m
......... r /opt/vattrtest/r
-A
......... a /opt/vattrtest/a
-c
......... c /opt/vattrtest/c
......... c /opt/vattrtest/cn
-d
......... d /opt/vattrtest/d
-L
......... l /opt/vattrtest/l
],
[])
AT_CLEANUP
# Test verify script success & failure behavior
# Ignoring stderr spew for now
AT_SETUP([verifyscript failure])
AT_KEYWORDS([verify])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild --quiet -bb /data/SPECS/verifyscript.spec
runroot rpm -U --nodeps /build/RPMS/noarch/verifyscript-1.0-1.noarch.rpm
rm -f "${RPMTEST}"/var/checkme
runroot rpm -V --nodeps verifyscript
],
[1],
[],
[ignore])
AT_CLEANUP
AT_SETUP([verifyscript success])
AT_KEYWORDS([verify])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild --quiet -bb /data/SPECS/verifyscript.spec
runroot rpm -U --nodeps /build/RPMS/noarch/verifyscript-1.0-1.noarch.rpm
touch "${RPMTEST}"/var/checkme
runroot rpm -V --nodeps verifyscript
],
[0],
[],
[])
AT_CLEANUP
# ------------------------------
# shared file timestamp behavior
AT_SETUP([shared file timestamp behavior])
AT_KEYWORDS([verify])
AT_CHECK([
RPMDB_INIT
# create packages sharing a file but with different timestamp
for p in "one" "two"; do
runroot rpmbuild --quiet -bb \
--define "pkg $p" \
--define "filedata same_stuff" \
/data/SPECS/conflicttest.spec
sleep 1
done
# first instance of a shared file is the one that actually gets created,
# force the order so we know what to expect as these dont depend on each other
runroot rpm -U --noorder /build/RPMS/noarch/conflictone-1.0-1.noarch.rpm /build/RPMS/noarch/conflicttwo-1.0-1.noarch.rpm
runroot rpm -e conflicttwo
runroot rpm -Va --nouser --nogroup
],
[0],
[],
[])
AT_CLEANUP
# ------------------------------
AT_SETUP([minimize writes (files)])
AT_KEYWORDS([upgrade verify min_writes])
RPMDB_INIT
for v in "1.0" "2.0"; do
runroot rpmbuild --quiet -bb \
--define "ver $v" \
--define "filetype file" \
--define "filedata foo" \
/data/SPECS/replacetest.spec
done
for v in "3.0" "4.0"; do
runroot rpmbuild --quiet -bb \
--define "ver $v" \
--define "filetype file" \
--define "filedata fox" \
/data/SPECS/replacetest.spec
done
AT_CHECK([
RPMDB_INIT
tf="${RPMTEST}"/opt/foo
rm -rf "${tf}"*
runroot rpm -i /build/RPMS/noarch/replacetest-1.0-1.noarch.rpm
cat "${tf}"
touch -t 201703171717 ${tf}
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-2.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
cat "${tf}"
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
cat "${tf}"
echo "xx" > "${tf}"
cat "${tf}"
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-4.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
cat "${tf}"
touch -t 201703171717 ${tf}
runroot rpm -U --oldpackage \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
cat "${tf}"
],
[0],
[foo
foo
fox
xx
fox
fox
],
[])
AT_CHECK([
RPMDB_INIT
tf="${RPMTEST}"/opt/foo
rm -rf "${tf}"*
runroot rpm -i /build/RPMS/noarch/replacetest-1.0-1.noarch.rpm
cat "${tf}"
touch -t 201703171717 ${tf}
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-2.0-1.noarch.rpm > output.txt 2>&1
runroot rpm -Va --nouser --nogroup replacetest
grep -c "touch" output.txt
cat "${tf}"
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm > output.txt 2>&1
runroot rpm -Va --nouser --nogroup replacetest
grep -c "touch" output.txt
cat "${tf}"
echo "xx" > "${tf}"
cat "${tf}"
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-4.0-1.noarch.rpm > output.txt 2>&1
runroot rpm -Va --nouser --nogroup replacetest
grep -c "touch" output.txt
cat "${tf}"
touch -t 201703171717 ${tf}
runroot rpm -U -Uvv --fsmdebug --oldpackage \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm > output.txt 2>&1
runroot rpm -Va --nouser --nogroup replacetest
grep -c "touch" output.txt
cat "${tf}"
],
[0],
[foo
2
foo
1
fox
xx
1
fox
2
fox
],
[])
AT_CLEANUP
AT_SETUP([minimize writes (hardlinks)])
AT_KEYWORDS([upgrade verify min_writes])
RPMDB_INIT
for v in "0" "1"; do
runroot rpmbuild --quiet -bb --define "ver ${v}" /data/SPECS/hlbreak.spec
done
AT_CHECK([
RPMDB_INIT
runroot rpm -U --define "_minimize_writes 1" /build/RPMS/noarch/hlbreak-0-0.noarch.rpm
runroot rpm -Vav --nouser --nogroup
runroot rpm -U --define "_minimize_writes 1" /build/RPMS/noarch/hlbreak-1-0.noarch.rpm
runroot rpm -Vav --nouser --nogroup
],
[0],
[......... /opt/file2
......... /opt/file1
......... /opt/file2
],
)
AT_CLEANUP
AT_SETUP([minimize writes (symlinks)])
AT_KEYWORDS([upgrade verify min_writes])
RPMDB_INIT
for v in "1.0" "2.0"; do
runroot rpmbuild --quiet -bb \
--define "ver $v" \
--define "filetype link" \
--define "filedata doh" \
/data/SPECS/replacetest.spec
done
for v in "3.0" "4.0"; do
runroot rpmbuild --quiet -bb \
--define "ver $v" \
--define "filetype link" \
--define "filedata fox" \
/data/SPECS/replacetest.spec
done
AT_CHECK([
RPMDB_INIT
tf="${RPMTEST}"/opt/foo
rm -rf "${tf}"*
runroot rpm -i /build/RPMS/noarch/replacetest-1.0-1.noarch.rpm
readlink "${tf}"
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-2.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
readlink "${tf}"
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
readlink "${tf}"
ln -sf "xx" "${tf}"
readlink "${tf}"
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-4.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
readlink "${tf}"
runroot rpm -U --oldpackage \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
readlink "${tf}"
],
[0],
[doh
doh
fox
xx
fox
fox
],
[])
AT_CHECK([
RPMDB_INIT
tf="${RPMTEST}"/opt/foo
rm -rf "${tf}" "${tf}".rpm*
runroot rpm -i /build/RPMS/noarch/replacetest-1.0-1.noarch.rpm
readlink "${tf}"
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-2.0-1.noarch.rpm > output.txt 2>&1
runroot rpm -Va --nouser --nogroup replacetest
grep -c "touch" output.txt
readlink "${tf}"
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm > output.txt 2>&1
runroot rpm -Va --nouser --nogroup replacetest
grep -c "touch" output.txt
readlink "${tf}"
ln -sf "xx" "${tf}"
readlink "${tf}"
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-4.0-1.noarch.rpm > output.txt 2>&1
runroot rpm -Va --nouser --nogroup replacetest
grep -c "touch" output.txt
readlink "${tf}"
runroot rpm -U -Uvv --fsmdebug --oldpackage \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm > output.txt 2>&1
runroot rpm -Va --nouser --nogroup replacetest
grep -c "touch" output.txt
readlink "${tf}"
],
[0],
[doh
2
doh
1
fox
xx
1
fox
2
fox
],
[])
AT_CLEANUP
AT_SETUP([minimize writes (SUID files)])
AT_KEYWORDS([upgrade verify min_writes])
AT_CHECK([
RPMDB_INIT
tf="${RPMTEST}"/opt/foo
rm -rf "${tf}" "${tf}".rpm*
for v in "1.0" "2.0"; do
runroot rpmbuild --quiet -bb \
--define "ver $v" \
--define "filetype file" \
--define "filedata foo" \
--define "fileattr %attr(2755,-,-)" \
/data/SPECS/replacetest.spec
done
runroot rpm -U /build/RPMS/noarch/replacetest-1.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-2.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
chmod 777 "${tf}"
runroot rpm -U \
--oldpackage \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-1.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup replacetest
],
[0],
[],
[])
AT_CLEANUP
AT_SETUP([verify empty/no capabilities 1])
AT_KEYWORDS([verify])
AT_SKIP_IF([$CAP_DISABLED])
AT_CHECK([
RPMDB_INIT
runroot rpm -U --nocaps --ignoreos \
/data/RPMS/capstest-1.0-1.noarch.rpm
runroot rpm -Va --nouser --nogroup
],
[1],
[........P /a/emptyCaps1
........P /a/emptyCaps2
],
[])
AT_CLEANUP
AT_SETUP([verify empty/no capabilities 2])
AT_KEYWORDS([verify])
AT_SKIP_IF([$CAP_DISABLED])
AT_CHECK([
RPMDB_INIT
runroot rpm -U --nocaps --nodeps --noscripts --ignorearch --ignoreos \
/data/RPMS/hello-1.0-1.ppc64.rpm
runroot rpm -Va --nouser --nogroup --nodeps | grep "/bin/hello"
],
[1],
[],
[])
AT_CLEANUP