[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-s390
Subject: Re: [kvm-unit-tests PATCH] s390x: Add strict mode to specification exception interpretation test
From: Claudio Imbrenda <imbrenda () linux ! ibm ! com>
Date: 2022-02-28 13:27:27
Message-ID: 20220228142727.3542b767 () p-imbrenda
[Download RAW message or body]
On Fri, 25 Feb 2022 18:23:55 +0100
Janis Schoetterl-Glausch <scgl@linux.ibm.com> wrote:
> While specification exception interpretation is not required to occur,
> it can be useful for automatic regression testing to fail the test if it
> does not occur.
> Add a `--strict` argument to enable this.
> `--strict` takes a list of machine types (as reported by STIDP)
> for which to enable strict mode, for example
> `--strict 8562,8561,3907,3906,2965,2964`
> will enable it for models z15 - z13.
> Alternatively, strict mode can be enabled for all but the listed machine
> types by prefixing the list with a `!`, for example
> `--strict !1090,1091,2064,2066,2084,2086,2094,2096,2097,2098,2817,2818,2827,2828`
> will enable it for z/Architecture models except those older than z13.
>
> Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
> ---
[...]
> +static bool parse_strict(int argc, char **argv)
> +{
> + uint16_t machine_id;
> + char *list;
> + bool ret;
> +
> + if (argc < 1)
> + return false;
> + if (strcmp("--strict", argv[0]))
> + return false;
> +
> + machine_id = get_machine_id();
> + if (argc < 2) {
> + printf("No argument to --strict, ignoring\n");
> + return false;
> + }
> + list = argv[1];
> + if (list[0] == '!') {
> + ret = true;
> + list++;
> + } else
> + ret = false;
> + while (true) {
> + long input = 0;
> +
> + if (strlen(list) == 0)
> + return ret;
> + input = strtol(list, &list, 16);
> + if (*list == ',')
> + list++;
> + else if (*list != '\0')
> + break;
> + if (input == machine_id)
> + return !ret;
> + }
> + printf("Invalid --strict argument \"%s\", ignoring\n", list);
> + return ret;
> +}
probably I should write a few parsing functions for command line
arguments, so we don't have to re-invent the wheel every time
> +
> int main(int argc, char **argv)
> {
> if (!sclp_facilities.has_sief2) {
> @@ -76,7 +121,7 @@ int main(int argc, char **argv)
> goto out;
> }
>
> - test_spec_ex_sie();
> + test_spec_ex_sie(parse_strict(argc - 1, argv + 1));
hmmm... maybe it would be more readable and more uniform with the other
tests to parse the command line during initialization of the unit test,
and set a global flag.
> out:
> return report_summary();
> }
>
> base-commit: 257c962f3d1b2d0534af59de4ad18764d734903a
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic