Skip to content

sensors: fix CSV selection and prevent false passes - #616

Merged
abbajaj806 merged 2 commits into
qualcomm-linux:mainfrom
smuppand:sensors
Oct 14, 2026
Merged

abbajaj806 merged 2 commits into
qualcomm-linux:mainfrom
smuppand:sensors

Conversation

@smuppand

@smuppand Srikanth Muppandam (smuppand) commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix false Sensors results when explicit CSV selections contain unavailable sensor types.

The quoted set -- "$SENSORS_CSV" kept the whole CSV as one sensor name. With --strict 0, this emptied the target set and incorrectly produced a control-plane PASS without running any selected sensor. The supplied DUT log reproduced this with accel,gravity,gyro,mag,pressur, even though the correctly named individual sensors were listed in inventory.

  • Parse CSV names individually, trim surrounding whitespace, deduplicate while preserving order and reject empty/unsafe entries before runtime operations.
  • Record unavailable selections as FAIL in strict mode or SKIP with --strict 0. An empty automatic/non-strict streaming selection is SKIP, never PASS.
  • Use shared result initialization, counters and finalization. Missing optional driver-tool coverage is recorded as SKIP rather than counted as PASS.
  • Require successful see_workhorse exit and its final documented PASS marker. Arbitrary nonempty output cannot establish success.
  • Preserve timeout failure even when a client exits zero after the deadline, without changing the existing timeout duration or signal sequence.
  • Treat failed discovery or missing TYPE output as FAIL, retain actionable diagnostics and document the policy.

Compatibility

Existing sensor inventory, auto/named-profile selection, CSV-over-profile precedence, optional ssc_drva_test support, package/provider flow, service handling and YAML interface are retained. Explicit --list still reports inventory-query success and states that streaming was not validated. No board or distro-specific selection rules are introduced.

With --strict 0, a partially available list can pass only after available sensors actually validate, with unavailable entries separately recorded as SKIP. Strict mode fails missing selections before streaming starts.

Add a pure CSV parser that trims and deduplicates TYPE names while rejecting empty or unsafe fields. Require successful see_workhorse exit and its final PASS marker, and retain timeout failure even when the client exits zero.

Keep existing helper call signatures and execution timing. This foundation is usable with the existing runner and supplies sensors_parse_csv for the following integration commit.

Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
Use shared CSV parsing and result orchestration. Classify unavailable selections according to strict mode, skip empty streaming selections and keep optional driver coverage visible without counting it as a pass. Validate selection input before runtime operations and document the operator policy.

Depends on the shared sensors helpers in 9126ee2. Revert this consumer commit before reverting the foundation, or revert both together.

Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
# shellcheck disable=SC2034
# shellcheck disable=SC1090
. "$INIT_ENV"
# shellcheck disable=SC1091

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems to be duplicate
We are already initializing it above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, there are two source statements in this bootstrap. The second does not repeat initialization: Runner/init_env lines 5-7 return immediately when __INIT_ENV_LOADED is set. The runner block retains the prescribed bootstrap pattern, including that guarded second source. It is redundant at the call site, but does not execute setup twice.

@@ -123,9 +200,10 @@ else
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is no if for this fi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The opening if is present just above the displayed diff context. Lines 194-200 contain the complete if / elif / else / fi block for resolving and entering the test directory. The fi at line 200 closes the if at line 194. I also reran dash -n and ShellCheck 0.9.0 on the current file, both passed.

@@ -183,9 +267,7 @@ if [ "$OVERLAY_REQUESTED" -eq 1 ]; then
pkg_ensure_optional_package_set_present \
pkg_verify_package_set_installed; do
if ! command -v "$required_helper" >/dev/null 2>&1; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This fragment has no surrounding loop:

IMO
It should be something like this

for required_helper in
pkg_ensure_optional_package_set_present
pkg_verify_package_set_installed
do
if ! command -v "$required_helper" >/dev/null 2>&1; then
test_result_finish FAIL
"Required package helper is unavailable: $required_helper"
fi
done

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The surrounding loop is already present in the full file at lines 265-272. It iterates over pkg_provider_init, pkg_ensure_optional_package_set_present and pkg_verify_package_set_installed, then checks each helper with command -v. The diff excerpt starts partway through that list and omits the opening for required_helper in.

test_result_finish FAIL "Failed to start $SENSORS_SERVICE, check the service status"
fi
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The shown code contains else and fi without the corresponding opening if statements. A structurally valid version would resemble:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The matching opening conditions are present in the full service block, lines 327-343. The outer condition checks distro support and systemctl, the next checks that the unit exists, and the inner conditions check whether it is active and whether starting it fails. The else at line 340 belongs to the unit-existence check at line 329. The diff omits some unchanged context. Both dash -n and ShellCheck pass on this revision.

TARGET_NL="$REQUESTED_TARGETS"
else
# 2) profile selection
case "$PROFILE" in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The profile selection is incomplete
The current block has no profile labels:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The profile labels are present immediately below the displayed excerpt: lines 396-425. The first case handles automatic discovery, and the second handles basic|core, vision and all, with a no-op auto arm and an invalid-profile fallback. No profile labels are missing. Combining the two case blocks could improve readability, but is not required to restore profile coverage.

if [ "$rc" -eq 0 ]; then
log_info "ssc_drva_test: PASS ($s) [log: $OUT_DIR/ssc_drva_test_${s}.log]"
pass_count=$((pass_count + 1))
test_result_record PASS "ssc_drva_test ($s), log=$OUT_DIR/ssc_drva_test_${s}.log"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The script uses SEE_DURATION, DRVA_DURATION, but their defaults are not shown:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Both defaults are already set before execution at lines 209-212: SEE_DURATION="${SEE_DURATION:-5}" and DRVA_DURATION="${DRVA_DURATION:-10}". These preserve nonempty CLI/environment overrides and otherwise use 5 and 10 seconds respectively. They are unchanged lines outside this diff excerpt, and the same defaults are documented in --help.

@abbajaj806 abbajaj806 left a comment

Copy link
Copy Markdown
Contributor

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 0bf20a2 into qualcomm-linux:main Oct 14, 2026
14 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