tests: Add test coverage for rpm-ostree container

This commit is contained in:
Colin Walters 2016-02-10 11:42:57 +01:00
parent 961a036c5b
commit 58cf2c9403
4 changed files with 109 additions and 3 deletions

View File

@ -1,5 +1,7 @@
include $(top_srcdir)/buildutil/glib-tap.mk include $(top_srcdir)/buildutil/glib-tap.mk
AM_TESTS_ENVIRONMENT = UNINSTALLEDTESTS=1 builddir=$(abs_builddir)
CLEANFILES += \ CLEANFILES += \
tests/setup-session.sh \ tests/setup-session.sh \
tests/compose/yum/empty tests/compose/yum/repodata/repomd.xml \ tests/compose/yum/empty tests/compose/yum/repodata/repomd.xml \
@ -57,6 +59,8 @@ test_programs = \
tests/jsonutil \ tests/jsonutil \
$(NULL) $(NULL)
test_scripts = tests/test-ucontainer.sh
installed_test_PROGRAMS += dbus-run-session installed_test_PROGRAMS += dbus-run-session
dbus_run_session_SOURCES = tests/dbus-run-session.c dbus_run_session_SOURCES = tests/dbus-run-session.c

View File

@ -267,11 +267,17 @@ add_canonicalized_string_array (GVariantBuilder *builder,
g_variant_builder_add (builder, "{sv}", notfound_key, g_variant_new_boolean (TRUE)); g_variant_builder_add (builder, "{sv}", notfound_key, g_variant_new_boolean (TRUE));
return TRUE; return TRUE;
} }
else else if (temp_error)
{ {
g_propagate_error (error, g_steal_pointer (&temp_error)); g_propagate_error (error, g_steal_pointer (&temp_error));
return FALSE; return FALSE;
} }
else
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Key %s is empty", key);
return FALSE;
}
} }
for (iter = input; iter && *iter; iter++) for (iter = input; iter && *iter; iter++)

View File

@ -18,6 +18,18 @@
# Boston, MA 02111-1307, USA. # Boston, MA 02111-1307, USA.
SRCDIR=$(dirname $0) SRCDIR=$(dirname $0)
_cleanup_tmpdir () {
if test -f ${test_tmpdir}.test; then
rm ${test_tmpdir} -rf
fi
}
if test -n "${UNINSTALLEDTESTS:-}"; then
test_tmpdir=$(mktemp -d test.XXXXXX)
touch ${test_tmpdir}/.test
trap _cleanup_tmpdir EXIT
cd ${test_tmpdir}
export PATH=${builddir}:${PATH}
fi
test_tmpdir=$(pwd) test_tmpdir=$(pwd)
export G_DEBUG=fatal-warnings export G_DEBUG=fatal-warnings
@ -30,11 +42,11 @@ export TEST_GPG_KEYID="472CDAFA"
export TEST_GPG_KEYHOME=${SRCDIR}/gpghome export TEST_GPG_KEYHOME=${SRCDIR}/gpghome
export OSTREE_GPG_HOME=${TEST_GPG_KEYHOME}/trusted export OSTREE_GPG_HOME=${TEST_GPG_KEYHOME}/trusted
if test -n "${OT_TESTS_DEBUG}"; then if test -n "${OT_TESTS_DEBUG:-}"; then
set -x set -x
fi fi
if test -n "$OT_TESTS_VALGRIND"; then if test -n "${OT_TESTS_VALGRIND:-}"; then
CMD_PREFIX="env G_SLICE=always-malloc valgrind -q --leak-check=full --num-callers=30 --suppressions=${SRCDIR}/ostree-valgrind.supp" CMD_PREFIX="env G_SLICE=always-malloc valgrind -q --leak-check=full --num-callers=30 --suppressions=${SRCDIR}/ostree-valgrind.supp"
fi fi

84
tests/test-ucontainer.sh Executable file
View File

@ -0,0 +1,84 @@
#!/bin/bash
#
# Copyright (C) 2016 Colin Walters <walters@verbum.org>
#
# 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 -euo pipefail
. $(dirname $0)/libtest.sh
echo "1..2"
rpm-ostree container init
if test -d ${SRCDIR}/compose; then
composedatadir=${SRCDIR}/compose
else
composedatadir=${SRCDIR}
fi
cp ${composedatadir}/test-repo.repo rpmmd.repos.d
cat >empty.conf <<EOF
[tree]
ref=empty
packages=empty
repos=test-repo
EOF
rpm-ostree container assemble empty.conf
assert_has_dir roots/empty.0
ostree --repo=repo rev-parse empty
echo "ok assemble"
cat >nobranch.conf <<EOF
[tree]
packages=empty
repos=test-repo
EOF
if rpm-ostree container assemble nobranch.conf 2>err.txt; then
assert_not_reached "nobranch.conf"
fi
cat >nopackages.conf <<EOF
[tree]
ref=empty
packages=
repos=test-repo
EOF
if rpm-ostree container assemble nopackages.conf 2>err.txt; then
assert_not_reached "nopackages.conf"
fi
cat >norepos.conf <<EOF
[tree]
ref=empty
packages=empty
EOF
if rpm-ostree container assemble norepos.conf 2>err.txt; then
assert_not_reached "norepos.conf"
fi
cat >notfoundpackage.conf <<EOF
[tree]
ref=notfound
packages=notfound
repos=test-repo
EOF
if rpm-ostree container assemble notfound.conf 2>err.txt; then
assert_not_reached "notfound.conf"
fi
echo "ok error conditions"