meta-netmodule-distro/classes/unittests.bbclass

46 lines
1.4 KiB
Plaintext

DEPENDS_class-target += "${PN}-native"
DEPENDS_class-native += "cpputest"
BUILD_CFLAGS +="-I${CPPUTEST_HOME}/include"
BUILD_CPPFLAGS +="-I${CPPUTEST_HOME}/include"
TEST_LIBRARY ?= "0"
do_compile_append_class-native () {
export CPPUTEST_HOME="${base_prefix}/usr/lib/cpputest/"
export CPPUTEST_ADDITIONAL_CFLAGS=" ${BUILD_CFLAGS}"
export CPPUTEST_ADDITIONAL_CPPFLAGS=" ${BUILD_CPPFLAGS}"
export CPPUTEST_ADDITIONAL_CXXFLAGS=" ${BUILD_CXXFLAGS}"
export CPPUTEST_ADDITIONAL_LDFLAGS=" ${BUILD_LDFLAGS}"
export UNITTEST_OUTPUT_XML=1
export BUILD_CONFIG="test"
export BUILD_TARGET="host"
export SILENCE=""
oe_runmake -f Makefile.utest.mk
if [ "${TEST_LIBRARY}" = "1" ]; then
export BUILD_TARGET=host
export BUILD_CONFIG=test
oe_runmake -f Makefile.host.mk
fi
}
do_install_append_class-native () {
if [ "${TEST_LIBRARY}" = "1" ]; then
# Install headers
libname=$(ls ${D}${includedir})
install -d ${D}${includedir}/$libname-test
install -d ${D}${includedir}/$libname-test/mocks
install -d ${D}${includedir}/$libname-test/utils
cp -r ${S}/src/* ${D}${includedir}/$libname-test
cp -r ${S}/tests/mocks/* ${D}${includedir}/$libname-test/mocks
cp -r ${S}/tests/utils/* ${D}${includedir}/$libname-test/utils
# Install test library
install -m 644 ${B}/test/host/*.a ${D}${libdir}
fi
}
BBCLASSEXTEND = "native nativesdk"