grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[LOCAL-CI v2 3/3] scripts: Add local-tester.sh script to run local CI te


From: Glenn Washburn
Subject: [LOCAL-CI v2 3/3] scripts: Add local-tester.sh script to run local CI tests
Date: Tue, 4 Jan 2022 12:00:46 -0600

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 scripts/ci/functions.local.sh | 37 +++++++++++++++++++++++++++++++++
 scripts/local-tester.sh       | 39 +++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
 create mode 100644 scripts/ci/functions.local.sh
 create mode 100755 scripts/local-tester.sh

diff --git a/scripts/ci/functions.local.sh b/scripts/ci/functions.local.sh
new file mode 100644
index 000000000..7a6766c07
--- /dev/null
+++ b/scripts/ci/functions.local.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+TXT_RED="\e[31m"
+TXT_YELLOW="\e[33m"
+TXT_CLEAR="\e[0m"
+TXT_LOG_COLOR="\e[97;100m"
+
+function start_log() {
+  local LOG_COLLAPSE LOG_NAME
+  while [ "$#" -gt 0 ]; do
+    case "$1" in
+      -c) LOG_COLLAPSE=1; shift;;
+      -n) LOG_NAME="$2"; shift;;
+      *) [ "$#" -eq 1 ] && LOG_MSG="$1"; shift;;
+    esac
+  done
+
+  echo -e "=========="
+  echo -e "========== ${TXT_YELLOW}Start Section ${LOG_NAME}: 
${LOG_MSG}${TXT_CLEAR}"
+  echo -e "=========="
+  echo -e "${LOG_NAME} STARTTIME=`date +%s`" >&2
+}
+
+function end_log() {
+  local LOG_NAME
+  while [ "$#" -gt 0 ]; do
+    case "$1" in
+      -n) LOG_NAME=$2; shift;;
+      *) shift;;
+    esac
+  done
+
+  echo -e "${LOG_NAME} ENDTIME=`date +%s`" >&2
+  echo -e "========== End Section ${LOG_NAME} =========="
+}
+
+:;
diff --git a/scripts/local-tester.sh b/scripts/local-tester.sh
new file mode 100755
index 000000000..9cc7b8f43
--- /dev/null
+++ b/scripts/local-tester.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+set -e
+
+SDIR=$(realpath -e "${SDIR:-"${0%/*}"}")
+ROOT=$(realpath -m "${ROOT:-"./grub-tests"}")
+
+mkdir -p "$ROOT"
+cd "$ROOT"
+
+# Log stdout+stderr to file while keeping stdout going to original stdout
+exec 2>"$ROOT/$(basename "$0" .sh).$(date '+%Y%m%d%H%M%S').log" > >(exec 3>&1; 
exec tee >(exec cat >&3) >&2)
+PTTY=$!
+
+if [ "x$SHELL_TRACE" = "xy" ]; then
+  set -x
+  export >&2
+fi
+
+export CI_TYPE=local
+if [ -d "${SDIR}/ci" ]; then
+  export SCRIPTS_DIR=${SCRIPTS_DIR:-"${SDIR}"}
+  export CI_SCRIPTS_DIR=${CI_SCRIPTS_DIR:-"${SCRIPTS_DIR}/ci"}
+fi
+
+# If found, source helper functions
+[ -f "${CI_SCRIPTS_DIR}/functions.sh" ] &&
+. "${CI_SCRIPTS_DIR}/functions.sh"
+
+
+onexit() {
+  set +x
+  # Must close our end of the pipe to tee, else it will not exit and
+  # we'll wait forever on it to exit.
+  exec >&-
+  wait_anypid $PTTY
+}
+trap onexit exit
+
+main "$@"
-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]