librdkafka/tests/devel-usability/runtest.sh
Sergio Arroutbi 9c6a8bee13 Fix test compilation to allow correct gating
Related: rhbz#2032923

Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
2022-02-08 10:17:29 +01:00

38 lines
833 B
Bash
Executable File

#!/bin/bash
set -e
set -x
TEST_SOURCE=kafka-test
C_TEST_TARGET="${TEST_SOURCE}.c"
CXX_TEST_TARGET="${TEST_SOURCE}.cpp"
C_BINARY="${TEST_SOURCE}-c"
CXX_BINARY="${TEST_SOURCE}-cpp"
CFLAGS="$(rpm --eval '%{build_cflags}')"
CXXFLAGS="$(rpm --eval '%{build_cxxflags}')"
LDFLAGS="$(rpm --eval '%{build_ldflags}')"
LIBCFLAGS="$(pkg-config rdkafka --libs --cflags)"
LIBCXXFLAGS="$(pkg-config rdkafka++ --libs --cflags)"
# build target using distribution-specific flags
gcc -std=c11 $CFLAGS $LDFLAGS -o $C_BINARY $C_TEST_TARGET $LIBCFLAGS
g++ -std=c++11 $CXXFLAGS $LDFLAGS -o $CXX_BINARY $CXX_TEST_TARGET $LIBCXXFLAGS
# test that target exists
test -f ./$C_BINARY
test -f ./$CXX_BINARY
# test that target is executable
test -x ./$C_BINARY
test -x ./$CXX_BINARY
# test that target runs successfully
./$C_BINARY -h
./$CXX_BINARY -h