From d4fb9f8ed8cd9780656b2d1533f9da2cc4bc155f Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 19 Apr 2022 18:17:32 +0000 Subject: [PATCH] Import gcc-fedora-flags test from redhat-rpm-config Once this is committed, the version in redhat-rpm-config will be removed and redhat-rpm-config will use this test. --- tests/fedora-flags/hello.c | 5 +++++ tests/fedora-flags/hello.cpp | 5 +++++ tests/fedora-flags/main.c | 6 ++++++ tests/fedora-flags/main.cpp | 6 ++++++ tests/fedora-flags/main.fmf | 10 ++++++++++ tests/fedora-flags/runtest.sh | 29 +++++++++++++++++++++++++++++ 6 files changed, 61 insertions(+) create mode 100644 tests/fedora-flags/hello.c create mode 100644 tests/fedora-flags/hello.cpp create mode 100644 tests/fedora-flags/main.c create mode 100644 tests/fedora-flags/main.cpp create mode 100644 tests/fedora-flags/main.fmf create mode 100755 tests/fedora-flags/runtest.sh diff --git a/tests/fedora-flags/hello.c b/tests/fedora-flags/hello.c new file mode 100644 index 0000000..51b259b --- /dev/null +++ b/tests/fedora-flags/hello.c @@ -0,0 +1,5 @@ +#include + +void hello() { + printf("Hello World\n"); +} diff --git a/tests/fedora-flags/hello.cpp b/tests/fedora-flags/hello.cpp new file mode 100644 index 0000000..400612b --- /dev/null +++ b/tests/fedora-flags/hello.cpp @@ -0,0 +1,5 @@ +#include + +void hello() { + std::cout << "Hello World\n"; +} diff --git a/tests/fedora-flags/main.c b/tests/fedora-flags/main.c new file mode 100644 index 0000000..1a3455d --- /dev/null +++ b/tests/fedora-flags/main.c @@ -0,0 +1,6 @@ +void hello(); + +int main(int argc, char **argv) { + hello(); + return 0; +} diff --git a/tests/fedora-flags/main.cpp b/tests/fedora-flags/main.cpp new file mode 100644 index 0000000..1a3455d --- /dev/null +++ b/tests/fedora-flags/main.cpp @@ -0,0 +1,6 @@ +void hello(); + +int main(int argc, char **argv) { + hello(); + return 0; +} diff --git a/tests/fedora-flags/main.fmf b/tests/fedora-flags/main.fmf new file mode 100644 index 0000000..43934a7 --- /dev/null +++ b/tests/fedora-flags/main.fmf @@ -0,0 +1,10 @@ +summary: Test compiling with the Fedora C/CXX flags. +description: '' +component: + - gcc +test: ./runtest.sh +require: + - annobin-annocheck + - gcc + - gcc-c++ + - redhat-rpm-config diff --git a/tests/fedora-flags/runtest.sh b/tests/fedora-flags/runtest.sh new file mode 100755 index 0000000..01b656b --- /dev/null +++ b/tests/fedora-flags/runtest.sh @@ -0,0 +1,29 @@ +#!/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"