test/eal: check invalid cpu value

Message ID 20200612120959.25626-1-ktraynor@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series test/eal: check invalid cpu value |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success Travis build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Kevin Traynor June 12, 2020, 12:09 p.m. UTC
  When using --lcores option, CPU_SETSIZE allows a range of
0-1023. Check it is not being exceeded.

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
---
 app/test/test_eal_flags.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Lukasz Wojciechowski July 8, 2020, 11:04 p.m. UTC | #1
W dniu 12.06.2020 o 14:09, Kevin Traynor pisze:
> When using --lcores option, CPU_SETSIZE allows a range of
> 0-1023. Check it is not being exceeded.
>
> Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
> ---
>   app/test/test_eal_flags.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c
> index 4ee809e3d..044cc1c59 100644
> --- a/app/test/test_eal_flags.c
> +++ b/app/test/test_eal_flags.c
> @@ -528,4 +528,7 @@ test_missing_c_flag(void)
>   				 "--lcores",
>   				 "0-1,2@(5-7),(3-5)@(0,2),(0,6),7"};
> +	/* check an invalid cpu value >= CPU_SETSIZE */
> +	const char * const argv30[] = { prgname, prefix, mp_flag,
> +				 "--lcores", "3@1024" };
>   
The proper cpu values are in range 0-CPU_SETSIZE, but the CPU_SETSIZE is 
not always equal to 1024 (currently it is on Linux).
Check lib/librte_eal/windows/include/sched.h:17 :

#ifndef CPU_SETSIZE
#define CPU_SETSIZE RTE_MAX_LCORE
#endif

so to make your patch better, you can use CPU_SETSIZE value directly:

const char * const argv30[] = { prgname, prefix, mp_flag, "--lcores", "3@" RTE_STR(CPU_SETSIZE) };


>   	if (launch_proc(argv2) != 0) {
> @@ -577,5 +580,6 @@ test_missing_c_flag(void)
>   	    launch_proc(argv24) == 0 || launch_proc(argv25) == 0 ||
>   	    launch_proc(argv26) == 0 || launch_proc(argv27) == 0 ||
> -	    launch_proc(argv28) == 0) {
> +	    launch_proc(argv28) == 0 || launch_proc(argv30) == 0) {
> +
>   		printf("Error - "
>   		       "process ran without error with invalid --lcore flag\n");

Best regards
  
Kevin Traynor July 20, 2020, 10:20 a.m. UTC | #2
On 09/07/2020 00:04, Lukasz Wojciechowski wrote:
> 
> W dniu 12.06.2020 o 14:09, Kevin Traynor pisze:
>> When using --lcores option, CPU_SETSIZE allows a range of
>> 0-1023. Check it is not being exceeded.
>>
>> Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
>> ---
>>   app/test/test_eal_flags.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c
>> index 4ee809e3d..044cc1c59 100644
>> --- a/app/test/test_eal_flags.c
>> +++ b/app/test/test_eal_flags.c
>> @@ -528,4 +528,7 @@ test_missing_c_flag(void)
>>   				 "--lcores",
>>   				 "0-1,2@(5-7),(3-5)@(0,2),(0,6),7"};
>> +	/* check an invalid cpu value >= CPU_SETSIZE */
>> +	const char * const argv30[] = { prgname, prefix, mp_flag,
>> +				 "--lcores", "3@1024" };
>>   
> The proper cpu values are in range 0-CPU_SETSIZE, but the CPU_SETSIZE is 
> not always equal to 1024 (currently it is on Linux).
> Check lib/librte_eal/windows/include/sched.h:17 :
> 
> #ifndef CPU_SETSIZE
> #define CPU_SETSIZE RTE_MAX_LCORE
> #endif
> 
> so to make your patch better, you can use CPU_SETSIZE value directly:
> 
> const char * const argv30[] = { prgname, prefix, mp_flag, "--lcores", "3@" RTE_STR(CPU_SETSIZE) };
> 

Thanks Lukasz. You are right, this is better. I just sent a v2.

Kevin.

> 
>>   	if (launch_proc(argv2) != 0) {
>> @@ -577,5 +580,6 @@ test_missing_c_flag(void)
>>   	    launch_proc(argv24) == 0 || launch_proc(argv25) == 0 ||
>>   	    launch_proc(argv26) == 0 || launch_proc(argv27) == 0 ||
>> -	    launch_proc(argv28) == 0) {
>> +	    launch_proc(argv28) == 0 || launch_proc(argv30) == 0) {
>> +
>>   		printf("Error - "
>>   		       "process ran without error with invalid --lcore flag\n");
> 
> Best regards
>
  

Patch

diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c
index 4ee809e3d..044cc1c59 100644
--- a/app/test/test_eal_flags.c
+++ b/app/test/test_eal_flags.c
@@ -528,4 +528,7 @@  test_missing_c_flag(void)
 				 "--lcores",
 				 "0-1,2@(5-7),(3-5)@(0,2),(0,6),7"};
+	/* check an invalid cpu value >= CPU_SETSIZE */
+	const char * const argv30[] = { prgname, prefix, mp_flag,
+				 "--lcores", "3@1024" };
 
 	if (launch_proc(argv2) != 0) {
@@ -577,5 +580,6 @@  test_missing_c_flag(void)
 	    launch_proc(argv24) == 0 || launch_proc(argv25) == 0 ||
 	    launch_proc(argv26) == 0 || launch_proc(argv27) == 0 ||
-	    launch_proc(argv28) == 0) {
+	    launch_proc(argv28) == 0 || launch_proc(argv30) == 0) {
+
 		printf("Error - "
 		       "process ran without error with invalid --lcore flag\n");