File: run_examples

package info (click to toggle)
msgpack-cxx 7.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,520 kB
  • sloc: cpp: 87,413; ansic: 3,571; sh: 56; makefile: 39
file content (58 lines) | stat: -rwxr-xr-x 1,419 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
set -e

SRCDIR=$(pwd)

LANG_TYPE=
API_VER=1

while getopts l:a: arg; do
  case $arg in
    l)
      LANG_TYPE=$OPTARG
      [ -d "$SRCDIR/example/$LANG_TYPE" ] || { >&2 printf 'Invalid example type - "%s"\n' "$LANG_TYPE"; exit 1; }
      ;;
    a)
      API_VER=$OPTARG
      expr "$API_VER" : '[0-9]\+$' >/dev/null 2>/dev/null || { >&2 printf 'API value (%s) must be numeric\n' "$API_VER"; exit 1; }
      ;;
    \?)
      printf 'Usage: %s -l <LANG> [-a <API_VER>]\n'
      exit 0
      ;;
  esac
done

[ -n "$LANG_TYPE" ] || (>&2 printf 'Must specify -l <LANG>\n'; exit 1)

cd "$AUTOPKGTEST_TMP"

[ -d example ] || cp -r "$SRCDIR"/example .

cat > CMakeLists.txt <<EOF
cmake_minimum_required(VERSION 3.0)
project(msgpack_autopkgtests)
find_package(msgpack-cxx REQUIRED CONFIG)
find_package(Threads)
add_subdirectory(example/$LANG_TYPE)
EOF

CXXFLAGS="$CXXFLAGS -DMSGPACK_DEFAULT_API_VERSION=$API_VER"
CMAKE_ARGS=
[ "$LANG_TYPE" = x3 ] && CMAKE_ARGS="$CMAKE_ARGS -DMSGPACK_USE_X3_PARSE=ON"
[ "$LANG_TYPE" = cpp11 ] && CMAKE_ARGS="$CMAKE_ARGS -DMSGPACK_CXX11=ON"

export CFLAGS
export CXXFLAGS

DIR="$AUTOPKGTEST_TMP/${LANG_TYPE}v${API_VER}"
mkdir -p "$DIR"
trap "rm -r '$DIR'" EXIT
cd "$DIR"

cmake -Wno-dev $CMAKE_ARGS ..
cmake --build . --verbose
for example_bin in $(find example/$LANG_TYPE -type f -perm /a+x); do
  echo "Testing $LANG_TYPE example '$(basename "$example_bin")'"
  ./"$example_bin"
done