1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#!/bin/sh
# Copyright 2016 Ghislain Antony Vaillant <ghisvail@gmail.com>
#
# This file is part of the autopkgtest testsuite for the libjsoncpp
# source package.
set -e
# Presence of $AUTOPKGTEST_TMP implies that someone will handle cleanup for us, so we
# can avoid duplicating the effort (signal handling, etc.) here.
if [ -z "$AUTOPKGTEST_TMP" ]
then
echo "Required envvar \"$AUTOPKGTEST_TMP\"is not set" >&2
exit 1
fi
# Copy testsuite source code.
cp -a ./src/test_lib_json/* "$AUTOPKGTEST_TMP"
cd "$AUTOPKGTEST_TMP"
if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
cat <<EOF > "$AUTOPKGTEST_TMP/toolchain.cmake"
set(CMAKE_C_COMPILER $DEB_HOST_GNU_TYPE-gcc)
set(CMAKE_CXX_COMPILER $DEB_HOST_GNU_TYPE-g++)
set(PKG_CONFIG_EXECUTABLE $DEB_HOST_GNU_TYPE-pkg-config)
EOF
CCFILE=-DCMAKE_TOOLCHAIN_FILE="$AUTOPKGTEST_TMP/toolchain.cmake"
else
CCFILE=
fi
cat <<EOF > CMakeLists.txt
cmake_minimum_required(VERSION 3.18)
project(jsoncpp_test)
find_package(jsoncpp REQUIRED)
add_executable(jsoncpp_test main.cpp jsontest.cpp jsontest.h fuzz.cpp fuzz.h)
target_link_libraries(jsoncpp_test PRIVATE JsonCpp::JsonCpp)
EOF
# Configure, build and execute.
mkdir build && cd build
cmake $CCFILE ..
make VERBOSE=1 -j$(nproc)
./jsoncpp_test
|