#!/bin/bash
set -e

cp -r tests "$AUTOPKGTEST_TMP"
mkdir -p "$AUTOPKGTEST_TMP/include/faiss"
cp -r faiss/cppcontrib "$AUTOPKGTEST_TMP/include/faiss"
cd "$AUTOPKGTEST_TMP/tests"
sed -i -e '1i \
cmake_minimum_required(VERSION 3.17)\
project(autopkgtest)\
find_package(faiss REQUIRED)\
include_directories(../include)' CMakeLists.txt
GTEST_FILTER="-MEM_LEAK.*"
if test `dpkg-architecture -qDEB_HOST_ARCH_BITS` = 32
then
	GTEST_FILTER="${GTEST_FILTER}:testCppcontribSaDecode*"
fi

set -x
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DFAISS_USE_SYSTEM_GTEST=ON
make VERBOSE=ON

./faiss_test --gtest_filter="${GTEST_FILTER}"

