libhugetlbfs: fetch libhugetlbfs by commit

The upstream master branch is 2 years old. Use the latest working commit
available in the next branch, instead.

Download the tarball from known good commit from upstream libhugetlbfs repo
and validate for #3418 bug fix and better test coverage in future use.

Ref:
libhugetlbfs: use next branch instead of master
https://projects.linaro.org/projects/CTT/queues/issue/CTT-770

libhugetlbfs linkhuge test is failing
https://bugs.linaro.org/show_bug.cgi?id=3418

Change-Id: Ib8e644d7d0e4aad454c31c62fb767f44f57d9edc
Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Dan Rue <dan.rue@linaro.org>
diff --git a/automated/linux/libhugetlbfs/libhugetlbfs.sh b/automated/linux/libhugetlbfs/libhugetlbfs.sh
index 73ad3e2..4662140 100755
--- a/automated/linux/libhugetlbfs/libhugetlbfs.sh
+++ b/automated/linux/libhugetlbfs/libhugetlbfs.sh
@@ -13,7 +13,7 @@
 CWD=""
 
 WORD_SIZE="64"
-VERSION="2.20"
+VERSION="02df38e93e25e07f4d54edae94fb4ec90b7a2824"
 
 usage() {
     echo "Usage: $0 [-b <4|64>] [-s <true>] [-v <libhugetlbfs-version>]" 1>&2
@@ -35,7 +35,7 @@
     # shellcheck disable=SC2063
     grep -v "*"  "${TMP_LOG}" | tee -a "${RESULT_LOG}"
     # Parse each type of results
-    egrep "PASS" "${RESULT_LOG}" | tee -a "${TEST_PASS_LOG}"
+    grep -E "PASS" "${RESULT_LOG}" | tee -a "${TEST_PASS_LOG}"
     sed -i -e 's/ (inconclusive)//g' "${TEST_PASS_LOG}"
     sed -i -e 's/(//g' "${TEST_PASS_LOG}"
     sed -i -e 's/)://g' "${TEST_PASS_LOG}"
@@ -43,15 +43,15 @@
     awk '{for (i=1; i<NF-1; i++) printf $i "-"; print $i " " $NF}' "${TEST_PASS_LOG}" 2>&1 | tee -a "${RESULT_FILE}"
     sed -i -e 's/PASS/pass/g' "${RESULT_FILE}"
 
-    egrep "FAIL" "${RESULT_LOG}" | cut -d: -f 1-2 2>&1 | tee -a "${TEST_FAIL_LOG}"
+    grep -E "FAIL" "${RESULT_LOG}" | cut -d: -f 1-2 2>&1 | tee -a "${TEST_FAIL_LOG}"
     sed -i -e 's/ (inconclusive)//g' "${TEST_FAIL_LOG}"
     sed -i -e 's/(//g' "${TEST_FAIL_LOG}"
     sed -i -e 's/)//g' "${TEST_FAIL_LOG}"
     sed -i -e 's/://g' "${TEST_FAIL_LOG}"
     awk '{for (i=1; i<NF; i++) printf $i "-"; print $i " " "fail"}' "${TEST_FAIL_LOG}" 2>&1 | tee -a "${RESULT_FILE}"
 
-    egrep "SKIP" "${RESULT_LOG}" | cut -d: -f 1-2 2>&1 | tee -a "${TEST_SKIP_LOG}"
-    egrep "Bad configuration" "${RESULT_LOG}" | cut -d: -f 1-2 2>&1 | tee -a "${TEST_SKIP_LOG}"
+    grep -E "SKIP" "${RESULT_LOG}" | cut -d: -f 1-2 2>&1 | tee -a "${TEST_SKIP_LOG}"
+    grep -E "Bad configuration" "${RESULT_LOG}" | cut -d: -f 1-2 2>&1 | tee -a "${TEST_SKIP_LOG}"
     sed -i -e 's/ (inconclusive)//g' "${TEST_SKIP_LOG}"
     sed -i -e 's/(//g' "${TEST_SKIP_LOG}"
     sed -i -e 's/)//g' "${TEST_SKIP_LOG}"
@@ -85,17 +85,24 @@
 }
 
 libhugetlbfs_build_test() {
+    CWD=$(pwd)
+
     # shellcheck disable=SC2140
     # Upstream tree
-#    wget https://github.com/libhugetlbfs/libhugetlbfs/releases/download/"${VERSION}"/libhugetlbfs-"${VERSION}".tar.gz
-    #TODO
-    # Private tree with CentOS build fix
-    # When patch is upstream remove private tree and enable upstream tree
-    wget http://github.com/nareshkamboju/libhugetlbfs/releases/download/"${VERSION}"/libhugetlbfs-"${VERSION}".tar.gz
-    CWD=$(pwd)
-    tar -xvf libhugetlbfs-"${VERSION}".tar.gz
+    # wget https://github.com/libhugetlbfs/libhugetlbfs/releases/download/"${VERSION}"/libhugetlbfs-"${VERSION}".tar.gz
+    # tar -xvf libhugetlbfs-"${VERSION}".tar.gz
+    # # shellcheck disable=SC2164
+    # cd libhugetlbfs-"${VERSION}"
+    # make BUILDTYPE=NATIVEONLY
+
+    # En lieu of an actual libhugetlbfs release, fetch a tarball from a github
+    # commit and write a version file explicitly.
+    wget -O libhugetlbfs-"${VERSION}".tar.gz https://github.com/libhugetlbfs/libhugetlbfs/tarball/"${VERSION}"
+    mkdir libhugetlbfs-"${VERSION}"
+    tar -xvf libhugetlbfs-"${VERSION}".tar.gz --strip=1 -C libhugetlbfs-"${VERSION}"
     # shellcheck disable=SC2164
     cd libhugetlbfs-"${VERSION}"
+    echo "${VERSION}" > version
     make BUILDTYPE=NATIVEONLY
 }