automated: linux: libhugetlbfs: use prebuilt overlays

Make it possible to use prebuilt libhugetlbfs overlays.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
diff --git a/automated/linux/libhugetlbfs/libhugetlbfs.sh b/automated/linux/libhugetlbfs/libhugetlbfs.sh
index 4662140..3a7f5ba 100755
--- a/automated/linux/libhugetlbfs/libhugetlbfs.sh
+++ b/automated/linux/libhugetlbfs/libhugetlbfs.sh
@@ -11,6 +11,7 @@
 TEST_FAIL_LOG="${OUTPUT}/test_fail_log.txt"
 TEST_SKIP_LOG="${OUTPUT}/test_skip_log.txt"
 CWD=""
+LIBHUGETLBFS_PATH=""
 
 WORD_SIZE="64"
 VERSION="02df38e93e25e07f4d54edae94fb4ec90b7a2824"
@@ -20,9 +21,10 @@
     exit 1
 }
 
-while getopts "b:s:v:" o; do
+while getopts "b:p:s:v:" o; do
   case "$o" in
     b) WORD_SIZE="${OPTARG}" ;;
+    p) LIBHUGETLBFS_PATH="${OPTARG}" ;;
     s) SKIP_INSTALL="${OPTARG}" ;;
     v) VERSION="${OPTARG}" ;;
     *) usage ;;
@@ -163,9 +165,19 @@
 # Setup libhugetlbfs mount point
 libhugetlbfs_setup
 
-PRE_BUILD_PATH="$(find /usr/lib*/libhugetlbfs -type f -name run_tests.py)"
+if [ -n "${LIBHUGETLBFS_PATH}" ] && [ -d "${LIBHUGETLBFS_PATH}" ]
+then
+     overlay=yes
+else
+     LIBHUGETLBFS_PATH="$(find /usr/lib*/libhugetlbfs -type f -name run_tests.py)"
+fi
 
-if [ -n "${PRE_BUILD_PATH}" ]
+
+if [ -n "${overlay}" ]
+then
+    echo "pre built libhugtlbfs found in overlays"
+    cd "${LIBHUGETLBFS_PATH}" || exit
+elif [ -n "${LIBHUGETLBFS_PATH}" ]
 then
     echo "pre built libhugetlbfs found on rootfs"
     # shellcheck disable=SC2164
diff --git a/automated/linux/libhugetlbfs/libhugetlbfs.yaml b/automated/linux/libhugetlbfs/libhugetlbfs.yaml
index 9565286..cc6d216 100644
--- a/automated/linux/libhugetlbfs/libhugetlbfs.yaml
+++ b/automated/linux/libhugetlbfs/libhugetlbfs.yaml
@@ -32,8 +32,11 @@
     SKIP_INSTALL: "False"
     VERSION: "02df38e93e25e07f4d54edae94fb4ec90b7a2824"
 
+    # Pre-installed tests
+    LIBHUGETLBFS_PATH: ""
+
 run:
     steps:
         - cd ./automated/linux/libhugetlbfs/
-        - ./libhugetlbfs.sh -b "${WORD_SIZE}" -s "${SKIP_INSTALL}" -v "${VERSION}"
+        - ./libhugetlbfs.sh -b "${WORD_SIZE}" -p "${LIBHUGETLBFS_PATH}" -s "${SKIP_INSTALL}" -v "${VERSION}"
         - ../../utils/send-to-lava.sh ./output/result.txt