#!/bin/bash
set -eu

# I am not sure this is a pretty work around to have linux headers installed
# Happy to hear if there is a better way:
apt-get update
apt-get install -y linux-headers-`uname -r`

basedir=$(dirname "$0")
. "${basedir}"/check-dpdk-supported-arch.sh

if [ -d /var/lib/dkms ]; then
    (cd /var/lib/dkms; find -name "make.log" -print0 | xargs -0 tar c) > "$ADT_ARTIFACTS/dkms-make-logs.tar"
else
    printf"\nDidn't find /var/lib/dkms\n"
fi

dkms status dpdk-rte-kni | grep installed$
dkms status dpdk-igb-uio | grep installed$

# check that the dkms build fine (on dep install), load and unload
printf "\n\nChecking igb_uio\n"
modinfo igb_uio
modprobe igb_uio
rmmod igb_uio
echo "OK"

printf "\n\nChecking igb_uio\n"
modinfo rte_kni
modprobe rte_kni
rmmod rte_kni
echo "OK"
