Headless testing using AIR test runner and Xvfb under Linux

493 views
Skip to first unread message

Brett Adam

unread,
Sep 3, 2008, 12:11:49 AM9/3/08
to Fluint Discussions
We've been using dpUInt recently as part of our testing strategy for
some new Flex apps. So far, so good.

However, one key piece of our build infrastructure has been
*automated* build and test. We happen to use a Linux based environment
with bamboo as our build driver and a gang of distributed, headless
build servers doing the heavy lifting. Needless to say, figuring out
how to get dpUInt tests working in a headless context was key.

After some mucking about, one of our team (Matthew Wilson) came up
with an elegant solution that uses the Xvfb virtual framebuffer as a
head. The AIR test runner thinks it has a head to run when the truth
is, it doesn't.

Here's the wrapper script we use to invoke the test runner with Xvfb
configured. We invoke this from a simple ant build wrapper. Hopefully,
others will find it useful.

---

ant task

(where property app-build.test.Xvnc-wrapper.cmd=${app-build.dir}/Xvfb-
wrapper.sh )

<target name="auto-test" description="Run automated tests">
<antcall target="test-clean"/>
<!-- The output file has to be an absolute path for air, so
create a property using location which resolves it for us -->
<property name="outputFile" location="${app-
build.test.output.dir}/junit.xml"/>
<exec executable="${app-build.test.Xvfb-wrapper.cmd}">
<arg line="${air.sdk.bin.dir}/${air.sdk.runner} ${app-
build.test.dir}/TestRunner-app.xml -- -headless -reportFile $
{outputFile}"/>
</exec>
</target>


---

Xvfb wrapper


#!/bin/sh
#
# Author: Matthew Wilson, rPath, Inc.
#
# This could probably be done more elegantly in Python...

pid=''
for ((d=0; d < 20; d++)); do
DISPLAY=:$d
Xvfb -ac $DISPLAY > /dev/null 2>&1 &
sleep 2
jobs -l %1 > /dev/null
pid=$(jobs -l %1 2>&1 | grep Running | awk '{print $2}')
if [ -z "$pid" ]; then
continue
fi
if ps $pid > /dev/null 2>&1; then
break
fi
done

if [ -z "$pid" ]; then
echo "unable to start Xvfb"
exit 1
fi

trap "kill -9 $pid" SIGINT SIGTERM EXIT

export DISPLAY=$DISPLAY

$*

Michael Labriola

unread,
Sep 3, 2008, 9:44:28 AM9/3/08
to fluint-di...@googlegroups.com
That is excellent.
 
I am going to add this as a page on the dpUInt and Fluint sites.
 
Thanks so much,
Mike
Reply all
Reply to author
Forward
0 new messages