Skip to contentSkip to conversation

Another sanity test tweak

PATCH Richard Purdie 2 participants 3 messages Dec 23, 2010

lore
Share & tools
lore
#0 lore raw

Hi Jiajun,

Along with bugs 611 and 612, I also noticed messages in the qemu logs about the qemu process being present when it very clearly wasn't. These are due to Test_Check_Qemu_UP() not functioning correctly.

Looking at the output of ps -ef when running the script, I see things like:

richard   6582  1845  0 11:32 pts/8    00:00:00 /bin/sh /rphome/poky/scripts/bitbake poky-image-sato -c qemuimagetest_standalone
richard   6588  6582 72 11:32 pts/8    00:00:15 python /rphome/poky/bitbake/bin//bitbake poky-image-sato -c qemuimagetest_standalone
richard   6598  6588  0 11:32 pts/8    00:00:00 python /rphome/poky/bitbake/bin//bitbake poky-image-sato -c qemuimagetest_standalone
richard   6601  6598  0 11:32 pts/8    00:00:00 sh -c /rphome/poky/scripts/qemuimage-tests/sanity/boot | tee -a /media/data1/builds/poky2/tmp/log/qemuimagetests/sanity/log_boot.20101223113226
richard   6602  6601  0 11:32 pts/8    00:00:00 /bin/bash /rphome/poky/scripts/qemuimage-tests/sanity/boot
richard   6603  6601  0 11:32 pts/8    00:00:00 tee -a /media/data1/builds/poky2/tmp/log/qemuimagetests/sanity/log_boot.20101223113226

which is why it thinks qemu is running. I'd like to propose something like:

scripts/qemuimage-testlib +1 -1
index c2c394d..2b18683 100644
@@ -204,7 +204,7 @@ Test_Kill_Qemu()
 # function to check if there is any qemu process
 Test_Check_Qemu_UP()
 {
-       local count=`ps -ef | grep -c qemu`
+       local count=`ps -eo command | cut -d " " -f 1 | grep -c \(^qemu\|.*/qemu\)`
        if [ ${count} -lt 2 ]; then
                Test_Info "There is no Qemu process"
                return 1

which should ensure a qemu command is running rather than any command which happens to have "qemu" in its path. I'm still testing the above to see if it works well.

Also, waiting 120 seconds for the qemu network to be up is fine. For the actual process to be running I'd suggest we just wait 10 seconds maximum as if it ever takes longer than that, we have a problem. I'd propose the following change:

@@ -383,9 +383,7 @@ Test_Create_Qemu()
# Get the pid of the xterm processor, which will be used in Test_Kill_Qemu PID=$!

- sleep 5
-
- while [ ${up_time} -lt ${timeout} ]
+ while [ ${up_time} -lt 10 ]

        do
                Test_Check_Qemu_UP
                if [ $? -ne 0 ]; then

Are you ok with these changes?

Cheers,

Richard

#1 lore raw
Quoted 38 lines

Hi Jiajun,

Along with bugs 611 and 612, I also noticed messages in the qemu logs about the qemu process being present when it very clearly wasn't. These are due to
Test_Check_Qemu_UP() not functioning correctly.

Looking at the output of ps -ef when running the script, I see things like:

richard 6582 1845 0 11:32 pts/8 00:00:00 /bin/sh
/rphome/poky/scripts/bitbake poky-image-sato -c qemuimagetest_standalone
richard 6588 6582 72 11:32 pts/8 00:00:15 python
/rphome/poky/bitbake/bin//bitbake poky-image-sato -c
qemuimagetest_standalone richard 6598 6588 0 11:32 pts/8 00:00:00
python /rphome/poky/bitbake/bin//bitbake poky-image-sato -c
qemuimagetest_standalone richard 6601 6598 0 11:32 pts/8 00:00:00
sh -c /rphome/poky/scripts/qemuimage-tests/sanity/boot | tee -a /media/data1/builds/poky2/tmp/log/qemuimagetests/sanity/log_boot.20101 2
23113226 richard 6602 6601 0 11:32 pts/8 00:00:00 /bin/bash
/rphome/poky/scripts/qemuimage-tests/sanity/boot richard 6603 6601 0
11:32 pts/8 00:00:00 tee -a
/media/data1/builds/poky2/tmp/log/qemuimagetests/sanity/log_boot.20101 2 23113226

which is why it thinks qemu is running. I'd like to propose something like:

scripts/qemuimage-testlib index renamed from scripts/qemuimage-testlib +0 -0

c2c394d..2b18683 100644 --- a/scripts/qemuimage-testlib +++ b/scripts/qemuimage-testlib @@ -204,7 +204,7 @@ Test_Kill_Qemu()

 # function to check if there is any qemu process Test_Check_Qemu_UP() {
scripts/qemuimage-testlib index renamed from scripts/qemuimage-testlib +2 -1
-       local count=`ps -ef | grep -c qemu`
+       local count=`ps -eo command | cut -d " " -f 1 | grep -c
+ \(^qemu\|.*/qemu\)`
        if [ ${count} -lt 2 ]; then
                Test_Info "There is no Qemu process"
                return 1
Quoted 4 lines

which should ensure a qemu command is running rather than any command which happens to have "qemu" in its path. I'm still testing the above to see if it works well.

I tested above code and it works correctly on my machine. One thing needs modification is the count value we check.

scripts/qemuimage-testlib +3 -3
index 608c6f0..684929a 100644
@@ -204,12 +204,12 @@ Test_Kill_Qemu()
 # function to check if there is any qemu process
 Test_Check_Qemu_UP()
 {
-       local count=`ps -ef | grep -c qemu`
-       if [ ${count} -lt 2 ]; then
+       local count=`ps -eo command | cut -d" " -f 1 | grep -c '\(^qemu\|.*/qemu\)'`
+       if [ ${count} -ne 1 ]; then
                Test_Info "There is no Qemu process"
                return 1
        else
-               Test_Info "There is at least Qemu process running"
+               Test_Info "There is at least one Qemu process running"
                return 0
        fi
 }
Quoted 14 lines

Also, waiting 120 seconds for the qemu network to be up is fine. For
the actual process to be running I'd suggest we just wait 10 seconds
maximum as if it ever takes longer than that, we have a problem. I'd propose the following change:

scripts/qemuimage-testlib index renamed from scripts/qemuimage-testlib +1 -3
@@ -383,9 +383,7 @@ Test_Create_Qemu()
        # Get the pid of the xterm processor, which will be used in
        Test_Kill_Qemu PID=$!
-       sleep 5
-
-       while [ ${up_time} -lt ${timeout} ]
+       while [ ${up_time} -lt 10 ]
        do
                Test_Check_Qemu_UP
                if [ $? -ne 0 ]; then
Quoted 2 lines

Are you ok with these changes?

Agree. We don’t' need to wait such a long time for qemu up.

Quoted 4 lines

Cheers,

Richard

Best Regards,
Jiajun

#2 lore raw
Quoted 28 lines · Jiajun

I tested above code and it works correctly on my machine. One thing needs modification is the count value we check.

scripts/qemuimage-testlib +3 -3
index 608c6f0..684929a 100644
@@ -204,12 +204,12 @@ Test_Kill_Qemu()
 # function to check if there is any qemu process
 Test_Check_Qemu_UP()
 {
-       local count=`ps -ef | grep -c qemu`
-       if [ ${count} -lt 2 ]; then
+       local count=`ps -eo command | cut -d" " -f 1 | grep -c '\(^qemu\|.*/qemu\)'`
+       if [ ${count} -ne 1 ]; then
                Test_Info "There is no Qemu process"
                return 1
        else
-               Test_Info "There is at least Qemu process running"
+               Test_Info "There is at least one Qemu process running"
                return 0
        fi
 }
Quoted 5 lines

Also, waiting 120 seconds for the qemu network to be up is fine. For
the actual process to be running I'd suggest we just wait 10 seconds
maximum as if it ever takes longer than that, we have a problem. I'd propose the following change:

Quoted 14 lines
Quoted 10 lines
(quoted diff) +1 -3
@@ -383,9 +383,7 @@ Test_Create_Qemu()
        # Get the pid of the xterm processor, which will be used in
        Test_Kill_Qemu PID=$!
-       sleep 5
-
-       while [ ${up_time} -lt ${timeout} ]
+       while [ ${up_time} -lt 10 ]
        do
                Test_Check_Qemu_UP
                if [ $? -ne 0 ]; then
Quoted 2 lines

Are you ok with these changes?

Agree. We don’t' need to wait such a long time for qemu up.

Thanks, I've merged these along with another fix I noticed which I think was stopping qemu starting on the autobuilder.

Cheers,

Richard