Skip to content

Commit

Permalink
test: on_target: add location tests
Browse files Browse the repository at this point in the history
adds location tests for Wi-Fi and GNSS.
GNSS not active yet.

Signed-off-by: David Dilner <[email protected]>
  • Loading branch information
dilner committed Oct 23, 2024
1 parent 3446a74 commit a7b8429
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/on_target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ jobs:
NRF91_CUSTOM_APP_ZIP: artifacts/usb_uart_bridge_app.zip
LOG_FILENAME: oob_conn_bridge_test_log

- name: Run Wi-Fi location tests
working-directory: thingy91x-oob/tests/on_target
run: |
mkdir -p results
pytest -s -v -m "dut1 and wifi" \
--junit-xml=results/test-results-wifi-location.xml \
tests
env:
SEGGER: ${{ secrets.SEGGER_DUT_1 }}

- name: Results
if: always()
uses: pmeier/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions tests/on_target/tests/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ markers =
uart: uart tests
fota: standard fota tests
fullmfw_fota: fullmfw fota tests
wifi: wifi location tests
gnss: device used for GNSS tests
54 changes: 54 additions & 0 deletions tests/on_target/tests/test_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
##########################################################################################
# Copyright (c) 2024 Nordic Semiconductor
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
##########################################################################################

import pytest
import time
import os
import re
from utils.flash_tools import flash_device, reset_device
import sys
sys.path.append(os.getcwd())
from utils.logger import get_logger

logger = get_logger()

@pytest.mark.wifi
@pytest.mark.dut1
def test_wifi_location(t91x_board, hex_file):
run_location(t91x_board, hex_file, location_method="Wi-Fi")

@pytest.mark.gnss
def test_gnss_location(t91x_board, hex_file):
run_location(t91x_board, hex_file, location_method="GNSS")

def run_location(t91x_board, hex_file, location_method):
flash_device(os.path.abspath(hex_file))
time.sleep(5)
t91x_board.uart.xfactoryreset()
patterns_cloud_connection = [
"Network connectivity established",
"Connected to Cloud"
]
patterns_location = [
f"location_core_location_get_pos: Requesting location with '{location_method}' method",
f"location: LOCATION_REQ_MODE_ALL: acquired location using '{location_method}'",
"location_event_handler: Got location: lat:",
"blocked_run: Location search done",]

# Cloud connection
t91x_board.uart.flush()
reset_device()
t91x_board.uart.wait_for_str(patterns_cloud_connection, timeout=60)

# Location
t91x_board.uart.wait_for_str(patterns_location, timeout=180)

# Extract coordinates from UART output
location_pattern = re.compile(r"location_event_handler: Got location: lat: ([\d.]+), lon: ([\d.]+), acc: ([\d.]+)")
match = location_pattern.search(t91x_board.uart.log)
assert match, "Failed to extract coordinates from UART output"
lat, lon, _ = match.groups()
assert abs(float(lat) - 61.5) < 2 and abs(float(lon) - 10.5) < 1, \
f"Coordinates ({lat}, {lon}) are not in the same part of the world as the test servers."

0 comments on commit a7b8429

Please sign in to comment.