run.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh
  2. # SQLite binding tests and showcase.
  3. set -e
  4. cd "$(dirname "$0")"
  5. ROOT="$(cd ../.. && pwd)"
  6. M2MAKE="$ROOT/tools/m2make/b_v3/M2make"
  7. if [ ! -x "$M2MAKE" ]; then
  8. echo "missing $M2MAKE; run tools/m2make/build_m2.sh" >&2
  9. exit 1
  10. fi
  11. SQLITE_LIBS="$(pkg-config --libs sqlite3 2>/dev/null || true)"
  12. if [ -z "$SQLITE_LIBS" ]; then
  13. # Runtime-only installations often have no .pc/header; use the
  14. # versioned shared object directly.
  15. SQLITE_LIBS="/usr/lib/x86_64-linux-gnu/libsqlite3.so.0"
  16. fi
  17. build_and_run() {
  18. name="$1"
  19. src="${2:-tests/$name.mod}"
  20. out="${TMPDIR:-/tmp}/m2-sqlite-$name"
  21. "$M2MAKE" -c m2 \
  22. --m2bin "$ROOT/compiler/M2" \
  23. --shim "$ROOT/runtime/syslib/shim.c" \
  24. --lib "$SQLITE_LIBS" \
  25. -I "$ROOT/bindings/sqlite3" \
  26. -I "$ROOT/runtime/syslib" \
  27. -I "$ROOT/lib/common" \
  28. -o "$out" \
  29. "$src"
  30. set +e
  31. "$out"
  32. rc=$?
  33. set -e
  34. if [ "$rc" = 42 ]; then return 0; fi
  35. return 1
  36. }
  37. build_and_run SQLiteSmoke
  38. build_and_run SQLitePrepared
  39. build_and_run SQLiteScalar
  40. build_and_run SQLiteErrors
  41. build_and_run SQLiteBlob
  42. build_and_run SQLiteConnection
  43. build_and_run SQLiteCallback
  44. build_and_run SQLiteHooks
  45. build_and_run SQLiteShowcase showcase/SQLiteShowcase.mod