rpm-ostree/tests/vmcheck/test-layering.sh
Jonathan Lebon 812c431856 test-layering.sh: basic package layering test
This is a preliminary package layering test which simply installs the
foo package and verifies that it functions properly. A bunch of
primitives are added to libvm.sh to facilitate this and future tests.

Closes: #344
Approved by: cgwalters
2016-06-23 00:05:09 +00:00

80 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (C) 2016 Jonathan Lebon <jlebon@redhat.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -e
. ${commondir}/libtest.sh
. ${commondir}/libvm.sh
set -x
# XXX: this should be done by the test harness
test_cleanup() {
if vm_has_packages foo; then
vm_cmd rpm-ostree rollback
vm_reboot
fi
}
trap 'test_cleanup; _cleanup_tmpdir' EXIT
# make sure package foo is not already layered
if vm_has_files /usr/bin/foo; then
assert_not_reached "/usr/bin/foo already present"
elif vm_has_packages foo; then
assert_not_reached "foo already in rpmdb"
elif vm_has_layered_packages foo; then
assert_not_reached "foo already layered"
fi
vm_send /tmp/vmcheck ${commondir}/compose
cat > vmcheck.repo << EOF
[test-repo]
name=test-repo
baseurl=file:///tmp/vmcheck/compose/yum
EOF
vm_send /etc/yum.repos.d vmcheck.repo
vm_cmd rpm-ostree pkg-add foo
echo "ok pkg-add foo"
vm_reboot
if ! vm_has_files /usr/bin/foo; then
assert_not_reached "/usr/bin/foo not present"
elif ! vm_has_packages foo; then
assert_not_reached "foo not in rpmdb"
elif ! vm_has_layered_packages foo; then
assert_not_reached "foo not layered"
fi
echo "ok pkg foo present"
if ! vm_cmd foo | grep "Happy foobing!"; then
assert_not_reached "foo printed wrong output"
fi
echo "ok correct output"
vm_cmd rpm-ostree rollback
vm_reboot
if vm_has_layered_packages foo; then
assert_not_reached "foo is still layered after rollback"
fi
echo "ok rollback"