2021-09-27 13:10:35 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
passt: Relicense to GPL 2.0, or any later version
In practical terms, passt doesn't benefit from the additional
protection offered by the AGPL over the GPL, because it's not
suitable to be executed over a computer network.
Further, restricting the distribution under the version 3 of the GPL
wouldn't provide any practical advantage either, as long as the passt
codebase is concerned, and might cause unnecessary compatibility
dilemmas.
Change licensing terms to the GNU General Public License Version 2,
or any later version, with written permission from all current and
past contributors, namely: myself, David Gibson, Laine Stump, Andrea
Bolognani, Paul Holzinger, Richard W.M. Jones, Chris Kuhn, Florian
Weimer, Giuseppe Scrivano, Stefan Hajnoczi, and Vasiliy Ulyanov.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2023-04-05 18:11:44 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2021-09-27 13:10:35 +00:00
|
|
|
#
|
|
|
|
# PASST - Plug A Simple Socket Transport
|
|
|
|
# for qemu/UNIX domain socket mode
|
|
|
|
#
|
|
|
|
# PASTA - Pack A Subtle Tap Abstraction
|
|
|
|
# for network namespace/tap device mode
|
|
|
|
#
|
2022-02-22 17:29:45 +00:00
|
|
|
# test/lib/video - Session recording, JavaScript fragments with links
|
2021-09-27 13:10:35 +00:00
|
|
|
#
|
2022-02-22 17:29:45 +00:00
|
|
|
# Copyright (c) 2021-2022 Red Hat GmbH
|
2021-09-27 13:10:35 +00:00
|
|
|
# Author: Stefano Brivio <sbrivio@redhat.com>
|
|
|
|
|
|
|
|
VIDEO_START_SECONDS=
|
|
|
|
VIDEO_NAME=
|
|
|
|
|
|
|
|
VIDEO_LINKS_TEMPLATE="document.write('"'
|
|
|
|
Skip to:
|
|
|
|
'
|
|
|
|
|
|
|
|
VIDEO_LINKS_TEMPLATE_JS="
|
|
|
|
');
|
|
|
|
|
|
|
|
var video___VIDEO_NAME__links = [
|
|
|
|
"
|
|
|
|
|
|
|
|
VIDEO_LINKS_TEMPLATE_POST='];
|
|
|
|
|
|
|
|
for (var i = 0; i < video___VIDEO_NAME__links.length; i++) {
|
|
|
|
var obj = document.getElementById(video___VIDEO_NAME__links[i][0]);
|
|
|
|
|
|
|
|
obj.addEventListener("click", function(event) {
|
2022-02-22 17:29:45 +00:00
|
|
|
var __VIDEO_NAME___div = document.getElementById("__VIDEO_NAME__");
|
|
|
|
var top = __VIDEO_NAME___div.offsetTop - 5;
|
|
|
|
var seek;
|
2021-09-27 13:10:35 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < video___VIDEO_NAME__links.length; i++) {
|
|
|
|
if (this.id == video___VIDEO_NAME__links[i][0]) {
|
2022-02-22 17:29:45 +00:00
|
|
|
seek = video___VIDEO_NAME__links[i][1];
|
2021-09-27 13:10:35 +00:00
|
|
|
}
|
|
|
|
}
|
2022-02-22 17:29:45 +00:00
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
__VIDEO_NAME___player.dispose();
|
|
|
|
__VIDEO_NAME___player = AsciinemaPlayer.create(
|
|
|
|
"/builds/latest/web/__VIDEO_NAME__.cast",
|
|
|
|
__VIDEO_NAME___div,
|
2022-04-05 22:31:44 +00:00
|
|
|
{ cols: 240, rows: 51, poster: "npt:999:0", startAt: seek, autoplay: true });
|
2022-02-22 17:29:45 +00:00
|
|
|
|
2021-09-27 13:10:35 +00:00
|
|
|
window.scrollTo({ top: top, behavior: "smooth" })
|
|
|
|
}, false);
|
|
|
|
}
|
|
|
|
'
|
|
|
|
|
|
|
|
VIDEO_LINKS_BUF=
|
|
|
|
VIDEO_LINKS_COUNT=0
|
|
|
|
|
|
|
|
# video_append_links() - Append generic string to JavaScript links file
|
|
|
|
video_append_links()
|
|
|
|
{
|
2022-09-13 04:35:28 +00:00
|
|
|
__web="${LOGDIR}/web"
|
|
|
|
printf "${@}" >> "${__web}/${VIDEO_NAME}.js"
|
2021-09-27 13:10:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# video_append_links() - Append generic string to buffer for links
|
|
|
|
video_append_links_js()
|
|
|
|
{
|
|
|
|
VIDEO_LINKS_BUF="${VIDEO_LINKS_BUF}${@}"
|
|
|
|
}
|
|
|
|
|
2022-02-22 17:29:45 +00:00
|
|
|
# video_start() - Mark start of a test in capture, record start timestamp
|
|
|
|
video_start() {
|
2021-09-27 13:10:35 +00:00
|
|
|
VIDEO_NAME="${1}"
|
2022-09-13 04:35:28 +00:00
|
|
|
__web="${LOGDIR}/web"
|
|
|
|
mkdir -p "${__web}"
|
|
|
|
echo "${VIDEO_LINKS_TEMPLATE}" > "${__web}/${VIDEO_NAME}.js"
|
2021-09-27 13:10:35 +00:00
|
|
|
VIDEO_START_SECONDS=$(sed -n 's/\([0-9]*\).[0-9]* [0-9]*.[0-9]*/\1/p' /proc/uptime)
|
|
|
|
|
2022-02-22 17:29:45 +00:00
|
|
|
sync
|
2022-09-13 04:35:28 +00:00
|
|
|
[ ${DEMO} -eq 1 ] && tail -1 "${STATEBASE}/demo.uncut" > "${STATEBASE}/${VIDEO_NAME}.start"
|
|
|
|
[ ${CI} -eq 1 ] && tail -1 "${STATEBASE}/ci.uncut" > "${STATEBASE}/${VIDEO_NAME}.start"
|
2022-02-22 17:29:45 +00:00
|
|
|
sync
|
|
|
|
|
|
|
|
tmux refresh-client
|
2021-09-27 13:10:35 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 17:29:45 +00:00
|
|
|
# video_stop() - Mark stop of a test in capture, finalise JavaScript fragments
|
2021-09-27 13:10:35 +00:00
|
|
|
video_stop() {
|
2022-09-13 04:35:28 +00:00
|
|
|
__web="${LOGDIR}/web"
|
2022-02-22 17:29:45 +00:00
|
|
|
tmux refresh-client
|
|
|
|
|
|
|
|
sync
|
2022-09-13 04:35:28 +00:00
|
|
|
[ ${DEMO} -eq 1 ] && tail -1 "${STATEBASE}/demo.uncut" > "${STATEBASE}/${VIDEO_NAME}.stop"
|
|
|
|
[ ${CI} -eq 1 ] && tail -1 "${STATEBASE}/ci.uncut" > "${STATEBASE}/${VIDEO_NAME}.stop"
|
2022-02-22 17:29:45 +00:00
|
|
|
sync
|
|
|
|
|
2022-09-13 04:35:28 +00:00
|
|
|
sed -i 's/^.*$/&\\/g' "${__web}/${VIDEO_NAME}.js"
|
|
|
|
echo "${VIDEO_LINKS_TEMPLATE_JS}" | sed "s/__VIDEO_NAME__/${VIDEO_NAME}/g" >> "${__web}/${VIDEO_NAME}.js"
|
|
|
|
echo "${VIDEO_LINKS_BUF}" >> "${__web}/${VIDEO_NAME}.js"
|
|
|
|
echo "${VIDEO_LINKS_TEMPLATE_POST}" | sed "s/__VIDEO_NAME__/${VIDEO_NAME}/g" >> "${__web}/${VIDEO_NAME}.js"
|
2022-02-22 17:29:45 +00:00
|
|
|
}
|
2021-09-27 13:10:35 +00:00
|
|
|
|
2022-02-22 17:29:45 +00:00
|
|
|
# video_postprocess() - Cut terminal recordings based on .start and .stop files
|
|
|
|
video_postprocess() {
|
|
|
|
IFS='
|
|
|
|
'
|
2022-09-13 04:35:28 +00:00
|
|
|
__web="${LOGDIR}/web"
|
2022-02-22 17:29:45 +00:00
|
|
|
__cast_name=
|
|
|
|
for __l in $(cat ${1}); do
|
|
|
|
[ -z "${__header}" ] && __header="${__l}" && continue
|
|
|
|
|
|
|
|
if [ -z "${__cast_name}" ]; then
|
2022-09-13 04:35:28 +00:00
|
|
|
for __cast_cut in "${STATEBASE}/"*.start; do
|
2022-02-22 17:29:45 +00:00
|
|
|
[ "${__l}" != "$(cat "${__cast_cut}")" ] && continue
|
2022-09-13 04:35:28 +00:00
|
|
|
__cast_name="$(basename "${__cast_cut}")"
|
|
|
|
__cast_name="${__cast_name%.start}"
|
2022-02-22 17:29:45 +00:00
|
|
|
__cast_offset=
|
2022-09-13 04:35:28 +00:00
|
|
|
__stop_line="$(cat "${STATEBASE}/${__cast_name}.stop")"
|
|
|
|
echo "${__header}" > "${__web}/${__cast_name}.cast"
|
2022-02-22 17:29:45 +00:00
|
|
|
break
|
|
|
|
done
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ "${__l}" = "${__stop_line}" ] && __cast_name= && continue
|
|
|
|
|
|
|
|
__l_offset="$(echo ${__l%%.*}|tr -c -d '[:digit:]')"
|
|
|
|
__l_rest="${__l#*.}"
|
|
|
|
[ -z "${__cast_offset}" ] && __cast_offset=${__l_offset}
|
|
|
|
__l_offset=$((__l_offset - __cast_offset))
|
2022-09-13 04:35:28 +00:00
|
|
|
printf '[%s.%s\n' "${__l_offset}" "${__l_rest}" >> "${__web}/${__cast_name}".cast
|
2022-02-22 17:29:45 +00:00
|
|
|
done
|
|
|
|
unset IFS
|
|
|
|
}
|
2021-09-27 13:10:35 +00:00
|
|
|
|
2022-02-22 17:29:45 +00:00
|
|
|
# video_time_now() - Print current video timestamp, in seconds
|
|
|
|
video_time_now() {
|
|
|
|
__now=$(sed -n 's/\([0-9]*\).[0-9]* [0-9]*.[0-9]*/\1/p' /proc/uptime)
|
|
|
|
echo $((__now - VIDEO_START_SECONDS))
|
2021-09-27 13:10:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# video_link() - Append single link to given video chapter
|
|
|
|
video_link() {
|
|
|
|
[ ${VIDEO_LINKS_COUNT} -eq 0 ] && __sep="" || __sep=" |"
|
|
|
|
__id="video_link_${VIDEO_LINKS_COUNT}"
|
2022-03-15 02:43:39 +00:00
|
|
|
video_append_links "${__sep} <a id=\"${__id}\" href=\"${1}\">${1}</a>"
|
2021-09-27 13:10:35 +00:00
|
|
|
video_append_links_js "[ '${__id}', $(($(video_time_now) - 1)) ],"
|
|
|
|
|
|
|
|
VIDEO_LINKS_COUNT=$((VIDEO_LINKS_COUNT + 1))
|
|
|
|
}
|