#!/usr/bin/env bats # tests/test_shell.bats — Tests for 'fs5 shell' command (US4) bats_require_minimum_version 1.5.0 SCRIPT="${BATS_TEST_DIRNAME}/../fs5" setup() { export DEVICE_SERIAL="RD51QE202392" export LOG_FILE="/tmp/fs5-test-$$.log" } teardown() { rm -f "${LOG_FILE}" } @test "shell: executes echo command on device" { run "${SCRIPT}" shell "echo hello-from-device" [ "${status}" -eq 0 ] [[ "${output}" == *"hello-from-device"* ]] } @test "shell: forwards exit code from device command" { run "${SCRIPT}" shell "exit 0" [ "${status}" -eq 0 ] } @test "shell: returns device hostname/uname" { run "${SCRIPT}" shell "uname -s" [ "${status}" -eq 0 ] [[ "${output}" == *"Linux"* ]] } @test "shell: --help shows usage" { run "${SCRIPT}" shell --help [ "${status}" -eq 0 ] [[ "${output}" == *"shell"* ]] } @test "shell: exits with code 2 when device not connected" { DEVICE_SERIAL="INVALID_SERIAL_000" run "${SCRIPT}" shell "echo test" [ "${status}" -eq 2 ] }