19 lines
1.8 KiB
Bash
19 lines
1.8 KiB
Bash
# B13W common environment (sourced). Software rendering only (wlroots Pixman), DRM backend on the ST7735S card0, seatd seat.
|
|
# X11 (aurora-x: Xorg fbdev + x11vnc) is never modified; it is only stopped while a compositor holds the display (STOP_X=1).
|
|
B13=/usr/local/lib/b13; S=/run/b13; mkdir -p $S
|
|
export XDG_RUNTIME_DIR=/run/user/0; mkdir -p -m 0700 $XDG_RUNTIME_DIR
|
|
export WLR_RENDERER=pixman WLR_BACKENDS=drm,libinput WLR_DRM_DEVICES=/dev/dri/card0 WLR_LIBINPUT_NO_DEVICES=1 LIBSEAT_BACKEND=seatd
|
|
now() { cut -d' ' -f1 /proc/uptime; }
|
|
log() { echo "[$(now)] $*" | tee -a $S/b13.log; }
|
|
x_guard() {
|
|
if pidof Xorg >/dev/null; then
|
|
[ "${STOP_X:-0}" = 1 ] || { log "FAIL: Xorg is running (holds the panel); rerun with STOP_X=1"; exit 1; }
|
|
log "stopping X11 (aurora-x stop) for the compositor test"; /usr/local/bin/aurora-x stop >> $S/b13.log 2>&1; echo 1 > $S/x-was-running
|
|
fi
|
|
for c in cage sway; do pidof $c >/dev/null && { log "FAIL: $c already running"; exit 1; }; done
|
|
}
|
|
seatd_up() { pidof seatd >/dev/null || { seatd -g video > $S/seatd.log 2>&1 & i=0; while [ ! -S /run/seatd.sock ] && [ $i -lt 50 ]; do sleep 0.1; i=$((i+1)); done; }; [ -S /run/seatd.sock ] || { log "FAIL: seatd"; exit 1; }; }
|
|
wait_socket() { i=0; while [ $i -lt 300 ]; do for w in $XDG_RUNTIME_DIR/wayland-*; do case $w in *.lock) ;; *) [ -S "$w" ] && { basename $w; return 0; };; esac; done; sleep 0.1; i=$((i+1)); done; return 1; }
|
|
# RSS kB and CPU% (utime+stime over N s) of a pid
|
|
measure() { p=$1; n=${2:-30}; hz=100; a=$(awk '{print $14+$15}' /proc/$p/stat); t0=$(now); sleep $n; b=$(awk '{print $14+$15}' /proc/$p/stat); t1=$(now)
|
|
echo "pid=$p rss_kB=$(awk '/VmRSS/{print $2}' /proc/$p/status) cpu%=$(awk -v a=$a -v b=$b -v t0=$t0 -v t1=$t1 -v hz=$hz 'BEGIN{printf "%.2f", (b-a)/hz/(t1-t0)*100}') over ${n}s"; }
|