#!/bin/sh # License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. # # mcde-tests.sh -- the unit tests of MCDE from a native build of this host # # usage: tools/mcde-tests.sh [BUILD] # (make test calls it; no new make target) # # The unit tests of the CDE we ship: libMcdeSys (the OS layer), # libDtSvc (menu model, displays, the miniature), libDtWidget (the shared # preferences), and the plain-C parts of dtbar, dtlaunch, dtsystemsettings, # dtterm and fontaliases. They run without X and without root, in a scratch # HOME; a failure is red, the summary is "result: N ok, M bad". # # The build they come from is the native development build of this host: # build/mcde-host (make mcde-host, the desktop in /usr/mdt) or # build/mcde-linux (make mcde-linux, build/mcde-root/dt); BUILD names one of # them (default: build/mcde-host). A missing build is exit 2, not a test # failure. set -eu TOP=$(cd "$(dirname "$0")/.." && pwd) # Tests do not run beside a build (make test/cdtest hold the lock). "$TOP/tools/build-lock.sh" --check || exit 1 B=${1:-$TOP/build/mcde-host} [ -d "$B" ] || { echo "mcde-tests: no native build in $B: make mcde-host (or make mcde-linux)" >&2; exit 2; } TMP=$(mktemp -d "${TMPDIR:-/tmp}/mcde-tests.XXXXXX") trap 'rm -rf "$TMP"' EXIT HUP INT TERM ok=0 fail=0 pass() { printf 'ok %s\n' "$1"; ok=$((ok + 1)); } bad() { printf 'BAD %s: %s\n' "$1" "$2" >&2; fail=$((fail + 1)); } # one unit test: it must exit 0; the last line of its output is the look run_test() { name=$1 shift if HOME="$TMP" "$@" > "$TMP/out" 2>&1; then pass "$name" else rc=$? bad "$name" "exit $rc: $(tail -n 1 "$TMP/out")" fi } # libMcdeSys run_test "McdeSys/test_sysinfo" "$B/lib/McdeSys/test_sysinfo" run_test "McdeSys/test_netmount" "$B/lib/McdeSys/test_netmount" run_test "McdeSys/test_updatesource" "$B/lib/McdeSys/test_updatesource" run_test "McdeSys/test_processes" "$B/lib/McdeSys/test_processes" run_test "McdeSys/test_job" "$B/lib/McdeSys/test_job" run_test "McdeSys/test_netinput" "$B/lib/McdeSys/test_netinput" run_test "McdeSys/test_sysload" "$B/lib/McdeSys/test_sysload" run_test "McdeSys/test_audio" "$B/lib/McdeSys/test_audio" run_test "McdeSys/test_netwatch" "$B/lib/McdeSys/test_netwatch" # lib/DtSvc run_test "DtSvc/test_menumodel" "$B/lib/DtSvc/test_menumodel" run_test "DtSvc/test_displays" "$B/lib/DtSvc/test_displays" run_test "DtSvc/test_thumb" "$B/lib/DtSvc/test_thumb" # lib/DtWidget run_test "DtWidget/test_prefs" "$B/lib/DtWidget/test_prefs" # lib/libDtChat (dtchat's IPC contract) run_test "DtChat/test_json" "$B/lib/libDtChat/test_json" run_test "DtChat/test_frame" "$B/lib/libDtChat/test_frame" run_test "DtChat/test_loop" "$B/lib/libDtChat/test_loop" run_test "DtChat/test_store" "$B/lib/libDtChat/test_store" run_test "DtChat/test_conv" "$B/lib/libDtChat/test_conv" run_test "DtChat/test_text" "$B/lib/libDtChat/test_text" run_test "DtChat/test_irc" "$B/lib/libDtChat/test_irc" run_test "DtChat/test_identity" "$B/lib/libDtChat/test_identity" run_test "DtChat/test_peers" "$B/lib/libDtChat/test_peers" run_test "DtChat/test_local" "$B/lib/libDtChat/test_local" run_test "DtChat/test_filexfer" "$B/lib/libDtChat/test_filexfer" run_test "DtChat/test_pair" "$B/lib/libDtChat/test_pair" run_test "DtChat/test_fuzz" "$B/lib/libDtChat/test_fuzz" run_test "DtChat/test_i18n" "$B/lib/libDtChat/test_i18n" \ "$TOP/ext/src/mcde/programs/localized/de_DE.UTF-8/msg/dtchat.msg" \ "$TOP/ext/src/mcde/programs/dtchat/dtchat.msg" run_test "DtChat/test_audio_opus" "$B/lib/libDtChat/test_audio_opus" run_test "DtChat/test_media_packet" "$B/lib/libDtChat/test_media_packet" run_test "DtChat/test_media_call" "$B/lib/libDtChat/test_media_call" run_test "DtChat/test_video_vp8" "$B/lib/libDtChat/test_video_vp8" run_test "DtChat/test_video_packet" "$B/lib/libDtChat/test_video_packet" run_test "DtChat/test_video_render" "$B/lib/libDtChat/test_video_render" run_test "DtChat/test_capture" "$B/lib/libDtChat/test_capture" run_test "DtChat/test_media_sync" "$B/lib/libDtChat/test_media_sync" run_test "DtChat/p2p" "$TOP/ext/src/mcde/tests/p2p.sh" "$B/programs/dtchat/dtchat-headless" run_test "DtChat/p2p-audio" "$TOP/ext/src/mcde/tests/p2p-audio.sh" "$B/programs/dtchat/dtchat-headless" run_test "DtChat/irc_typing" "$TOP/ext/src/mcde/tests/irc_typing.py" "$B/programs/dtchat/dtchat-irc" run_test "DtChat/irc_join" "$TOP/ext/src/mcde/tests/irc_join.py" "$B/programs/dtchat/dtchat-irc" if [ -x "$B/programs/dtchat/dtchat-telegram" ]; then run_test "DtChat/telegram_fake" "$TOP/ext/src/mcde/tests/telegram_fake.py" "$B/programs/dtchat/dtchat-telegram" fi if [ -x "$B/programs/dtchat/dtchat-whatsapp" ]; then run_test "DtChat/whatsapp_fake" "$TOP/ext/src/mcde/tests/whatsapp_fake.py" "$B/programs/dtchat/dtchat-whatsapp" fi if [ -x "$B/programs/dtchat/dtchat-xmpp" ]; then run_test "DtChat/xmpp_fake" "$TOP/ext/src/mcde/tests/xmpp_fake.py" "$B/programs/dtchat/dtchat-xmpp" run_test "DtChat/xmpp_muc" "$TOP/ext/src/mcde/tests/xmpp_muc.py" "$B/programs/dtchat/dtchat-xmpp" run_test "DtChat/xmpp_drop" "$TOP/ext/src/mcde/tests/xmpp_drop.py" "$B/programs/dtchat/dtchat-xmpp" run_test "DtChat/xmpp_ibb" "$TOP/ext/src/mcde/tests/xmpp_ibb.py" "$B/programs/dtchat/dtchat-xmpp" fi run_test "DtChat/packaged_layout" "$TOP/ext/src/mcde/tests/packaged_layout.sh" "$B/programs/dtchat/dtchat" run_test "DtChat/file_ui" "$TOP/ext/src/mcde/tests/file_ui.sh" "$B/programs/dtchat/dtchat" "$B/lib/libDtChat/fake_adapter" run_test "DtChat/test_adapter" "$B/lib/libDtChat/test_adapter" run_test "DtChat/test_instance" "$B/lib/libDtChat/test_instance" # the plain-C parts of the programs run_test "dtbar/test_items" "$B/programs/dtbar/test_items" run_test "dtlaunch/test_model" "$B/programs/dtlaunch/test_model" run_test "dtsystemsettings/test_panes" "$B/programs/dtsystemsettings/test_panes" run_test "dtterm/test_profiles" "$B/programs/dtterm/test_profiles" # programs/fontaliases/test_fonts_alias needs an X display (XOpenDisplay) and # is therefore not part of the headless unit run. printf 'result: %s ok, %s bad\n' "$ok" "$fail" [ "$fail" -eq 0 ]