1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3source ../tests/engine.sh 4test_begin 5 6set_timeout 30s 7 8RVDIR=/sys/kernel/tracing/rv/ 9 10# Help and basic tests 11check "verify help page" \ 12 "$RV --help" 0 "usage: rv command" 13 14check "verify list subcommand help" \ 15 "$RV list --help" 0 "list all available monitors" 16 17all_nested=$(grep : $RVDIR/available_monitors | cut -d: -f2 | paste -s | sed 's/\t/\\|/g') 18all_non_nested=$(grep -v : $RVDIR/available_monitors | cut -d: -f2 | paste -s | sed 's/\t/\\|/g') 19sched_monitors=$(grep sched: $RVDIR/available_monitors | cut -d: -f2 | paste -s | sed 's/\t/\\|/g') 20description_state="[[:space:]]\+[[:print:]]\+\[\(OFF\|ON\)\]" 21line_nested=" - \($all_nested\)${description_state}" 22line_non_nested="\($all_non_nested\)${description_state}" 23 24# List monitors and containers 25check "list all monitors" \ 26 "$RV list" 0 "" "" "^\($line_nested\|$line_non_nested\)$" 27 28check_if_exists "list container" \ 29 "$RV list sched" "$RVDIR/monitors/sched" \ 30 "" "-- No monitor found in container sched --" \ 31 "^\($sched_monitors\)${description_state}$" 32 33check_if_exists "list non-container" \ 34 "$RV list wwnr" "$RVDIR/monitors/wwnr" \ 35 "-- No monitor found in container wwnr --" \ 36 "^\( - \)\?[[:alnum:]]\+${description_state}$" 37 38check "list incomplete container name" \ 39 "$RV list s" 0 "-- No monitor found in container s --" 40 41# Error handling tests 42check "no command" \ 43 "$RV" 1 "rv requires a command" 44 45check "invalid command" \ 46 "$RV invalid" 1 "rv does not know the invalid command" 47 48test_end 49