[PATCH 24/26] rv/rvgen: make monitor arguments required in rvgen

Wander Lairson Costa posted 26 patches 2 weeks, 5 days ago
There is a newer version of this series
[PATCH 24/26] rv/rvgen: make monitor arguments required in rvgen
Posted by Wander Lairson Costa 2 weeks, 5 days ago
Add required=True to the monitor subcommand arguments for class, spec,
and monitor_type in rvgen. These arguments are essential for monitor
generation and attempting to run without them would cause AttributeError
exceptions later in the code when the script tries to access them.

Making these arguments explicitly required provides clearer error
messages to users at parse time rather than cryptic exceptions during
execution. This improves the user experience by catching missing
arguments early with helpful usage information.

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
---
 tools/verification/rvgen/__main__.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/verification/rvgen/__main__.py b/tools/verification/rvgen/__main__.py
index eeeccf81d4b90..f3e79b14c5d5d 100644
--- a/tools/verification/rvgen/__main__.py
+++ b/tools/verification/rvgen/__main__.py
@@ -28,10 +28,11 @@ if __name__ == '__main__':
     monitor_parser.add_argument('-n', "--model_name", dest="model_name")
     monitor_parser.add_argument("-p", "--parent", dest="parent",
                                 required=False, help="Create a monitor nested to parent")
-    monitor_parser.add_argument('-c', "--class", dest="monitor_class",
+    monitor_parser.add_argument('-c', "--class", dest="monitor_class", required=True,
                                 help="Monitor class, either \"da\" or \"ltl\"")
-    monitor_parser.add_argument('-s', "--spec", dest="spec", help="Monitor specification file")
-    monitor_parser.add_argument('-t', "--monitor_type", dest="monitor_type",
+    monitor_parser.add_argument('-s', "--spec", dest="spec", required=True,
+                                help="Monitor specification file")
+    monitor_parser.add_argument('-t', "--monitor_type", dest="monitor_type", required=True,
                                 help=f"Available options: {', '.join(Monitor.monitor_types.keys())}")
 
     container_parser = subparsers.add_parser("container")
-- 
2.52.0
Re: [PATCH 24/26] rv/rvgen: make monitor arguments required in rvgen
Posted by Nam Cao 2 weeks, 2 days ago
Wander Lairson Costa <wander@redhat.com> writes:

> Add required=True to the monitor subcommand arguments for class, spec,
> and monitor_type in rvgen. These arguments are essential for monitor
> generation and attempting to run without them would cause AttributeError
> exceptions later in the code when the script tries to access them.
>
> Making these arguments explicitly required provides clearer error
> messages to users at parse time rather than cryptic exceptions during
> execution. This improves the user experience by catching missing
> arguments early with helpful usage information.
>
> Signed-off-by: Wander Lairson Costa <wander@redhat.com>

Reviewed-by: Nam Cao <namcao@linutronix.de>
Re: [PATCH 24/26] rv/rvgen: make monitor arguments required in rvgen
Posted by Gabriele Monaco 2 weeks, 5 days ago
On Mon, 2026-01-19 at 17:46 -0300, Wander Lairson Costa wrote:
> Add required=True to the monitor subcommand arguments for class, spec,
> and monitor_type in rvgen. These arguments are essential for monitor
> generation and attempting to run without them would cause AttributeError
> exceptions later in the code when the script tries to access them.
> 
> Making these arguments explicitly required provides clearer error
> messages to users at parse time rather than cryptic exceptions during
> execution. This improves the user experience by catching missing
> arguments early with helpful usage information.
> 
> Signed-off-by: Wander Lairson Costa <wander@redhat.com>

Good catch, thanks!

Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>

> ---
>  tools/verification/rvgen/__main__.py | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/verification/rvgen/__main__.py
> b/tools/verification/rvgen/__main__.py
> index eeeccf81d4b90..f3e79b14c5d5d 100644
> --- a/tools/verification/rvgen/__main__.py
> +++ b/tools/verification/rvgen/__main__.py
> @@ -28,10 +28,11 @@ if __name__ == '__main__':
>      monitor_parser.add_argument('-n', "--model_name", dest="model_name")
>      monitor_parser.add_argument("-p", "--parent", dest="parent",
>                                  required=False, help="Create a monitor nested
> to parent")
> -    monitor_parser.add_argument('-c', "--class", dest="monitor_class",
> +    monitor_parser.add_argument('-c', "--class", dest="monitor_class",
> required=True,
>                                  help="Monitor class, either \"da\" or
> \"ltl\"")
> -    monitor_parser.add_argument('-s', "--spec", dest="spec", help="Monitor
> specification file")
> -    monitor_parser.add_argument('-t', "--monitor_type", dest="monitor_type",
> +    monitor_parser.add_argument('-s', "--spec", dest="spec", required=True,
> +                                help="Monitor specification file")
> +    monitor_parser.add_argument('-t', "--monitor_type", dest="monitor_type",
> required=True,
>                                  help=f"Available options: {',
> '.join(Monitor.monitor_types.keys())}")
>  
>      container_parser = subparsers.add_parser("container")