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-runby Default: Invoking the script without a mode flag (or withFORCE_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: Appliesmount -o bindcleanly insidensenter -t 1 -m(orchipset/systemsandbox 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=0after operations and on abnormal exit traps; pass--keep-screenwhen 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 Variable | Default | Purpose |
|---|---|---|
UNIOHOS_WORKSPACE | $(pwd) | Base directory used to resolve default helper script paths. |
UNIOHOS_PROBE_RW_DIR | $UNIOHOS_WORKSPACE/tools/oled-guard | Directory containing your host serial helper probe_rw.py. |
UNIOHOS_COLLECTOR_SCRIPT | $UNIOHOS_WORKSPACE/tools/flash_and_verify.py | Safe remote execution helper script (safe_exec). |
HDC_BIN | $HOME/.local/bin/hdc | Path to the OpenHarmony hdc host binary. |
FORCE_DRY_RUN | 0 | Set 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
# Pure offline syntax, guard, and CLI validation (zero device mutation)
sh harness/hotbind_test_harness.sh --dry-run# 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# 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# 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-screen4. All Supported Options
| Flag | Description |
|---|---|
--dry-run | Default mode. Offline hygiene, path guard, and CLI stub self-check. |
--status | Read-only status query and target SHA-256 check inside the PID1 mount namespace. |
--apply | Push --local <file>, bind-mount onto --target <dev_path>, verify SHA-256, and restart --service. |
--unmount | Unmount --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-screen | Skip 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.