-
Notifications
You must be signed in to change notification settings - Fork 1.3k
ui-smoke phase 3: screenshots, writable config mirrors, homing settle #4136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
grandixximo
wants to merge
15
commits into
LinuxCNC:master
Choose a base branch
from
grandixximo:ui-tests-phase3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
aacd0c6
test: ui-smoke phase 3, screenshot the GUI on failure and confirm on …
grandixximo 8855a05
test: run gmoccapy ui-smoke against a writable config mirror
grandixximo 9514b7b
ui-smoke: settle after homing before requesting AUTO
grandixximo 9ed19b2
test: ui-smoke compare confirm shot to a committed reference image
grandixximo d78cb6c
ci: install gdb up front so the ui-smoke crash dump path does not apt…
grandixximo 53d15d5
tests/runtests: export NOSUDO via RUNTESTS_NOSUDO so children can hon…
grandixximo a43bd74
test: ui-smoke touchy-fit, fail if the window exceeds the screen
grandixximo a23d4ff
test: bump ui-smoke compare fuzz to 40 % so the metric tracks real drift
grandixximo 1c007bd
test: refresh touchy ui-smoke for the new minimum-height patch
grandixximo c4de595
test: regenerate axis/gmoccapy/qtdragon references from CI output
grandixximo f318204
ci: move gdb to control build-deps so package-arch tests get it too
grandixximo ed7f125
ui-smoke: only use a readable core from this run for the native backt…
grandixximo ffd8a82
tests: dual red and absolute-difference ui-smoke diffs at 0% fuzz
grandixximo dbf80a3
test: adopt CI confirm shots as ui-smoke references
grandixximo 31c9888
tests: stabilize qtdragon ui-smoke preview and gcode scroll
grandixximo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/bin/bash | ||
| # Known-good image comparison for the UI smoke confirm shots. Complements | ||
| # screenshot.sh: that grabs confirm.png on a clean run; this compares it to | ||
| # a committed reference.png and writes two visual diffs. Like screenshot.sh | ||
| # it carries no state and is a logged no-op whenever it cannot run, so it can | ||
| # never turn a pass into a fail. | ||
| # | ||
| # Two diff images, both at 0% fuzz so nothing is hidden: | ||
| # diff.png red highlight over a faded copy of the reference (where it | ||
| # changed, ImageMagick "compare" style) | ||
| # diff-abs.png absolute per-channel difference |b - a|, black where equal | ||
| # and bright where it changed (unbiased, magnitude preserved) | ||
| # | ||
| # Policy: we never fail a test on the image difference. freetype/font | ||
| # versions differ across distros, so some drift is expected; the diffs are | ||
| # here to record what changed, not to gate. The function always returns 0. | ||
| # | ||
| # Local "make a known-good image" workflow: run a test with | ||
| # UI_SMOKE_UPDATE_REFERENCE=1 (see make-references.sh) and the freshly | ||
| # captured shot is saved as the committed reference instead of compared. | ||
|
|
||
| # Set IM_COMPARE and IM_CONVERT to the IM7 or IM6 entry points; return 1 | ||
| # if ImageMagick is absent. | ||
| _im_tools() { | ||
| if command -v magick >/dev/null 2>&1; then | ||
| IM_COMPARE="magick compare"; IM_CONVERT="magick" | ||
| elif command -v compare >/dev/null 2>&1; then | ||
| IM_COMPARE="compare"; IM_CONVERT="convert" | ||
| else | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| # compare_to_reference <shot> <reference> <diff> <diff_abs> | ||
| # Compare the captured shot to the committed reference, writing a red-highlight | ||
| # diff and an absolute-difference diff. Always returns 0. | ||
| compare_to_reference() { | ||
| shot="$1" | ||
| reference="$2" | ||
| diff="$3" | ||
| diff_abs="$4" | ||
|
|
||
| if [ ! -s "$shot" ]; then | ||
| echo "compare: no shot at $shot, skipping" | ||
| return 0 | ||
| fi | ||
|
|
||
| # Update mode: adopt this shot as the new known-good reference. | ||
| if [ "${UI_SMOKE_UPDATE_REFERENCE:-}" = "1" ]; then | ||
| if cp -f "$shot" "$reference"; then | ||
| echo "compare: saved reference $reference (UI_SMOKE_UPDATE_REFERENCE=1)" | ||
| else | ||
| echo "compare: failed to save reference $reference" | ||
| fi | ||
| return 0 | ||
| fi | ||
|
|
||
| if [ ! -s "$reference" ]; then | ||
| echo "compare: no reference at $reference yet, skipping (run with UI_SMOKE_UPDATE_REFERENCE=1 to create one)" | ||
| return 0 | ||
| fi | ||
|
|
||
| _im_tools || { | ||
| echo "compare: no ImageMagick available, skipping" | ||
| return 0 | ||
| } | ||
|
|
||
| # Red-highlight diff at 0% fuzz: -metric AE counts every differing pixel | ||
| # (interpretable), and the same call writes diff.png. compare exits 0 | ||
| # (identical), 1 (differ) or 2 (error, e.g. the shots are different | ||
| # sizes). We log the outcome and always succeed. | ||
| metric=$($IM_COMPARE -metric AE -fuzz 0% "$reference" "$shot" "$diff" 2>&1) | ||
| rc=$? | ||
| case "$rc" in | ||
| 0) echo "compare: $shot matches $reference (AE=$metric)" ;; | ||
| 1) echo "compare: $shot differs from $reference (AE=$metric differing pixels); diff at $diff" ;; | ||
| *) echo "compare: could not compare $shot to $reference (rc=$rc): $metric" ;; | ||
| esac | ||
|
|
||
| # Absolute-difference diff |b - a|: black where equal, bright where it | ||
| # changed. Unbiased (direction does not matter) and keeps magnitude. | ||
| if $IM_CONVERT "$reference" "$shot" -compose difference -composite "$diff_abs" 2>/dev/null; then | ||
| echo "compare: absolute-difference diff at $diff_abs" | ||
| else | ||
| echo "compare: could not write absolute-difference diff $diff_abs" | ||
| fi | ||
| return 0 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,59 @@ | ||
| #!/bin/bash | ||
| # Native crash capture for the UI smoke launchers. A GUI segfault is the | ||
| # failure these tests most need to explain, and it lands in C/C++ (Qt, | ||
| # dbus, GL) where PYTHONFAULTHANDLER stops at the event-loop frame. Arm a | ||
| # core dump before launch; after the run, if the GUI left a core, print a | ||
| # native backtrace into the log so CI shows the faulting frame directly. | ||
| # Source with LIB_DIR set; runs only on the failure path, so green runs | ||
| # pay nothing. | ||
| # Native crash capture for the UI smoke launchers. A GUI segfault lands in | ||
| # C/C++ (Qt, dbus, GL); PYTHONFAULTHANDLER (set in launch-env.sh) prints a | ||
| # Python traceback to linuxcnc.err naming the frame that called in, which | ||
| # is the reliable, environment-independent crash signal and is surfaced in | ||
| # every failure log. This helper adds a best-effort native backtrace on | ||
| # top: arm a core dump before launch, and after the run, if a readable | ||
| # core from this run is present, gdb-print its backtrace. The core only | ||
| # materialises when we can point kernel.core_pattern at a writable dir, | ||
| # which needs root; non-root runs (CI, local -u) keep the Python traceback | ||
| # and skip the native one. Source with LIB_DIR set; runs only on the | ||
| # failure path, so green runs pay nothing. | ||
|
|
||
| crashdump_arm() { | ||
| CORE_DIR="$(mktemp -d -t ui-smoke-cores.XXXXXX)" | ||
| export CORE_DIR | ||
| ulimit -c unlimited 2>/dev/null || true | ||
| # core_pattern is global; only set it if already root. Never sudo: | ||
| # the suite must run unattended. Non-root falls back to a cwd "core". | ||
| if [ "$(id -u)" = 0 ]; then | ||
| # core_pattern is global; only set it if already root, never sudo | ||
| # (the suite must run unattended), and skip under runtests -u so a | ||
| # user opting out of root tweaks is respected even when invoking the | ||
| # suite from a root shell. Non-root falls back to a cwd "core". | ||
| if [ "$(id -u)" = 0 ] && [ "${RUNTESTS_NOSUDO:-0}" != "1" ]; then | ||
| sysctl -w "kernel.core_pattern=$CORE_DIR/core.%e.%p" >/dev/null 2>&1 || true | ||
| fi | ||
| } | ||
|
|
||
| crashdump_report() { | ||
| [ -n "${CORE_DIR:-}" ] || return 0 | ||
| local core | ||
| # shellcheck disable=SC2012 # mktemp dir, no odd filenames | ||
| core=$(ls -t "$CORE_DIR"/core* ./core* /tmp/core* 2>/dev/null | head -1) | ||
| if [ -n "$core" ]; then | ||
| local c core="" | ||
| # Only trust a core we know is from this run and can actually read: | ||
| # one the kernel wrote into our fresh CORE_DIR (root path, where we set | ||
| # core_pattern), or a relative "core" in the cwd that postdates arming. | ||
| # A broad /tmp glob would pick up a stale or foreign core (often root- | ||
| # owned), and gdb would just print "Permission denied". | ||
| for c in "$CORE_DIR"/core*; do | ||
| [ -e "$c" ] && [ -r "$c" ] && { core="$c"; break; } | ||
| done | ||
| if [ -z "$core" ]; then | ||
| for c in ./core*; do | ||
| [ -e "$c" ] && [ -r "$c" ] && [ "$c" -nt "$CORE_DIR" ] && { core="$c"; break; } | ||
| done | ||
| fi | ||
| if [ -n "$core" ] && command -v gdb >/dev/null 2>&1; then | ||
| echo "=== crash: native backtrace ($core) ===" | ||
| # gdb reads the core; pull it in if missing, only when root. | ||
| if ! command -v gdb >/dev/null 2>&1 && [ "$(id -u)" = 0 ]; then | ||
| apt-get install -y -q gdb >/dev/null 2>&1 || true | ||
| fi | ||
| if command -v gdb >/dev/null 2>&1; then | ||
| # "bt" first: gdb auto-selects the faulting thread on a SIGSEGV | ||
| # core. "thread apply all bt" after gives the rest. | ||
| gdb -batch -nx \ | ||
| -ex "bt" \ | ||
| -ex "echo \n=== all threads ===\n" \ | ||
| -ex "thread apply all bt" \ | ||
| "$(command -v python3)" "$core" 2>&1 | head -400 | ||
| else | ||
| echo "(gdb unavailable; core left at $core)" | ||
| fi | ||
| # "bt" first: gdb auto-selects the faulting thread on a SIGSEGV | ||
| # core. "thread apply all bt" after gives the rest. | ||
| gdb -batch -nx \ | ||
| -ex "bt" \ | ||
| -ex "echo \n=== all threads ===\n" \ | ||
| -ex "thread apply all bt" \ | ||
| "$(command -v python3)" "$core" 2>&1 | head -400 | ||
| else | ||
| # No readable core (the common non-root case). The Python | ||
| # faulthandler traceback in linuxcnc.err already names the crash | ||
| # site; the native backtrace is only a best-effort extra. | ||
| echo "=== crash: no readable core dump; see the Python traceback in linuxcnc.err above ===" | ||
| fi | ||
| rm -rf "$CORE_DIR" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/bin/bash | ||
| # Sourced by the gmoccapy ui-smoke tests (smoke and quit) to run gmoccapy | ||
| # against a writable copy of its sim config. Sets GMOCCAPY_INI to the | ||
| # mirrored ini path; the caller then execs run-gui.sh or quit-launch.sh | ||
| # with "$GMOCCAPY_INI". Must be sourced with LIB_DIR already set. | ||
| # | ||
| # gmoccapy writes its preferences file next to the config: with no | ||
| # PREFERENCE_FILE_PATH in the ini, getiniinfo falls back to | ||
| # <config-dir>/<MACHINE>.pref. CI mounts the workspace read-only for the | ||
| # runtime user, so that write raises PermissionError partway through | ||
| # __init__ (during _get_pref_data, before the MDIHistory widget's | ||
| # _hal_init runs). gmoccapy pops an error dialog and limps on in a | ||
| # half-initialised state: the interp-idle handler then hits a widget with | ||
| # no .stat and throws a second dialog. Both vanish once the config dir is | ||
| # writable. Mirror it to tmp, same fix qtdragon-prepare.sh uses. | ||
|
|
||
| : "${LIB_DIR:?gmoccapy-prepare.sh must be sourced with LIB_DIR set}" | ||
|
|
||
| SRC_DIR="$(cd "$LIB_DIR/../../../configs/sim/gmoccapy" && pwd)" | ||
|
|
||
| WORK_DIR="$(mktemp -d -t ui-smoke-gmoccapy.XXXXXX)" | ||
| trap 'rm -rf "$WORK_DIR"' EXIT | ||
| cp -r "$SRC_DIR/." "$WORK_DIR/" | ||
|
|
||
| # Seed the preference file (config dir + <MACHINE>.pref; MACHINE=gmoccapy) | ||
| # so the first-run "Important change(s)" modal stays hidden. That dialog | ||
| # runs a nested gtk loop, so under xvfb it never gets dismissed: it sits | ||
| # on top of the UI in the confirm shot and, worse, swallows the SIGTERM | ||
| # in the quit test (the loop keeps running after main_quit). A real user | ||
| # ticks "Don't show this again" once; hide_startup_messsage replicates | ||
| # that. The triple-s key matches gmoccapy's own (sic). | ||
| cat >"$WORK_DIR/gmoccapy.pref" <<'PREF' | ||
| [DEFAULT] | ||
| hide_startup_messsage = 99 | ||
| PREF | ||
|
|
||
| # Consumed by the sourcing test.sh, which execs the launcher with it. | ||
| # shellcheck disable=SC2034 | ||
| GMOCCAPY_INI="$WORK_DIR/gmoccapy.ini" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this makes no sense, checking if we are root and then if RUNTESTS_NOSUDO not doing it.
Here, you can only be root if you use
sudo runtestsright? However,sudo runtestswill always fail.I would just check for
"${RUNTESTS_NOSUDO:-0}" != "1"and then dosudo sysctlDid you ever test if you get a crashdump if there is a segfault?