Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Runner/suites/Connectivity/Bluetooth/BT_ON_OFF/BT_ON_OFF.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
metadata:
name: bt-on-off
format: "Lava-Test Test Definition 1.0"
description: "Toggle Bluetooth on/off using qcom-linux-testkit BT_ON_FF"
os:
- linux
scope:
- functional

run:
steps:
- cd Runner
- REPO_ROOT="$PWD"
- RPATH="$REPO_ROOT/suites/Connectivity/Bluetooth/BT_ON_FF/run.sh"
- RESFILE="$REPO_ROOT/suites/Connectivity/Bluetooth/BT_ON_FF/BT_ON_FF.res"
- rm -f "$RESFILE" 2>/dev/null || true
- "$RPATH" || true
Copy link
Contributor

Choose a reason for hiding this comment

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

YAML parser doesn't like these variable substitutions:

>>> y = yaml.safe_load(f.read())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 125, in safe_load
    return load(stream, SafeLoader)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 81, in load
    return loader.get_single_data()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 110, in compose_sequence_node
    while not self.check_event(SequenceEndEvent):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 384, in parse_block_sequence_entry
    if not self.check_token(BlockEntryToken, BlockEndToken):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 239, in fetch_more_tokens
    return self.fetch_literal()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 635, in fetch_literal
    self.fetch_block_scalar(style='|')
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 649, in fetch_block_scalar
    self.tokens.append(self.scan_block_scalar(style))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 989, in scan_block_scalar
    chomping, increment = self.scan_block_scalar_indicators(start_mark)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 1087, in scan_block_scalar_indicators
    raise ScannerError("while scanning a block scalar", start_mark,
yaml.scanner.ScannerError: while scanning a block scalar
  in "<unicode string>", line 17, column 16:
        - "$RPATH" || true
                   ^
expected chomping or indentation indicators, but found '|'
  in "<unicode string>", line 17, column 17:
        - "$RPATH" || true

- "$REPO_ROOT/utils/send-to-lava.sh" "$RESFILE" || true
- "$REPO_ROOT/utils/result_parse.sh" || true
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
metadata:
name: bt-scan-pair
format: "Lava-Test Test Definition 1.0"
description: "Pair/connect to a BT device using qcom-linux-testkit BT_SCAN_PAIR"
os:
- Yocto
- Ubuntu
- Debina
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

scope:
- functional

params:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be useful to add a comment saying that the script uses these parameters from environment.

bt_mac: ""
bt_name: ""
whitelist: ""
pair_retries: "3"
scan_attempts: "2"

run:
steps:
- cd qcom-linux-testkit/Runner/suites/Connectivity/Bluetooth/BT_SCAN_PAIR
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be

cd ./qcom-linux-testkit/Runner/suites/Connectivity/Bluetooth/BT_SCAN_PAIR

Tried to run it here: https://lava.infra.foundries.io/scheduler/job/114175

- ./run.sh
- ../../../../utils/send-to-lava.sh ./BT_SCAN_PAIR.res || true
- ../../../../utils/result_parse.sh || true
161 changes: 150 additions & 11 deletions Runner/suites/Connectivity/Bluetooth/BT_SCAN_PAIR/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/sh

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# Robustly find and source init_env
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
INIT_ENV=""
Expand Down Expand Up @@ -42,29 +40,170 @@ rm -f "$RES_FILE"
log_info "------------------------------------------------------------"
log_info "Starting $TESTNAME Testcase"

# ------------------- Minimal long-option support (multi-line) -------------------
# Env defaults are honored; long options update variables; positional fallback remains.

# Defaults
PAIR_RETRIES="${PAIR_RETRIES:-3}"
SCAN_ATTEMPTS="${SCAN_ATTEMPTS:-2}"

BT_NAME=""
BT_MAC=""
WHITELIST=""
# Accept env overrides for identity too (optional)
BT_NAME="${BT_NAME:-}"
BT_MAC="${BT_MAC:-}"
WHITELIST="${WHITELIST:-}"

# Params from LAVA (lowercase -> our uppercase) – only if not already set
if [ -z "${BT_MAC:-}" ] && [ -n "${bt_mac:-}" ]; then
BT_MAC="$bt_mac"
fi

if [ -z "${BT_NAME:-}" ] && [ -n "${bt_name:-}" ]; then
BT_NAME="$bt_name"
fi

if [ -z "${WHITELIST:-}" ] && [ -n "${whitelist:-}" ]; then
WHITELIST="$whitelist"
fi

# Numeric knobs (pair/scan) – use if provided and numeric (multi-line)
case "${pair_retries:-}" in
''|*[!0-9]*)
:
;;
*)
PAIR_RETRIES="$pair_retries"
;;
esac

case "${scan_attempts:-}" in
''|*[!0-9]*)
:
;;
*)
SCAN_ATTEMPTS="$scan_attempts"
;;
esac

usage_bt() {
cat <<EOF
Usage: $0 [OPTIONS] [MAC-or-NAME] [WHITELIST]

Options (long):
--mac=AA:BB:CC:DD:EE:FF Set target MAC (overrides positional)
--name=DeviceName Set target device name (overrides positional)
--whitelist=/path/list.txt Set whitelist file
--pair-retries=N Default: ${PAIR_RETRIES}
--scan-attempts=N Default: ${SCAN_ATTEMPTS}
-h, --help Show this help

Positional fallback (kept exactly as before):
1) MAC-or-NAME 2) WHITELIST
EOF
}

# Tiny parser for --key and --key=value (POSIX, no getopts)
while [ $# -gt 0 ]; do
case "$1" in
--mac)
shift
[ -n "${1-}" ] && BT_MAC="$1"
shift
continue
;;
--mac=*)
BT_MAC="${1#*=}"
shift
continue
;;
--name)
shift
[ -n "${1-}" ] && BT_NAME="$1"
shift
continue
;;
--name=*)
BT_NAME="${1#*=}"
shift
continue
;;
--whitelist)
shift
[ -n "${1-}" ] && WHITELIST="$1"
shift
continue
;;
--whitelist=*)
WHITELIST="${1#*=}"
shift
continue
;;
--pair-retries)
shift
[ -n "${1-}" ] && PAIR_RETRIES="$1"
shift
continue
;;
--pair-retries=*)
PAIR_RETRIES="${1#*=}"
shift
continue
;;
--scan-attempts)
shift
[ -n "${1-}" ] && SCAN_ATTEMPTS="$1"
shift
continue
;;
--scan-attempts=*)
SCAN_ATTEMPTS="${1#*=}"
shift
continue
;;
-h|--help)
usage_bt
exit 0
;;
--) # stop option parsing; leave remaining for legacy positional handling
shift
break
;;
-*)
log_warn "Unknown option: $1"
shift
continue
;;
*)
# leave for legacy positional block below
break
;;
esac
done
# ----------------- end of minimal long-option support --------------------------

# Parse CLI args
if [ -n "$1" ]; then
# Legacy positional parsing (unchanged behavior)
if [ -n "${1-}" ]; then
if echo "$1" | grep -Eq '^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$'; then
BT_MAC="$1"
BT_MAC="${BT_MAC:-$1}"
else
BT_NAME="$1"
BT_NAME="${BT_NAME:-$1}"
fi
fi
if [ -n "$2" ]; then
WHITELIST="$2"
if [ -n "${2-}" ]; then
WHITELIST="${WHITELIST:-$2}"
if [ -z "$BT_MAC" ] && echo "$2" | grep -Eq '^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$'; then
BT_MAC="$2"
fi
fi

# Multi-line config echo (for debugging in LAVA logs)
log_info "BT args:
MAC=${BT_MAC-}
NAME=${BT_NAME-}
WHITELIST=${WHITELIST-}
PAIR_RETRIES=${PAIR_RETRIES}
SCAN_ATTEMPTS=${SCAN_ATTEMPTS}
"

# Skip if no CLI input and no list file
if [ -z "$BT_MAC" ] && [ -z "$BT_NAME" ] && [ ! -f "./bt_device_list.txt" ]; then
log_warn "No MAC/name or bt_device_list.txt found. Skipping test."
Expand Down
Loading