tests: Add test for compose

A local yum repository, which contains a dummy .rpm package adding
support for programs needed by the post-process phase, is created as
part of the test.

Since no libc is present, the empty.c program (which is a no-op)
directly invokes the interrupt 0x80 to exit.

The test works only on x86_64, it is skipped on other architectures.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2015-03-23 12:23:29 +01:00
parent b2c3e8a264
commit 27008e402a
6 changed files with 167 additions and 1 deletions

View File

@ -1,12 +1,36 @@
include $(top_srcdir)/buildutil/glib-tap.mk
# Needed by the compose test
tests/compose/yum/empty: tests/compose/yum/empty.c
$(CC) -nostdlib $< -o $@
tests/compose/yum/repodata/repomd.xml: tests/compose/yum/empty tests/compose/yum/empty.spec
(cd tests/compose/yum && \
rpmbuild --define "_sourcedir $(shell pwd)/tests/compose/yum" --define "_specdir $(shell pwd)/tests/compose/yum" --define "_builddir $(shell pwd)/tests/compose/yum" \
--define "_srcrpmdir $(shell pwd)/tests/compose/yum" --define "_rpmdir $(shell pwd)/tests/compose/yum" --define "_buildrootdir $(shell pwd)/tests/compose/yum/.build" \
-ba empty.spec && createrepo --database $(shell pwd)/tests/compose/yum/)
tests/compose/test-repo.repo: tests/compose/test-repo.repo.in tests/compose/yum/repodata/repomd.xml
cat $< | sed -e "s|%WHERE%|$(installed_testdir)|" > $@
tests_jsonutil_CPPFLAGS = -I $(srcdir)/src/libpriv
tests_jsonutil_CFLAGS = $(PKGDEP_RPMOSTREE_CFLAGS)
tests_jsonutil_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostree.la
installed_test_data = tests/libtest.sh
tests/test-compose.sh: tests/compose/test-repo.repo
installed_test_data = tests/libtest.sh \
tests/compose/test-repo.repo \
tests/compose/test-repo.json \
tests/compose/test-repo.repo.in \
$(NULL)
nobase_installed_test_DATA += $(shell find tests/compose/yum/ -type f) \
$(NULL)
installed_test_scripts = \
tests/test-compose.sh \
tests/test-basic.sh \
$(NULL)

View File

@ -0,0 +1,11 @@
{
"ref": "fedora/test",
"repos": ["test-repo"],
"bootstrap_packages": ["empty"],
"selinux": true,
"packages": []
}

View File

@ -0,0 +1,6 @@
[test-repo]
name=test-repo
baseurl=file://%WHERE%/tests/compose/yum
enabled=1
gpgcheck=0
skip_if_unavailable=False

27
tests/compose/yum/empty.c Normal file
View File

@ -0,0 +1,27 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2015 Red Hat Inc.
*
* This program 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 licence 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.
*/
int
_start ()
{
__asm__ __volatile__ ("mov $1, %eax");
__asm__ __volatile__ ("mov $0, %ebx\n");
__asm__ __volatile__ ("int $0x80\n");
}

View File

@ -0,0 +1,60 @@
%define __spec_install_post %{nil}
%define debug_package %{nil}
%define __os_install_post %{_dbpath}/brp-compress
Summary: A very (un)useful package
Name: empty
Version: 1.0
Release: 1
License: GPL+
Group: Development/Tools
URL: http://foo.bar.com
BuildArch: x86_64
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%description
%{summary}
%prep
%build
%install
mkdir -p %{buildroot}/boot
mkdir -p %{buildroot}/var/share/
mkdir -p %{buildroot}/var/tmp/
mkdir -p %{buildroot}/usr/sbin
mkdir -p %{buildroot}/etc
mkdir -p %{buildroot}/usr/lib
mkdir -p %{buildroot}/usr/lib/tmpfiles.d
for i in foo bar hello world; do
echo $i > %{buildroot}/var/share/$i
done
touch %{buildroot}/boot/vmlinuz-kernel
echo "nobody:x:99:99:Nobody:/:/sbin/nologin" > %{buildroot}/etc/passwd
touch %{buildroot}/etc/group
touch %{buildroot}/etc/nsswitch.conf
cp empty %{buildroot}/usr/sbin/depmod
cp empty %{buildroot}/usr/sbin/dracut
touch %{buildroot}/var/tmp/initramfs.img
%clean
rm -rf %{buildroot}
%files
/var/share/*
/boot/*
/usr/sbin/*
/usr/lib/*
/var/tmp/*
/etc/*
%changelog
* Tue Mar 17 2015 Giuseppe Scrivano <gscrivan@redhat.com> 1.0-1
- First Build
EOF

38
tests/test-compose.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
#
# Copyright (C) 2015 Red Hat Inc.
#
# 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
. $(dirname $0)/libtest.sh
check_root_test
# Workaround a debugging message "Missing callback called fullpath" that let the test fails.
# Remove once it doesn't happen anymore.
unset G_DEBUG
(arch | grep -q x86_64) || { echo 1>&2 "$0 can be run only on x86_64"; echo "1..0" ; exit 0; }
echo "1..1"
ostree init --repo=repo --mode=archive-z2
echo "ok setup"
rpm-ostree --repo=repo compose tree $SRCDIR/test-repo.json