Hello, Cai.

Disclaimer: I may be missing something so please be patient. :)

CAI Qian wrote:
[snipped]

> ltp-cvs-081006a/testcases/kernel/ipc/ipc_stress/run_semaphore_test_01.sh.ORIG
>> 2008-10-01 09:50:25.000000000 -0300
>> +++
>>
> ltp-cvs-081006a/testcases/kernel/ipc/ipc_stress/run_semaphore_test_01.sh
>> 2008-10-07 11:23:41.000000000 -0300
>> @@ -99,7 +99,7 @@
>>  fi
>>  
>>  # Get the semphore ID by "ipcs -s"
>> -SEMS=`ipcs -s | awk '{printf " %d", $2}' | sed -e 's/ 0//g'`
>> +SEMS=`LANG= ipcs -s | awk '{print $2}' | grep [[:digit:]]`
>>  for SEM_IPCS in $SEMS
>>  do
>>      if [ $SEM_IPCS -eq $SEM_ID ] ;then
> 
> No, this will break the original behaviour. In my system,
> 
> $ ipcs -s | awk '{printf " %d", $2}' | sed -e 's/ 0//g'
> <empty>

That is exactly the point of the patch. I think the behavior above is 
plain wrong as the script intention is to identify the semaphores ids in 
every line. The first time test_semaphore_01 runs the id is 0, awk's 
output is the string " 0 0 0 0 0" and sed just returns an empty string 
due as the match to occur with the first 0 which is wrong (it 
corresponds to the blank line of ipcs output.) The subsequent runs in 
which the id is nonzero produce the right behavior as the only non zero 
is the id.

> 
> $ LANG= ipcs -s | awk '{print $2}' | grep [[:digit:]]
> 0
> 

I think this is the intended behavior as the id is 0. awk explicitly 
returns the second column of every line (not formatted so the nonnumeric 
ones are and grep filters out the non numeric ones. There must be a 
better way to to it though.


$ LANG= ipcs -s

------ Semaphore Arrays --------
key        semid      owner      perms      nsems
0x00000000 0          elder     660        1
0x00000000 32769      elder     660        1
0x00000000 65538      elder     660        1
0x00000000 98307      elder     660        1
0x00000000 131076     elder     660        1

$ ipcs -s | awk '{printf " %d", $2}'
  0 0 0 0 32769 65538 98307 131076 0

$ ipcs -s | awk '{printf " %d", $2}' | sed -e 's/ 0//g'
  32769 65538 98307 131076

^^^^^^^^^^
id 0 is missed!!!!!



$ LANG= ipcs -s | awk '{print $2}'

Semaphore
semid
0
32769
65538
98307
131076


$ LANG= ipcs -s | awk '{print $2}' | grep [[:digit:]]
0
32769
65538
98307
131076


As I said before I may be missing something but the change does not seem 
to break the testcase and the first run does not fail anymore.

Elder.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to