Skip to content

Commit

Permalink
Create (generate-result-json)-parsable log file from mtps-get-module
Browse files Browse the repository at this point in the history
  • Loading branch information
jpopelka committed Jan 25, 2024
1 parent e67ae50 commit 141f5af
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
36 changes: 34 additions & 2 deletions mtps-get-module
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,43 @@ while [[ $# -gt 0 ]]; do
done

mkdir -p "${LOGS_DIR:=mtps-logs}"
TESTRUN_ID="$(date +%H%M%S)"
logfname="${LOGS_DIR%%/}/${TESTRUN_ID}-mtps-get-module.log"
LOGS_DIR="$(realpath "$LOGS_DIR")"
while true; do
TESTRUN_ID="$(date +%H%M%S)"
logfname="${LOGS_DIR%%/}/${TESTRUN_ID}-${MBSID}-mtps-get-module.log"
logfname_skip="$(dirname "$logfname")/SKIP-$(basename "$logfname")"
logfname_pass="$(dirname "$logfname")/PASS-$(basename "$logfname")"
logfname_fail="$(dirname "$logfname")/FAIL-$(basename "$logfname")"
if [[ -e "$logfname" || -e "$logfname_pass" || -e "$logfname_fail" ]]; then
sleep 1
continue
fi
break
done
exec &> >(tee -a "$logfname")
exec 2>&1

do_clean_exit() {
rc=$?
trap - SIGINT SIGTERM SIGABRT EXIT # clear the trap
new_logfname="$logfname_fail"
if [[ "$rc" -eq 0 ]]; then
new_logfname="$logfname_pass"
elif [[ "$rc" -eq $RET_NO_RPMS_IN_BREW || "$rc" -eq $RET_NO_RPMS_IN_REPOS || "$rc" -eq $RET_NO_MODULE_ARCH ]]; then
new_logfname="$logfname_skip"
fi
# Close tee pipes
for pid in $(ps -o pid --no-headers --ppid $$); do
if [ -n "$(ps -p $pid -o pid=)" ]; then
kill -s HUP $pid
fi
done
mv -f "$logfname" "$new_logfname"
exit $rc
}

trap do_clean_exit SIGINT SIGTERM SIGABRT EXIT

debug "Brew build: $BUILD"
debug "Brew tag: $TAG"
debug "MBS build id: $MBSID"
Expand Down
4 changes: 4 additions & 0 deletions viewer/generate-result-json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ for log in mtps_log_dir.iterdir():
test_name = "download build"
test_object = None

if test_object == "mtps-get-module":
test_name = "module info"
test_object = None

results[test_name].append(
{
"result": RESULTS_MAPPING[result],
Expand Down

0 comments on commit 141f5af

Please sign in to comment.