QA/Bibisect/Automation
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
Automation can be done on different levels. Some shells and plugins like Oh My Zsh already have aliases for git. Or we can create our own aliases for efficiency. Or we can use fully automated bibisect.
Tidbits for efficiency
The repetitive nature of bibisecting gets tedious fast, so every trick you can use to make the process quicker is valuable. A typical way is to define aliases for complex commands in your .bashrc file.
The .bashrc of an active bibisecter might include a block such as this:
alias bad='git bisect bad && instdir/program/soffice'
alias good='git bisect good && instdir/program/soffice'
alias skip='git bisect skip && instdir/program/soffice'
alias next='git log --reverse --pretty=%H master | grep -A 1 $(git rev-parse HEAD) | tail -n1 | xargs git checkout'
alias prev='git checkout HEAD^1'
alias gallery='rm instdir/program/gengal'
alias pycache='find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf'
alias source='if [[ $(git log -1) =~ sha:([[:alnum:]]+) ]]; then git --git-dir ~/libreoffice/.git log -1 ${BASH_REMATCH[1]}; fi'
alias sof="\$( if [[ -d instdir ]] ; then echo instdir ; else if [[ -d opt ]] ; then echo opt ; fi ; fi )/program/soffice --norestore --nologo"
We have commands for jumping to the next or previous commit, "pycache" for dealing with a Windows-specific annoyance and finally "source" for quickly displaying source commit information. The command named "source" assumes you are in a bibisect repository, grabs the source hash of the currently checked out commit and feeds it to a git command targeting a full clone of the LibreOffice source code. To get a breakdown of the command, see the Bash Reference Manual. "sof" introduces single command for newer repos with instdir and older with opt directories.
The above examples are not exclusive to *nix systems, but work fine in a cygwin environment on Windows. If you want to open documents from the cygwin command line, enclose the ordinary Windows path in single quotes like so: instdir/program/soffice 'c:\users\test\downloads\example.ods'
Another approach would be to assume one will also do reverse bibisects, so use "before" and "after" instead of "good" and "bad". soffice command remains separate and can be replaced with "sof" and combined with "gen" or "skia". "skip" is useful when LO doesn't start, but it can also be temporarily modified when a specific file cannot be loaded. "loexit" is used with "time" to measure loading time with auto exit.
alias gbs='echo "git bisect start master oldest" && git bisect start master oldest'
alias gbb='echo "git bisect before" && git bisect good'
alias gba='echo "git bisect after" && git bisect bad'
alias skip='while (git clean -f -X && git bisect skip && ! (SAL_USE_VCLPLUGIN=gen instdir/program/soffice)); do : ; done'
alias gen='SAL_USE_VCLPLUGIN=gen'
alias skia='SAL_ENABLESKIA=1 SAL_USE_VCLPLUGIN=gen'
alias loexit='OOO_EXIT_POST_STARTUP=1'
alias buildc='lynx https://git.libreoffice.org/core/+log/`instdir/program/soffice --version | awk '"'"'{print $(NF)}'"'"'` '
build() { lynx https://git.libreoffice.org/core/+log/"$1"; }
log() { git log --all --grep="$1"; }
Alias "buildc" opens web page with current commit, showing it's time and author. Function "build" opens master , while "build d376297c643785564e7bda1a74b573c35ade6cb8" checks the specific commit. Function "log 3678e0efcb8bedc58dd329a430da0ac3b1572df8" finds bisect commit of source commit in current repo.
For example, with those commands one can bibisect change in fileopen time, inlcuding in old versions, as:
gbs && time loexit gen sof file.ext.
Automation with scripts
It is possible to automate bisecting with the help of scripts. Command to run bibisect is always the same, we start bibisect and mark old commit as good and new as bad. That works for finding a regression and if we need to find a fix we must compensate in a script. Command git bisect run is run with a script. In simple case, script is run from the current directory and files are already there with contiguous names. But script can be more complex, have parameters and be predefined for user's bug files download folder where original file names are used. Further are examples. Script needs to be executable.
cd ~/linux-64-6.3 && git bisect start && git bisect good oldest && git bisect bad master && git bisect run ~/lo-script.sh ["param 1"] [param2] ...
Here is an example with fixed values, finding if convert is correct by looking at PDF size.
./instdir/program/soffice --headless --convert-to pdf tdf141049.doc
file=tdf141049.pdf
minsize=40000
size=$(wc -c <"$file")
if [ $size -ge $minsize ]; then
exit 0
else
exit 1
fi
Here is the script to check export time for any original and exported extension, comparing to some good time that is determined by user when looking at oldest and master times. Script can also be used to find a fix, if optional last parameter is a word "fix".
#!/bin/bash
# lo-exptime.sh. Called with 4+1 parameters: "12345 file" ext-original ext-exported good-time [fix]
file=$1 ; extorig=$2 ; extexp=$3 ; goodtime=$4 ; regfix=$5
if [[ $regfix = "fix" ]]; then before=1; after=0; else before=0; after=1; fi
./instdir/program/soffice --headless --convert-to $extexp /media/LibreOffice_Bug_Files/"$file".$extorig
exptime=$SECONDS
if (( $exptime < $goodtime )) ; then echo "exports fast in $exptime sec" ; exit $before
elif (( $exptime > $goodtime )) ; then echo "exports slow in $exptime sec" ; exit $after
else echo "error"
fi
Here is the script to use macro and exit, measuring execution time and comparing to some good time. It's advantage is that file can be modified from within. This script also uses timeout time check in case of hang or crash. Command is more complex as it allows for any file name. Exact statuses are found with testing oldest and master commits and script can be modified accordingly.
#!/bin/bash
# lo-openmacro.sh Called with 4+1 parameters: "12345 file.ext" good-time timeout-time macro-name [fix]
fileext=$1 ; goodtime=$2 ; timeouttime=$3 ; macroname=$4 ; regfix=$5
if [[ $regfix = "fix" ]]; then before=1; after=0; else before=0; after=1; fi
timeout $timeouttime bash -c ' OOO_EXIT_POST_STARTUP=1 SAL_USE_VCLPLUGIN=gen ./instdir/program/soffice --norestore "$@" ' bash /media/LibreOffice_Bug_Files/"$fileext" macro:///Standard.Module1.$macroname
status=$? ; echo "$status"
exptime=$SECONDS
if [ $status = 124 ] ; then
echo "timeout in $timeouttime, done in $exptime sec" ; exit $before
elif [ $status = 134 ] ; then
echo "done in $exptime sec" ; exit $after
elif [ $status = 42 ] ; then
if (( $exptime < $goodtime )) ; then
echo "opens fast in $exptime sec" ; exit $before
elif (( $exptime > $goodtime )) ; then
echo "opens slow in $exptime sec" ; exit $after
else echo "error"
fi
else echo "other exit code"
git reset --hard
fi