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"