Skip to content

Conversation

smuppand
Copy link
Contributor

@smuppand smuppand commented Oct 1, 2025

This PR addresses the enhancements that were requested as of now #179

Why

  • On several images the DSP skeletons live under /usr/share/qcom/**/dsp but /usr/lib/dsp is empty. Manually creating SoC-specific links doesn’t scale and is brittle across new targets.
  • Rootfs often lacks timeout/gtimeout, calling run_with_timeout with an empty/invalid timeout caused errors via functestlib.
  • Tests should not fail when fastrpc_test isn’t installed yet or when /bin layout is disallowed by policy.

What changed (high level)

  • Generic DSP autolink (idempotent, SoC-agnostic)
    • New ensure_usr_lib_dsp_symlinks() populates /usr/lib/dsp only if empty.
    • Auto-discovers the best source under /usr/share/qcom/**/dsp using detect_platform hints (if available), falling back to the most populated candidate.
    • Links both files and directories (e.g. adsp/, cdsp/), does not clobber existing names, and prints a short listing after completion.
    • Completely Yocto-safe (no sudo): requires root; optionally remounts the underlying FS rw if FASTRPC_AUTOREMOUNT=yes and restores ro unless FASTRPC_AUTOREMOUNT_RO=no.
    • Never hard-fails the testcase—warns and continues if linking isn’t possible.
  • Guarded timeout wrapper
    • Introduced runWithTimeoutIfSet in run.sh to only call run_with_timeout when TIMEOUT is a positive integer and the function exists.
    • Otherwise executes the command directly. This fixes:
    • sleep: invalid number ''
  • No dependency on external timeout/gtimeout binaries.
  • SKIP semantics for absent binary / disallowed layout
    • If fastrpc_test is not present/executable at the chosen path, SKIP (emit fastrpc_test SKIP in .res) instead of FAIL.
    • If --bin-dir /bin is used and ALLOW_BIN_FASTRPC is not set, SKIP with a clear message (policy opt-in via ALLOW_BIN_FASTRPC=1).
  • Minor quality-of-life
  • --assets-dir is accepted for compatibility but logged as ignored under the new layout.
  • Logging aligned with functestlib.sh.

Environment knobs

  • FASTRPC_DSP_AUTOLINK=yes|no (default: yes) — enable/disable autolink.
  • FASTRPC_DSP_SRC=/path/to/dsp — force a specific source directory.
  • FASTRPC_AUTOREMOUNT=yes|no (default: no) — allow RO→RW remount to create /usr/lib/dsp and links.
  • FASTRPC_AUTOREMOUNT_RO=yes|no (default: yes) — remount back to RO when we changed it.
  • ALLOW_BIN_FASTRPC=1 — permit /bin/fastrpc_test usage when --bin-dir /bin.

User-visible behavior

  • On first run where /usr/lib/dsp is empty:
  • Auto-creates symlinks like: /usr/lib/dsp/adsp -> /usr/share/qcom////dsp/adsp /usr/lib/dsp/cdsp -> ...
  • Logs how many links were created and lists them.
  • If no source is found or filesystem is RO and remount not allowed → warns and continues (no FAIL).
  • If fastrpc_test is missing → SKIP.
  • If TIMEOUT unset or non-numeric → run without timeout (no wrapper errors).

Introduce a portable, idempotent autolink step that populates /usr/lib/dsp
from /usr/share/qcom/**/dsp only when /usr/lib/dsp is empty.

Key points
- No SoC hardcoding: discovers all /usr/share/qcom/**/dsp candidates and
  picks the best match using platform hints (detect_platform if present)
  or falls back to the most populated candidate.
- Yocto-safe, sudo-free: requires root; if filesystem is read-only,
  optionally remounts rw when FASTRPC_AUTOREMOUNT=yes and restores ro
  unless FASTRPC_AUTOREMOUNT_RO=no.
- Idempotent & safe: skips when /usr/lib/dsp already has entries; does
  not clobber existing files; links files only; warns instead of failing
  if linking isn’t possible.
- Configurable knobs:
    * FASTRPC_DSP_AUTOLINK=yes|no   (default: yes)
    * FASTRPC_DSP_SRC=/path/to/dsp  (force a specific source)
    * FASTRPC_AUTOREMOUNT=yes|no    (default: no)
    * FASTRPC_AUTOREMOUNT_RO=yes|no (default: yes)
- Clean helpers: no underscores in helper function/var names to match
  repo style; pure POSIX sh.
- Placement: autolink runs once before LD_LIBRARY_PATH and
  *DSP_LIBRARY_PATH exports; logging via functestlib.

This makes fastrpc_test robust across Kodiak/LeMans/Monaco/Agatti/Talos
and future targets without per-SoC maintenance while keeping tests
non-fatal when DSP assets are missing or the FS is read-only.

Signed-off-by: Srikanth Muppandam <[email protected]>
Copy link
Contributor

@abbajaj806 abbajaj806 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@abbajaj806 abbajaj806 merged commit 78197b9 into qualcomm-linux:main Oct 3, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants