Convert tests to tmt

Also pull the gcc-fedora-flags test from rpms/gcc and pull the
clang-fedora-flags from rpms/clang.
This commit is contained in:
Tom Stellard 2022-05-24 19:03:59 -07:00
parent a26aee055e
commit 81ddce57d9
12 changed files with 49 additions and 103 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,11 @@
summary: >
Check the that the environment variables for build flags are automatically set
https://fedoraproject.org/wiki/Changes/SetBuildFlagsBuildCheck
require:
- annobin-annocheck
- gcc
- gcc-c++
- make
test: ./runtest.sh

16
tests/build-gating.fmf Normal file
View File

@ -0,0 +1,16 @@
summary: Tests
discover:
- name: redhat-rpm-config-tests
how: fmf
- name: gcc-fedora-flags
how: fmf
url: https://src.fedoraproject.org/rpms/gcc.git
ref: rawhide
test: fedora-flags
- name: clang-fedora-flags
how: fmf
url: https://src.fedoraproject.org/rpms/clang.git
ref: rawhide
test: fedora-flags
execute:
how: tmt

View File

@ -0,0 +1,6 @@
summary: self-build test
require:
- dnf-plugins-core
- rpm-build
test: ./runtest.sh

7
tests/build-self/runtest.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
spec=$TMT_TREE/redhat-rpm-config.spec
dnf -y build-dep $spec
rpmbuild --define "_sourcedir $TMT_TREE" -ba $spec

View File

@ -1,5 +0,0 @@
#include <stdio.h>
void hello() {
printf("Hello World\n");
}

View File

@ -1,5 +0,0 @@
#include <iostream>
void hello() {
std::cout << "Hello World\n";
}

View File

@ -1,6 +0,0 @@
void hello();
int main(int argc, char **argv) {
hello();
return 0;
}

View File

@ -1,6 +0,0 @@
void hello();
int main(int argc, char **argv) {
hello();
return 0;
}

View File

@ -1,29 +0,0 @@
#!/bin/bash
set -ex
default_cflags=$(rpm -E '%{build_cflags}')
default_cxxflags=$(rpm -E '%{build_cxxflags}')
default_ldflags=$(rpm -E '%{build_ldflags}')
cflags=$(rpm -D '%toolchain gcc' -E '%{build_cflags}')
cxxflags=$(rpm -D '%toolchain gcc' -E '%{build_cxxflags}')
ldflags=$(rpm -D '%toolchain gcc' -E '%{build_ldflags}')
test "$default_cflags" = "$cflags"
test "$default_cxxflags" = "$cxxflags"
test "$default_ldflags" = "$ldflags"
gcc $cflags -o hello.o -c hello.c
annocheck hello.o
gcc $cflags -o main.o -c main.c
gcc $ldflags -o hello main.o hello.o
annocheck hello
./hello | grep "Hello World"
g++ $cxxflags -o hello-cpp.o -c hello.cpp
annocheck hello-cpp.o
g++ $cxxflags -o main-cpp.o -c main.cpp
g++ $ldflags -o hello-cpp main-cpp.o hello-cpp.o
annocheck hello-cpp
./hello-cpp | grep "Hello World"

View File

@ -0,0 +1,8 @@
summary: Test that we don't accidently introduce any new dependencies.
require:
- diffutils
- grep
- redhat-rpm-config
- rpm
test: ./runtest.sh

View File

@ -1,52 +0,0 @@
---
- hosts: localhost
tags:
- classic
tasks:
- dnf:
name: "*"
state: latest
- hosts: localhost
tags:
- classic
pre_tasks:
- import_role:
name: standard-test-source
vars:
fetch_only: True
roles:
- role: standard-test-basic
tags:
- classic
required_packages:
- rpm
# build-self
- dnf
- rpm-build
# clang/fedora-flags
- clang
#gcc-fedora-flags
- gcc
- gcc-c++
- annobin-annocheck
#auto-set-build-flags
- gcc
- gcc-c++
- annobin-annocheck
- make
# no-new-dependency
- diffutils
- grep
repositories:
- repo: https://src.fedoraproject.org/tests/clang.git
dest: clang
tests:
- build-self:
dir: .
run: "dnf -y build-dep {{ tenv_workdir }}/redhat-rpm-config.spec && rpmbuild --define '_sourcedir {{ tenv_workdir }}' -ba {{ tenv_workdir }}/redhat-rpm-config.spec"
- clang/fedora-flags
- gcc-fedora-flags
- no-new-dependency
- auto-set-build-flags