#!/bin/bash

set -ex

# This executes the equivalent of `make integration` from the main Makefile,
# but with all dependencies, golang libraries, and executables built from Debian sources

# The containerd package will start containerd automatically, and will confuse the test
# To remedy, make sure to stop that service
systemctl stop containerd
systemctl mask containerd
systemctl status containerd || true

# make test executables accessible
PATH=$PATH:/usr/lib/containerd
export PATH

# build the test binary
export GO111MODULE=off
export GOPATH=/usr/share/gocode
cd /usr/share/gocode/src/github.com/containerd/containerd/v2/integration/client/
go test -o $OLDPWD/client.test -c

# now execute it
cd $OLDPWD
exec ./client.test -test.v -test.root
