[kvm-unit-tests,1/3] s390x: Beautify sthyi report strings
diff mbox series

Message ID 20190219084913.198737-2-frankja@linux.ibm.com
State New
Headers show
Series
  • s390x: Report string cleanup
Related show

Commit Message

Janosch Frank Feb. 19, 2019, 8:49 a.m. UTC
Tests like the register odd check in r1 and r2 were not
destinguishable and the reports were hard to read in total.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/sthyi.c | 45 +++++++++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 16 deletions(-)

Comments

David Hildenbrand Feb. 19, 2019, 2:16 p.m. UTC | #1
On 19.02.19 09:49, Janosch Frank wrote:
> Tests like the register odd check in r1 and r2 were not
> destinguishable and the reports were hard to read in total.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  s390x/sthyi.c | 45 +++++++++++++++++++++++++++++----------------
>  1 file changed, 29 insertions(+), 16 deletions(-)
> 
> diff --git a/s390x/sthyi.c b/s390x/sthyi.c
> index 16b8c14..aaf13af 100644
> --- a/s390x/sthyi.c
> +++ b/s390x/sthyi.c
> @@ -52,10 +52,12 @@ static void test_exception_addr(void)
>  
>  static void test_exception_reg_odd(void)
>  {
> -	report_prefix_push("Register check odd");
> +	report_prefix_push("Register check odd R1");
>  	expect_pgm_int();
>  	sthyi((uint64_t)pagebuf, 0, NULL, 1, 2);
>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
> +	report_prefix_pop();
> +	report_prefix_push("Register check odd R2");

I was wondering if we should convert/add "check_pgm_int_code" to pass
accept a string message. That would help as long as no other, unexpect
message is triggered (e.g. EXTERNAL instead of PGM). Something that is
unlikely.

This would be similar to simple "report(condition ..., "message").

Like "report_pgm_int_code(PGM_INT_CODE_SPECIFICATION, "R1 odd").

Not sure if that would be better in some cases.

>  	expect_pgm_int();
>  	sthyi((uint64_t)pagebuf, 0, NULL, 0, 3);
>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
> @@ -76,52 +78,59 @@ static void test_function_code(uint64_t addr)
>  	uint64_t urc = 0;
>  	int cc = sthyi((uint64_t)pagebuf, 42, &urc, 0, 2);
>  
> -	report("Ill. fcode", cc == 3 && urc == CODE_UNSUPP);
> +	report("Illegal fcode", cc == 3 && urc == CODE_UNSUPP);
>  }
>  
>  static void test_fcode0_hdr(struct sthyi_hdr_sctn *hdr)
>  {
> -	report("HDR length", (hdr->INFHDLN >= sizeof(*hdr)
> +	report_prefix_push("Header");
> +
> +	report("length", (hdr->INFHDLN >= sizeof(*hdr)
>  			      && !(hdr->INFHDLN % 8)));
> -	report("MACH sctn length", (hdr->INFMLEN >= sizeof(struct sthyi_mach_sctn)
> +	report("Machine sctn length", (hdr->INFMLEN >= sizeof(struct sthyi_mach_sctn)
>  				    && !(hdr->INFMLEN % 8)));
> -	report("PAR sctn length", (hdr->INFPLEN >= sizeof(struct sthyi_par_sctn)
> +	report("Partition section length", (hdr->INFPLEN >= sizeof(struct sthyi_par_sctn)
>  				   && !(hdr->INFPLEN % 8)));
>  
> -	report("MACH offset", hdr->INFMOFF >= hdr->INFHDLN);
> -	report("PAR offset", hdr->INFPOFF >= hdr->INFHDLN);
> +	report("Machine offset", hdr->INFMOFF >= hdr->INFHDLN);
> +	report("Partition offset", hdr->INFPOFF >= hdr->INFHDLN);
> +	report_prefix_pop();
>  }
>  
>  static void test_fcode0_mach(struct sthyi_mach_sctn *mach)
>  {
>  	int sum = mach->INFMSCPS + mach->INFMDCPS + mach->INFMSIFL + mach->INFMDIFL;
>  
> +	report_prefix_push("Machine");
>  	if (mach->INFMVAL1 & MACH_ID_VLD) {
> -		report("MACH type", memcmp(mach->INFMTYPE, null_buf, sizeof(mach->INFMTYPE)));
> -		report("MACH manu", memcmp(mach->INFMMANU, null_buf, sizeof(mach->INFMMANU)));
> -		report("MACH seq", memcmp(mach->INFMSEQ, null_buf, sizeof(mach->INFMSEQ)));
> -		report("MACH plant", memcmp(mach->INFMPMAN, null_buf, sizeof(mach->INFMPMAN)));
> +		report("type", memcmp(mach->INFMTYPE, null_buf, sizeof(mach->INFMTYPE)));
> +		report("manufacturer", memcmp(mach->INFMMANU, null_buf, sizeof(mach->INFMMANU)));
> +		report("sequence", memcmp(mach->INFMSEQ, null_buf, sizeof(mach->INFMSEQ)));
> +		report("plant", memcmp(mach->INFMPMAN, null_buf, sizeof(mach->INFMPMAN)));
>  	}
>  
>  	if (mach->INFMVAL1 & MACH_NAME_VLD)
> -		report("MACH name", memcmp(mach->INFMNAME, null_buf,
> +		report("name", memcmp(mach->INFMNAME, null_buf,
>  					   sizeof(mach->INFMNAME)));
>  
>  	if (mach->INFMVAL1 & MACH_CNT_VLD)
> -		report("MACH core counts", sum);
> +		report("core counts", sum);
> +	report_prefix_pop();
>  }
>  
>  static void test_fcode0_par(struct sthyi_par_sctn *par)
>  {
>  	int sum = par->INFPSCPS + par->INFPDCPS + par->INFPSIFL + par->INFPDIFL;
>  
> +	report_prefix_push("Partition");
>  	if (par->INFPVAL1 & PART_CNT_VLD)
> -		report("PAR core counts", sum);
> +		report("core counts", sum);
>  
>  	if (par->INFPVAL1 & PART_STSI_SUC) {
> -		report("PAR number", par->INFPPNUM);
> -		report("PAR name", memcmp(par->INFPPNAM, null_buf, sizeof(par->INFPPNAM)));
> +		report("number", par->INFPPNUM);
> +		report("name", memcmp(par->INFPPNAM, null_buf, sizeof(par->INFPPNAM)));
>  	}
> +	report_prefix_pop();
>  }
>  
>  static void test_fcode0(void)
> @@ -133,6 +142,7 @@ static void test_fcode0(void)
>  	/* Zero destination memory. */
>  	memset(pagebuf, 0, PAGE_SIZE);
>  
> +	report_prefix_push("fcode 0");
>  	sthyi((uint64_t)pagebuf, 0, NULL, 0, 2);
>  	hdr = (void *)pagebuf;
>  	mach = (void *)pagebuf + hdr->INFMOFF;
> @@ -141,6 +151,7 @@ static void test_fcode0(void)
>  	test_fcode0_hdr(hdr);
>  	test_fcode0_mach(mach);
>  	test_fcode0_par(par);
> +	report_prefix_pop();
>  }
>  
>  int main(void)
> @@ -156,10 +167,12 @@ int main(void)
>  	}
>  
>  	/* Test register/argument checking. */
> +	report_prefix_push("Instruction");
>  	test_exception_addr();
>  	test_exception_reg_odd();
>  	test_exception_reg_equal();
>  	test_function_code((uint64_t) pagebuf);
> +	report_prefix_pop();
>  
>  	/* Test function code 0 - CP and IFL Capacity Information */
>  	test_fcode0();
>
Janosch Frank Feb. 19, 2019, 2:44 p.m. UTC | #2
On 19.02.19 15:16, David Hildenbrand wrote:
> On 19.02.19 09:49, Janosch Frank wrote:
>> Tests like the register odd check in r1 and r2 were not
>> destinguishable and the reports were hard to read in total.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  s390x/sthyi.c | 45 +++++++++++++++++++++++++++++----------------
>>  1 file changed, 29 insertions(+), 16 deletions(-)
>>
>> diff --git a/s390x/sthyi.c b/s390x/sthyi.c
>> index 16b8c14..aaf13af 100644
>> --- a/s390x/sthyi.c
>> +++ b/s390x/sthyi.c
>> @@ -52,10 +52,12 @@ static void test_exception_addr(void)
>>  
>>  static void test_exception_reg_odd(void)
>>  {
>> -	report_prefix_push("Register check odd");
>> +	report_prefix_push("Register check odd R1");
>>  	expect_pgm_int();
>>  	sthyi((uint64_t)pagebuf, 0, NULL, 1, 2);
>>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
>> +	report_prefix_pop();
>> +	report_prefix_push("Register check odd R2");
> 
> I was wondering if we should convert/add "check_pgm_int_code" to pass
> accept a string message. That would help as long as no other, unexpect
> message is triggered (e.g. EXTERNAL instead of PGM). Something that is
> unlikely.
> 
> This would be similar to simple "report(condition ..., "message").
> 
> Like "report_pgm_int_code(PGM_INT_CODE_SPECIFICATION, "R1 odd").
> 
> Not sure if that would be better in some cases.

Yes, that might be a help.

> 
>>  	expect_pgm_int();
>>  	sthyi((uint64_t)pagebuf, 0, NULL, 0, 3);
>>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
>> @@ -76,52 +78,59 @@ static void test_function_code(uint64_t addr)
>>  	uint64_t urc = 0;
>>  	int cc = sthyi((uint64_t)pagebuf, 42, &urc, 0, 2);
>>  
>> -	report("Ill. fcode", cc == 3 && urc == CODE_UNSUPP);
>> +	report("Illegal fcode", cc == 3 && urc == CODE_UNSUPP);
>>  }
>>  
>>  static void test_fcode0_hdr(struct sthyi_hdr_sctn *hdr)
>>  {
>> -	report("HDR length", (hdr->INFHDLN >= sizeof(*hdr)
>> +	report_prefix_push("Header");
>> +
>> +	report("length", (hdr->INFHDLN >= sizeof(*hdr)
>>  			      && !(hdr->INFHDLN % 8)));
>> -	report("MACH sctn length", (hdr->INFMLEN >= sizeof(struct sthyi_mach_sctn)
>> +	report("Machine sctn length", (hdr->INFMLEN >= sizeof(struct sthyi_mach_sctn)
>>  				    && !(hdr->INFMLEN % 8)));
>> -	report("PAR sctn length", (hdr->INFPLEN >= sizeof(struct sthyi_par_sctn)
>> +	report("Partition section length", (hdr->INFPLEN >= sizeof(struct sthyi_par_sctn)
>>  				   && !(hdr->INFPLEN % 8)));
>>  
>> -	report("MACH offset", hdr->INFMOFF >= hdr->INFHDLN);
>> -	report("PAR offset", hdr->INFPOFF >= hdr->INFHDLN);
>> +	report("Machine offset", hdr->INFMOFF >= hdr->INFHDLN);
>> +	report("Partition offset", hdr->INFPOFF >= hdr->INFHDLN);
>> +	report_prefix_pop();
>>  }
>>  
>>  static void test_fcode0_mach(struct sthyi_mach_sctn *mach)
>>  {
>>  	int sum = mach->INFMSCPS + mach->INFMDCPS + mach->INFMSIFL + mach->INFMDIFL;
>>  
>> +	report_prefix_push("Machine");
>>  	if (mach->INFMVAL1 & MACH_ID_VLD) {
>> -		report("MACH type", memcmp(mach->INFMTYPE, null_buf, sizeof(mach->INFMTYPE)));
>> -		report("MACH manu", memcmp(mach->INFMMANU, null_buf, sizeof(mach->INFMMANU)));
>> -		report("MACH seq", memcmp(mach->INFMSEQ, null_buf, sizeof(mach->INFMSEQ)));
>> -		report("MACH plant", memcmp(mach->INFMPMAN, null_buf, sizeof(mach->INFMPMAN)));
>> +		report("type", memcmp(mach->INFMTYPE, null_buf, sizeof(mach->INFMTYPE)));
>> +		report("manufacturer", memcmp(mach->INFMMANU, null_buf, sizeof(mach->INFMMANU)));
>> +		report("sequence", memcmp(mach->INFMSEQ, null_buf, sizeof(mach->INFMSEQ)));
>> +		report("plant", memcmp(mach->INFMPMAN, null_buf, sizeof(mach->INFMPMAN)));
>>  	}
>>  
>>  	if (mach->INFMVAL1 & MACH_NAME_VLD)
>> -		report("MACH name", memcmp(mach->INFMNAME, null_buf,
>> +		report("name", memcmp(mach->INFMNAME, null_buf,
>>  					   sizeof(mach->INFMNAME)));
>>  
>>  	if (mach->INFMVAL1 & MACH_CNT_VLD)
>> -		report("MACH core counts", sum);
>> +		report("core counts", sum);
>> +	report_prefix_pop();
>>  }
>>  
>>  static void test_fcode0_par(struct sthyi_par_sctn *par)
>>  {
>>  	int sum = par->INFPSCPS + par->INFPDCPS + par->INFPSIFL + par->INFPDIFL;
>>  
>> +	report_prefix_push("Partition");
>>  	if (par->INFPVAL1 & PART_CNT_VLD)
>> -		report("PAR core counts", sum);
>> +		report("core counts", sum);
>>  
>>  	if (par->INFPVAL1 & PART_STSI_SUC) {
>> -		report("PAR number", par->INFPPNUM);
>> -		report("PAR name", memcmp(par->INFPPNAM, null_buf, sizeof(par->INFPPNAM)));
>> +		report("number", par->INFPPNUM);
>> +		report("name", memcmp(par->INFPPNAM, null_buf, sizeof(par->INFPPNAM)));
>>  	}
>> +	report_prefix_pop();
>>  }
>>  
>>  static void test_fcode0(void)
>> @@ -133,6 +142,7 @@ static void test_fcode0(void)
>>  	/* Zero destination memory. */
>>  	memset(pagebuf, 0, PAGE_SIZE);
>>  
>> +	report_prefix_push("fcode 0");
>>  	sthyi((uint64_t)pagebuf, 0, NULL, 0, 2);
>>  	hdr = (void *)pagebuf;
>>  	mach = (void *)pagebuf + hdr->INFMOFF;
>> @@ -141,6 +151,7 @@ static void test_fcode0(void)
>>  	test_fcode0_hdr(hdr);
>>  	test_fcode0_mach(mach);
>>  	test_fcode0_par(par);
>> +	report_prefix_pop();
>>  }
>>  
>>  int main(void)
>> @@ -156,10 +167,12 @@ int main(void)
>>  	}
>>  
>>  	/* Test register/argument checking. */
>> +	report_prefix_push("Instruction");
>>  	test_exception_addr();
>>  	test_exception_reg_odd();
>>  	test_exception_reg_equal();
>>  	test_function_code((uint64_t) pagebuf);
>> +	report_prefix_pop();
>>  
>>  	/* Test function code 0 - CP and IFL Capacity Information */
>>  	test_fcode0();
>>
> 
>
Thomas Huth Feb. 25, 2019, 12:54 p.m. UTC | #3
On 19/02/2019 09.49, Janosch Frank wrote:
> Tests like the register odd check in r1 and r2 were not
> destinguishable and the reports were hard to read in total.

distinguishable

> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  s390x/sthyi.c | 45 +++++++++++++++++++++++++++++----------------
>  1 file changed, 29 insertions(+), 16 deletions(-)
> 
> diff --git a/s390x/sthyi.c b/s390x/sthyi.c
> index 16b8c14..aaf13af 100644
> --- a/s390x/sthyi.c
> +++ b/s390x/sthyi.c
> @@ -52,10 +52,12 @@ static void test_exception_addr(void)
>  
>  static void test_exception_reg_odd(void)
>  {
> -	report_prefix_push("Register check odd");
> +	report_prefix_push("Register check odd R1");
>  	expect_pgm_int();
>  	sthyi((uint64_t)pagebuf, 0, NULL, 1, 2);
>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
> +	report_prefix_pop();
> +	report_prefix_push("Register check odd R2");
>  	expect_pgm_int();
>  	sthyi((uint64_t)pagebuf, 0, NULL, 0, 3);
>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
> @@ -76,52 +78,59 @@ static void test_function_code(uint64_t addr)
>  	uint64_t urc = 0;
>  	int cc = sthyi((uint64_t)pagebuf, 42, &urc, 0, 2);
>  
> -	report("Ill. fcode", cc == 3 && urc == CODE_UNSUPP);
> +	report("Illegal fcode", cc == 3 && urc == CODE_UNSUPP);
>  }
>  
>  static void test_fcode0_hdr(struct sthyi_hdr_sctn *hdr)
>  {
> -	report("HDR length", (hdr->INFHDLN >= sizeof(*hdr)
> +	report_prefix_push("Header");
> +
> +	report("length", (hdr->INFHDLN >= sizeof(*hdr)
>  			      && !(hdr->INFHDLN % 8)));

That fits into one line now (especially if you also remove the redundant
parentheses around the conditional expression).

> -	report("MACH sctn length", (hdr->INFMLEN >= sizeof(struct sthyi_mach_sctn)
> +	report("Machine sctn length", (hdr->INFMLEN >= sizeof(struct sthyi_mach_sctn)
>  				    && !(hdr->INFMLEN % 8)));

I'd like to suggest to align the "&& !(hdr->INFMLEN % 8)));" according
to the previous line again.

> -	report("PAR sctn length", (hdr->INFPLEN >= sizeof(struct sthyi_par_sctn)
> +	report("Partition section length", (hdr->INFPLEN >= sizeof(struct sthyi_par_sctn)
>  				   && !(hdr->INFPLEN % 8)));

dito

> -	report("MACH offset", hdr->INFMOFF >= hdr->INFHDLN);
> -	report("PAR offset", hdr->INFPOFF >= hdr->INFHDLN);
> +	report("Machine offset", hdr->INFMOFF >= hdr->INFHDLN);
> +	report("Partition offset", hdr->INFPOFF >= hdr->INFHDLN);
> +	report_prefix_pop();
>  }
>  
>  static void test_fcode0_mach(struct sthyi_mach_sctn *mach)
>  {
>  	int sum = mach->INFMSCPS + mach->INFMDCPS + mach->INFMSIFL + mach->INFMDIFL;
>  
> +	report_prefix_push("Machine");
>  	if (mach->INFMVAL1 & MACH_ID_VLD) {
> -		report("MACH type", memcmp(mach->INFMTYPE, null_buf, sizeof(mach->INFMTYPE)));
> -		report("MACH manu", memcmp(mach->INFMMANU, null_buf, sizeof(mach->INFMMANU)));
> -		report("MACH seq", memcmp(mach->INFMSEQ, null_buf, sizeof(mach->INFMSEQ)));
> -		report("MACH plant", memcmp(mach->INFMPMAN, null_buf, sizeof(mach->INFMPMAN)));
> +		report("type", memcmp(mach->INFMTYPE, null_buf, sizeof(mach->INFMTYPE)));
> +		report("manufacturer", memcmp(mach->INFMMANU, null_buf, sizeof(mach->INFMMANU)));
> +		report("sequence", memcmp(mach->INFMSEQ, null_buf, sizeof(mach->INFMSEQ)));
> +		report("plant", memcmp(mach->INFMPMAN, null_buf, sizeof(mach->INFMPMAN)));
>  	}
>  
>  	if (mach->INFMVAL1 & MACH_NAME_VLD)
> -		report("MACH name", memcmp(mach->INFMNAME, null_buf,
> +		report("name", memcmp(mach->INFMNAME, null_buf,
>  					   sizeof(mach->INFMNAME)));

dito

>  	if (mach->INFMVAL1 & MACH_CNT_VLD)
> -		report("MACH core counts", sum);
> +		report("core counts", sum);
> +	report_prefix_pop();
>  }

 Thomas
Janosch Frank Feb. 25, 2019, 2:22 p.m. UTC | #4
On 25.02.19 13:54, Thomas Huth wrote:
> On 19/02/2019 09.49, Janosch Frank wrote:
>> Tests like the register odd check in r1 and r2 were not
>> destinguishable and the reports were hard to read in total.
> 
> distinguishable
> 
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  s390x/sthyi.c | 45 +++++++++++++++++++++++++++++----------------
>>  1 file changed, 29 insertions(+), 16 deletions(-)
>>
>> diff --git a/s390x/sthyi.c b/s390x/sthyi.c
>> index 16b8c14..aaf13af 100644
>> --- a/s390x/sthyi.c
>> +++ b/s390x/sthyi.c
>> @@ -52,10 +52,12 @@ static void test_exception_addr(void)
>>  
>>  static void test_exception_reg_odd(void)
>>  {
>> -	report_prefix_push("Register check odd");
>> +	report_prefix_push("Register check odd R1");
>>  	expect_pgm_int();
>>  	sthyi((uint64_t)pagebuf, 0, NULL, 1, 2);
>>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
>> +	report_prefix_pop();
>> +	report_prefix_push("Register check odd R2");
>>  	expect_pgm_int();
>>  	sthyi((uint64_t)pagebuf, 0, NULL, 0, 3);
>>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
>> @@ -76,52 +78,59 @@ static void test_function_code(uint64_t addr)
>>  	uint64_t urc = 0;
>>  	int cc = sthyi((uint64_t)pagebuf, 42, &urc, 0, 2);
>>  
>> -	report("Ill. fcode", cc == 3 && urc == CODE_UNSUPP);
>> +	report("Illegal fcode", cc == 3 && urc == CODE_UNSUPP);
>>  }
>>  
>>  static void test_fcode0_hdr(struct sthyi_hdr_sctn *hdr)
>>  {
>> -	report("HDR length", (hdr->INFHDLN >= sizeof(*hdr)
>> +	report_prefix_push("Header");
>> +
>> +	report("length", (hdr->INFHDLN >= sizeof(*hdr)
>>  			      && !(hdr->INFHDLN % 8)));
> 
> That fits into one line now (especially if you also remove the redundant
> parentheses around the conditional expression).

You and your hate for parentheses... :-)
Fixed all of the problems.
David Hildenbrand Feb. 25, 2019, 2:27 p.m. UTC | #5
On 25.02.19 15:22, Janosch Frank wrote:
> On 25.02.19 13:54, Thomas Huth wrote:
>> On 19/02/2019 09.49, Janosch Frank wrote:
>>> Tests like the register odd check in r1 and r2 were not
>>> destinguishable and the reports were hard to read in total.
>>
>> distinguishable
>>
>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>> ---
>>>  s390x/sthyi.c | 45 +++++++++++++++++++++++++++++----------------
>>>  1 file changed, 29 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/s390x/sthyi.c b/s390x/sthyi.c
>>> index 16b8c14..aaf13af 100644
>>> --- a/s390x/sthyi.c
>>> +++ b/s390x/sthyi.c
>>> @@ -52,10 +52,12 @@ static void test_exception_addr(void)
>>>  
>>>  static void test_exception_reg_odd(void)
>>>  {
>>> -	report_prefix_push("Register check odd");
>>> +	report_prefix_push("Register check odd R1");
>>>  	expect_pgm_int();
>>>  	sthyi((uint64_t)pagebuf, 0, NULL, 1, 2);
>>>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
>>> +	report_prefix_pop();
>>> +	report_prefix_push("Register check odd R2");
>>>  	expect_pgm_int();
>>>  	sthyi((uint64_t)pagebuf, 0, NULL, 0, 3);
>>>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
>>> @@ -76,52 +78,59 @@ static void test_function_code(uint64_t addr)
>>>  	uint64_t urc = 0;
>>>  	int cc = sthyi((uint64_t)pagebuf, 42, &urc, 0, 2);
>>>  
>>> -	report("Ill. fcode", cc == 3 && urc == CODE_UNSUPP);
>>> +	report("Illegal fcode", cc == 3 && urc == CODE_UNSUPP);
>>>  }
>>>  
>>>  static void test_fcode0_hdr(struct sthyi_hdr_sctn *hdr)
>>>  {
>>> -	report("HDR length", (hdr->INFHDLN >= sizeof(*hdr)
>>> +	report_prefix_push("Header");
>>> +
>>> +	report("length", (hdr->INFHDLN >= sizeof(*hdr)
>>>  			      && !(hdr->INFHDLN % 8)));
>>
>> That fits into one line now (especially if you also remove the redundant
>> parentheses around the conditional expression).
> 
> You and your hate for parentheses... :-)
> Fixed all of the problems.
> 

Maybe he's traumatized by LISP ... just like me ;)
Thomas Huth Feb. 25, 2019, 2:33 p.m. UTC | #6
On 25/02/2019 15.27, David Hildenbrand wrote:
> On 25.02.19 15:22, Janosch Frank wrote:
>> On 25.02.19 13:54, Thomas Huth wrote:
>>> On 19/02/2019 09.49, Janosch Frank wrote:
>>>> Tests like the register odd check in r1 and r2 were not
>>>> destinguishable and the reports were hard to read in total.
>>>
>>> distinguishable
>>>
>>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>>> ---
>>>>  s390x/sthyi.c | 45 +++++++++++++++++++++++++++++----------------
>>>>  1 file changed, 29 insertions(+), 16 deletions(-)
>>>>
>>>> diff --git a/s390x/sthyi.c b/s390x/sthyi.c
>>>> index 16b8c14..aaf13af 100644
>>>> --- a/s390x/sthyi.c
>>>> +++ b/s390x/sthyi.c
>>>> @@ -52,10 +52,12 @@ static void test_exception_addr(void)
>>>>  
>>>>  static void test_exception_reg_odd(void)
>>>>  {
>>>> -	report_prefix_push("Register check odd");
>>>> +	report_prefix_push("Register check odd R1");
>>>>  	expect_pgm_int();
>>>>  	sthyi((uint64_t)pagebuf, 0, NULL, 1, 2);
>>>>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
>>>> +	report_prefix_pop();
>>>> +	report_prefix_push("Register check odd R2");
>>>>  	expect_pgm_int();
>>>>  	sthyi((uint64_t)pagebuf, 0, NULL, 0, 3);
>>>>  	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
>>>> @@ -76,52 +78,59 @@ static void test_function_code(uint64_t addr)
>>>>  	uint64_t urc = 0;
>>>>  	int cc = sthyi((uint64_t)pagebuf, 42, &urc, 0, 2);
>>>>  
>>>> -	report("Ill. fcode", cc == 3 && urc == CODE_UNSUPP);
>>>> +	report("Illegal fcode", cc == 3 && urc == CODE_UNSUPP);
>>>>  }
>>>>  
>>>>  static void test_fcode0_hdr(struct sthyi_hdr_sctn *hdr)
>>>>  {
>>>> -	report("HDR length", (hdr->INFHDLN >= sizeof(*hdr)
>>>> +	report_prefix_push("Header");
>>>> +
>>>> +	report("length", (hdr->INFHDLN >= sizeof(*hdr)
>>>>  			      && !(hdr->INFHDLN % 8)));
>>>
>>> That fits into one line now (especially if you also remove the redundant
>>> parentheses around the conditional expression).
>>
>> You and your hate for parentheses... :-)
>> Fixed all of the problems.
>>
> 
> Maybe he's traumatized by LISP ... just like me ;)

Yes, I took a LISP course at the university once ... I never overcame
that trauma... ;-)

 Thomas

Patch
diff mbox series

diff --git a/s390x/sthyi.c b/s390x/sthyi.c
index 16b8c14..aaf13af 100644
--- a/s390x/sthyi.c
+++ b/s390x/sthyi.c
@@ -52,10 +52,12 @@  static void test_exception_addr(void)
 
 static void test_exception_reg_odd(void)
 {
-	report_prefix_push("Register check odd");
+	report_prefix_push("Register check odd R1");
 	expect_pgm_int();
 	sthyi((uint64_t)pagebuf, 0, NULL, 1, 2);
 	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
+	report_prefix_pop();
+	report_prefix_push("Register check odd R2");
 	expect_pgm_int();
 	sthyi((uint64_t)pagebuf, 0, NULL, 0, 3);
 	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
@@ -76,52 +78,59 @@  static void test_function_code(uint64_t addr)
 	uint64_t urc = 0;
 	int cc = sthyi((uint64_t)pagebuf, 42, &urc, 0, 2);
 
-	report("Ill. fcode", cc == 3 && urc == CODE_UNSUPP);
+	report("Illegal fcode", cc == 3 && urc == CODE_UNSUPP);
 }
 
 static void test_fcode0_hdr(struct sthyi_hdr_sctn *hdr)
 {
-	report("HDR length", (hdr->INFHDLN >= sizeof(*hdr)
+	report_prefix_push("Header");
+
+	report("length", (hdr->INFHDLN >= sizeof(*hdr)
 			      && !(hdr->INFHDLN % 8)));
-	report("MACH sctn length", (hdr->INFMLEN >= sizeof(struct sthyi_mach_sctn)
+	report("Machine sctn length", (hdr->INFMLEN >= sizeof(struct sthyi_mach_sctn)
 				    && !(hdr->INFMLEN % 8)));
-	report("PAR sctn length", (hdr->INFPLEN >= sizeof(struct sthyi_par_sctn)
+	report("Partition section length", (hdr->INFPLEN >= sizeof(struct sthyi_par_sctn)
 				   && !(hdr->INFPLEN % 8)));
 
-	report("MACH offset", hdr->INFMOFF >= hdr->INFHDLN);
-	report("PAR offset", hdr->INFPOFF >= hdr->INFHDLN);
+	report("Machine offset", hdr->INFMOFF >= hdr->INFHDLN);
+	report("Partition offset", hdr->INFPOFF >= hdr->INFHDLN);
+	report_prefix_pop();
 }
 
 static void test_fcode0_mach(struct sthyi_mach_sctn *mach)
 {
 	int sum = mach->INFMSCPS + mach->INFMDCPS + mach->INFMSIFL + mach->INFMDIFL;
 
+	report_prefix_push("Machine");
 	if (mach->INFMVAL1 & MACH_ID_VLD) {
-		report("MACH type", memcmp(mach->INFMTYPE, null_buf, sizeof(mach->INFMTYPE)));
-		report("MACH manu", memcmp(mach->INFMMANU, null_buf, sizeof(mach->INFMMANU)));
-		report("MACH seq", memcmp(mach->INFMSEQ, null_buf, sizeof(mach->INFMSEQ)));
-		report("MACH plant", memcmp(mach->INFMPMAN, null_buf, sizeof(mach->INFMPMAN)));
+		report("type", memcmp(mach->INFMTYPE, null_buf, sizeof(mach->INFMTYPE)));
+		report("manufacturer", memcmp(mach->INFMMANU, null_buf, sizeof(mach->INFMMANU)));
+		report("sequence", memcmp(mach->INFMSEQ, null_buf, sizeof(mach->INFMSEQ)));
+		report("plant", memcmp(mach->INFMPMAN, null_buf, sizeof(mach->INFMPMAN)));
 	}
 
 	if (mach->INFMVAL1 & MACH_NAME_VLD)
-		report("MACH name", memcmp(mach->INFMNAME, null_buf,
+		report("name", memcmp(mach->INFMNAME, null_buf,
 					   sizeof(mach->INFMNAME)));
 
 	if (mach->INFMVAL1 & MACH_CNT_VLD)
-		report("MACH core counts", sum);
+		report("core counts", sum);
+	report_prefix_pop();
 }
 
 static void test_fcode0_par(struct sthyi_par_sctn *par)
 {
 	int sum = par->INFPSCPS + par->INFPDCPS + par->INFPSIFL + par->INFPDIFL;
 
+	report_prefix_push("Partition");
 	if (par->INFPVAL1 & PART_CNT_VLD)
-		report("PAR core counts", sum);
+		report("core counts", sum);
 
 	if (par->INFPVAL1 & PART_STSI_SUC) {
-		report("PAR number", par->INFPPNUM);
-		report("PAR name", memcmp(par->INFPPNAM, null_buf, sizeof(par->INFPPNAM)));
+		report("number", par->INFPPNUM);
+		report("name", memcmp(par->INFPPNAM, null_buf, sizeof(par->INFPPNAM)));
 	}
+	report_prefix_pop();
 }
 
 static void test_fcode0(void)
@@ -133,6 +142,7 @@  static void test_fcode0(void)
 	/* Zero destination memory. */
 	memset(pagebuf, 0, PAGE_SIZE);
 
+	report_prefix_push("fcode 0");
 	sthyi((uint64_t)pagebuf, 0, NULL, 0, 2);
 	hdr = (void *)pagebuf;
 	mach = (void *)pagebuf + hdr->INFMOFF;
@@ -141,6 +151,7 @@  static void test_fcode0(void)
 	test_fcode0_hdr(hdr);
 	test_fcode0_mach(mach);
 	test_fcode0_par(par);
+	report_prefix_pop();
 }
 
 int main(void)
@@ -156,10 +167,12 @@  int main(void)
 	}
 
 	/* Test register/argument checking. */
+	report_prefix_push("Instruction");
 	test_exception_addr();
 	test_exception_reg_odd();
 	test_exception_reg_equal();
 	test_function_code((uint64_t) pagebuf);
+	report_prefix_pop();
 
 	/* Test function code 0 - CP and IFL Capacity Information */
 	test_fcode0();