From 145f26fa48102805ba5ffffd2874ba9983b1b9cd Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 22 Feb 2022 23:51:08 +0000 Subject: [PATCH] Add CI test --- .fmf/version | 1 + plans/basic.fmf | 5 +++++ tests/build-gating.fmf | 4 ++++ tests/simple-rpm/main.fmf | 6 ++++++ tests/simple-rpm/runtest.sh | 8 +++++++ tests/simple-rpm/test.spec | 42 +++++++++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+) create mode 100644 .fmf/version create mode 100644 plans/basic.fmf create mode 100644 tests/build-gating.fmf create mode 100644 tests/simple-rpm/main.fmf create mode 100755 tests/simple-rpm/runtest.sh create mode 100644 tests/simple-rpm/test.spec diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/plans/basic.fmf b/plans/basic.fmf new file mode 100644 index 0000000..c1627f9 --- /dev/null +++ b/plans/basic.fmf @@ -0,0 +1,5 @@ +summary: Basic smoke test +discover: + how: fmf +execute: + how: tmt diff --git a/tests/build-gating.fmf b/tests/build-gating.fmf new file mode 100644 index 0000000..a40b6a8 --- /dev/null +++ b/tests/build-gating.fmf @@ -0,0 +1,4 @@ +discover: + how: fmf +exexute: + how: tmt diff --git a/tests/simple-rpm/main.fmf b/tests/simple-rpm/main.fmf new file mode 100644 index 0000000..25ad4f8 --- /dev/null +++ b/tests/simple-rpm/main.fmf @@ -0,0 +1,6 @@ +summary: Test build a simple RPM package to ensure package notes are working +require: + - dnf + - dnf-plugins-core + - rpm-build +test: ./runtest.sh diff --git a/tests/simple-rpm/runtest.sh b/tests/simple-rpm/runtest.sh new file mode 100755 index 0000000..07afcd5 --- /dev/null +++ b/tests/simple-rpm/runtest.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -ex + +dnf -y build-dep test.spec +rpmbuild --define '_sourcedir .' --define '_builddir .' -bb test.spec +dnf -y build-dep test.spec -D "_with_ld_lld 1" +rpmbuild --with ld_lld --define '_sourcedir .' --define '_builddir .' -bb test.spec diff --git a/tests/simple-rpm/test.spec b/tests/simple-rpm/test.spec new file mode 100644 index 0000000..c5de261 --- /dev/null +++ b/tests/simple-rpm/test.spec @@ -0,0 +1,42 @@ +%bcond_with ld_lld + +%if %{with ld_lld} +%global extra_ldflags -fuse-ld=lld +%global _package_note_linker lld +%endif + +Name: test +Version: 1 +Release: 1 +Summary: Test package for checking package notes +License: MIT + +BuildRequires: gcc +# For %check +BuildRequires: binutils +BuildRequires: jq +%if %{with ld_lld} +BuildRequires: lld +%endif + +%description +Test package for checking package notes + +%build +echo 'int main(int argc, char **argv) { return 0; }' | %{build_cc} ${CFLAGS} -x c -c - -o main.o +%{build_cc} ${LDFLAGS} %{?extra_ldflags} main.o -o main + +# Package notes not supported with lld, so the the build succeeding is enough. +%if %{without ld_lld} +%check +# avoid any attempt to access the network by readelf +export DEBUGINFOD_URLS= + +readelf --notes ./main | sed -r -n 's/.*Packaging Metadata: (.*)/\1/p' | tee package-note.text + +test "`cat package-note.text | jq -r '[.type,.name,.version,.architecture]|join(" ")'`" == "rpm %{name} %{version}-%{release} %{_arch}" +%endif + +%changelog +* Sat Aug 6 2022 Jane Doe - 1-1 +- Dummy