xref: /linux/tools/verification/rvgen/tests/rvgen_monitor.t (revision 55ee4b931a7ffedc886175d265dd6e6d08fd4151)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3source ../tests/engine.sh
4test_begin
5
6set_timeout 30s
7
8# Help and basic tests
9check "verify help page" \
10	"$RVGEN --help" 0 "Generate kernel rv monitor"
11
12check "verify monitor subcommand help" \
13	"$RVGEN monitor --help" 0 "Monitor class"
14
15# DA monitor tests - test all monitor types
16check_and_compare_folder "DA per_cpu (default name)" \
17	"$RVGEN monitor -c da -s tests/specs/test_da.dot -t per_cpu" \
18	"test_da" "obj-\$(CONFIG_RV_MON_TEST_DA) += monitors/test_da/test_da.o"
19
20check_and_compare_folder "DA global type" \
21	"$RVGEN monitor -c da -s tests/specs/test_da.dot -t global -n da_global" \
22	"da_global" "DA_MON_EVENTS_IMPLICIT"
23
24check_and_compare_folder "DA per_task with description" \
25	"$RVGEN monitor -c da -s tests/specs/test_da2.dot -t per_task -n da_pertask_desc -D 'Custom description for testing'" \
26	"da_pertask_desc" "#include <monitors/da_pertask_desc/da_pertask_desc_trace.h>"
27
28check_and_compare_folder "DA per_obj with parent" \
29	"$RVGEN monitor -c da -s tests/specs/test_da2.dot -t per_obj -n da_perobj_parent -p parent_mon" \
30	"da_perobj_parent" "DA_MON_EVENTS_ID"
31
32# HA monitor tests
33check_and_compare_folder "HA per_task (default name)" \
34	"$RVGEN monitor -c ha -s tests/specs/test_ha.dot -t per_task" \
35	"test_ha" "HA_MON_EVENTS_ID"
36
37check_and_compare_folder "HA per_cpu type" \
38	"$RVGEN monitor -c ha -s tests/specs/test_ha.dot -t per_cpu -n ha_percpu" \
39	"ha_percpu" "HA_MON_EVENTS_IMPLICIT"
40
41# LTL monitor test
42check_and_compare_folder "LTL per_task" \
43	"$RVGEN monitor -c ltl -s tests/specs/test_ltl.ltl -t per_task -n ltl_pertask" \
44	"ltl_pertask" "source \"kernel/trace/rv/monitors/ltl_pertask/Kconfig\""
45
46check_and_compare_folder "LTL per_task with parent and description (default name)" \
47	"$RVGEN monitor -c ltl -s tests/specs/test_ltl.ltl -t per_task -p ltl_parent -D 'Simple description'" \
48	"test_ltl" "LTL_MON_EVENTS_ID"
49
50# Error handling tests
51check "missing required spec argument" \
52	"$RVGEN monitor -c da -t per_cpu" 2 \
53	"the following arguments are required: -s/--spec" "Traceback (most recent call last)"
54
55check "missing required monitor type" \
56	"$RVGEN monitor -c da -s tests/specs/test_da.dot" 2 \
57	"the following arguments are required: -t/--monitor_type" "Traceback (most recent call last)"
58
59check "missing required monitor class" \
60	"$RVGEN monitor -s tests/specs/test_da.dot -t per_cpu" 2 \
61	"the following arguments are required: -c/--class" "Traceback (most recent call last)"
62
63check "invalid monitor class" \
64	"$RVGEN monitor -c invalid -s tests/specs/test_da.dot -t per_cpu" 1 \
65	"Unknown monitor class" "Traceback (most recent call last)"
66
67check "missing dot file" \
68	"$RVGEN monitor -c da -s tests/specs/nonexistent.dot -t per_cpu" 1 \
69	"No such file or directory" "Traceback (most recent call last)"
70
71check "missing ltl file" \
72	"$RVGEN monitor -c ltl -s tests/specs/nonexistent.ltl -t per_task" 1 \
73	"No such file or directory" "Traceback (most recent call last)"
74
75check "invalid dot file syntax" \
76	"$RVGEN monitor -c da -s tests/specs/test_invalid.dot -t per_cpu" 1 \
77	"The automaton doesn't have an initial state" "Traceback (most recent call last)"
78
79check "invalid ha file syntax" \
80	"$RVGEN monitor -c ha -s tests/specs/test_invalid_ha.dot -t per_obj" 1 \
81	"Unrecognised event" "Traceback (most recent call last)"
82
83check "invalid ltl file syntax" \
84	"$RVGEN monitor -c ltl -s tests/specs/test_invalid.ltl -t per_task" 1 \
85	"No terminal matches 'i'" "Traceback (most recent call last)"
86
87test_end
88