lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3c627856-5e66-3cbe-adab-464ae573e23d@linux.ibm.com>
Date:   Thu, 14 Apr 2022 14:48:33 +0200
From:   Janis Schoetterl-Glausch <scgl@...ux.ibm.com>
To:     Thomas Huth <thuth@...hat.com>, kvm@...r.kernel.org,
        Christian Borntraeger <borntraeger@...ux.ibm.com>,
        Janosch Frank <frankja@...ux.ibm.com>,
        Claudio Imbrenda <imbrenda@...ux.ibm.com>
Cc:     linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
        David Hildenbrand <david@...hat.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Shuah Khan <shuah@...nel.org>
Subject: Re: [PATCH 1/4] KVM: s390: selftests: Use TAP interface in the memop
 test

On 4/14/22 12:53, Thomas Huth wrote:
> The memop test currently does not have any output (unless one of the
> TEST_ASSERT statement fails), so it's hard to say for a user whether
> a certain new sub-test has been included in the binary or not. Let's
> make this a little bit more user-friendly and include some TAP output
> via the kselftests.h interface.
> 
> Signed-off-by: Thomas Huth <thuth@...hat.com>
> ---
>  tools/testing/selftests/kvm/s390x/memop.c | 90 ++++++++++++++++++-----
>  1 file changed, 73 insertions(+), 17 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
> index b04c2c1b3c30..a2783d9afcac 100644
> --- a/tools/testing/selftests/kvm/s390x/memop.c
> +++ b/tools/testing/selftests/kvm/s390x/memop.c
> @@ -12,6 +12,7 @@
>  
>  #include "test_util.h"
>  #include "kvm_util.h"
> +#include "kselftest.h"
>  
>  enum mop_target {
>  	LOGICAL,
> @@ -648,33 +649,88 @@ static void test_errors(void)
>  	kvm_vm_free(t.kvm_vm);
>  }
>  
> +struct testdef {
> +	const char *name;
> +	void (*test)(void);
> +	bool needs_extension;

Please make this numeric. You could also rename it to required_extension or similar.

> +} testlist[] = {
> +	{
> +		.name = "simple copy",
> +		.test = test_copy,
> +		.needs_extension = false,
> +	},
> +	{
> +		.name = "copy with storage keys",
> +		.test = test_copy_key,
> +		.needs_extension = true,
> +	},
> +	{
> +		.name = "copy with key storage protection override",
> +		.test = test_copy_key_storage_prot_override,
> +		.needs_extension = true,
> +	},
> +	{
> +		.name = "copy with key fetch protection",
> +		.test = test_copy_key_fetch_prot,
> +		.needs_extension = true,
> +	},
> +	{
> +		.name = "copy with key fetch protection override",
> +		.test = test_copy_key_fetch_prot_override,
> +		.needs_extension = true,
> +	},
> +	{
> +		.name = "error checks with key",
> +		.test = test_errors_key,
> +		.needs_extension = true,
> +	},
> +	{
> +		.name = "error checks with key storage protection override",
> +		.test = test_errors_key_storage_prot_override,
> +		.needs_extension = true,
> +	},
> +	{
> +		.name = "error checks without key fetch prot override",
> +		.test = test_errors_key_fetch_prot_override_not_enabled,
> +		.needs_extension = true,
> +	},
> +	{
> +		.name = "error checks with key fetch prot override",
> +		.test = test_errors_key_fetch_prot_override_enabled,
> +		.needs_extension = true,
> +	},
> +	{
> +		.name = "generic error checks",
> +		.test = test_errors,
> +		.needs_extension = false,
> +	},
> +};
> +
>  int main(int argc, char *argv[])
>  {
> -	int memop_cap, extension_cap;
> +	int memop_cap, extension_cap, idx;
>  
>  	setbuf(stdout, NULL);	/* Tell stdout not to buffer its content */
>  
> +	ksft_print_header();
> +
>  	memop_cap = kvm_check_cap(KVM_CAP_S390_MEM_OP);
>  	extension_cap = kvm_check_cap(KVM_CAP_S390_MEM_OP_EXTENSION);
>  	if (!memop_cap) {
> -		print_skip("CAP_S390_MEM_OP not supported");
> -		exit(KSFT_SKIP);
> +		ksft_exit_skip("CAP_S390_MEM_OP not supported.\n");
>  	}
>  
> -	test_copy();
> -	if (extension_cap > 0) {
> -		test_copy_key();
> -		test_copy_key_storage_prot_override();
> -		test_copy_key_fetch_prot();
> -		test_copy_key_fetch_prot_override();
> -		test_errors_key();
> -		test_errors_key_storage_prot_override();
> -		test_errors_key_fetch_prot_override_not_enabled();
> -		test_errors_key_fetch_prot_override_enabled();
> -	} else {
> -		print_skip("storage key memop extension not supported");
> +	ksft_set_plan(ARRAY_SIZE(testlist));
> +
> +	for (idx = 0; idx < ARRAY_SIZE(testlist); idx++) {
> +		if (!testlist[idx].needs_extension || extension_cap) {

Then check here that extension_cap >= the required extension.
This way the test can easily be adapted in case of future extensions.
> +			testlist[idx].test();
> +			ksft_test_result_pass("%s\n", testlist[idx].name);
> +		} else {
> +			ksft_test_result_skip("%s - storage key memop not supported\n",
> +					      testlist[idx].name);
> +		}
>  	}
> -	test_errors();
>  
> -	return 0;
> +	ksft_finished();
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ