Skip to content

Inner-Loop Hotbind Testing (hotbind_test_harness.sh) ​

Rebuilding and flashing a multi-gigabyte super image for every single VDI or daemon code change wastes time and increases flash wear. UniOHOS/builder/harness/hotbind_test_harness.sh supports fast inner-loop testing by bind-mounting a single compiled binary inside the device's PID1 mount namespace and restarting only the target OpenHarmony service.

1. Safety Defaults & Design Guarantees ​

  • Offline --dry-run by Default: Invoking the script without a mode flag (or with FORCE_DRY_RUN=1) runs purely offline static validation and argument checks without touching any connected device.
  • Strict Target Path Validation: Rejects relative paths, shell metacharacters, .. traversal, and top-level system mountpoints (/, /dev, /proc, /sys, /data, /etc, /system, /vendor, /sys_prod, /chip_prod).
  • Namespace-Scoped MS_BIND & SHA-256 Check: Applies mount -o bind cleanly inside nsenter -t 1 -m (or chipset/system sandbox mode), checks for duplicate mounts, verifies end-to-end SHA-256 parity, and restarts only the requested service (param set ohos.ctl.stop/start).
  • Optional OLED Screen-Off Protection: By default during automated tests, ensures BRI=0 after operations and on abnormal exit traps; pass --keep-screen when interactively inspecting UI on screen.

2. Host Environment Prerequisites ​

hotbind_test_harness.sh delegates device serial control and safe remote command execution to local host helper scripts configured via environment variables (defaulting to paths under UNIOHOS_WORKSPACE, which defaults to $(pwd)):

Environment VariableDefaultPurpose
UNIOHOS_WORKSPACE$(pwd)Base directory used to resolve default helper script paths.
UNIOHOS_PROBE_RW_DIR$UNIOHOS_WORKSPACE/tools/oled-guardDirectory containing your host serial helper probe_rw.py.
UNIOHOS_COLLECTOR_SCRIPT$UNIOHOS_WORKSPACE/tools/flash_and_verify.pySafe remote execution helper script (safe_exec).
HDC_BIN$HOME/.local/bin/hdcPath to the OpenHarmony hdc host binary.
FORCE_DRY_RUN0Set to 1 to force --dry-run regardless of other mode flags.

Note on --dry-run Helper Checks

Even in --dry-run mode, the harness validates that probe_rw.py and flash_and_verify.py exist at UNIOHOS_PROBE_RW_DIR and UNIOHOS_COLLECTOR_SCRIPT before executing its static syntax and argument-guard self-checks. Point those two variables at your local bring-up workstation helpers (or stub paths when testing in CI).

3. Command Reference ​

bash
# Pure offline syntax, guard, and CLI validation (zero device mutation)
sh harness/hotbind_test_harness.sh --dry-run
bash
# Read-only check of current hotbind mounts and target SHA-256
sh harness/hotbind_test_harness.sh   --status   --target /vendor/lib64/libdisplay_composer_vdi_impl.z.so   --keep-screen
bash
# Push one binary, bind-mount into PID1 namespace, and restart only render_service
sh harness/hotbind_test_harness.sh   --apply   --local out/libdisplay_composer_vdi_impl.z.so   --target /vendor/lib64/libdisplay_composer_vdi_impl.z.so   --service render_service   --keep-screen
bash
# Unmount the bind override, clean staging files, and restore the stock read-only file
sh harness/hotbind_test_harness.sh   --unmount   --target /vendor/lib64/libdisplay_composer_vdi_impl.z.so   --service render_service   --keep-screen

4. All Supported Options ​

FlagDescription
--dry-runDefault mode. Offline hygiene, path guard, and CLI stub self-check.
--statusRead-only status query and target SHA-256 check inside the PID1 mount namespace.
--applyPush --local <file>, bind-mount onto --target <dev_path>, verify SHA-256, and restart --service.
--unmountUnmount --target <dev_path>, clean temporary staged file, and restart --service.
--local <file>Local compiled binary or config to push (required for --apply).
--target <dev_path>Absolute on-device destination path (required for --apply and --unmount).
--service <svc_or_none>Single OpenHarmony service name to restart, or none (required for --apply and --unmount).
--sandbox <mode>Target mount namespace mode: pid1 (default), chipset, or system.
--hdc-check <subsys_id>Optional post-apply host-side hdc shell hidumper -s <id> verification.
--keep-screenSkip post-run BRI=0 screen blanking when actively viewing the screen.
--log-dir <dir>Custom log output directory (defaults to .uniohos-logs/hb_<ts>).

Inner Loop vs Outer Loop

Use hotbind_test_harness.sh for fast single-variable debugging during bring-up. Because MS_BIND overlays live in memory only and disappear on reboot, always fold verified changes back into your EROFS partition build and validate a clean cold boot before closing a milestone.

Independent Open-Source Community (CC-BY-4.0). Not affiliated with Huawei, HiSilicon, OpenAtom Foundation, Xiaomi, Qualcomm, MediaTek, or Arm.