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.
This commit is contained in:
Tom Stellard 2022-04-19 18:17:32 +00:00
parent 7198391f75
commit d4fb9f8ed8
6 changed files with 61 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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

29
tests/fedora-flags/runtest.sh Executable file
View File

@ -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"