Commit 52e2c64a authored by Emanuele Aina's avatar Emanuele Aina

sdk-performance-tools-sysprof-smoke-test: Fix usage of binary capture

Sysprof moved to a binary capture log, so the current machinery parsing
the old XML-based format no longer works.

Since this is a smoke test, just check that the capture file exist and is
not empty.

This also avoid printing large amount of binary contents to the
LAVA log, which makes the log unviewable from the UI and may cause
other issues.
Signed-off-by: Emanuele Aina's avatarEmanuele Aina <emanuele.aina@collabora.com>
parent b09af1b8
......@@ -23,7 +23,7 @@ apparmor/webkit-clutter/webkit-clutter
/sdk/automated/multipath.c.gcov
/sdk/automated/multipath.gcda
/sdk/automated/multipath.gcno
/sdk/automated/sysprof-out.xml
/sdk/automated/sysprof-out.capture
# Misc compiled files
/clutter-zoom/clutter-zoom-test
/emulated-soft-keys/keyevent_waiter
......
......@@ -15,9 +15,7 @@ DATA := backtrace.c \
fib.c \
leak.c \
linty.c \
multipath.c \
sysprof-usage.xsl \
total-count.xsl
multipath.c
TEST_NAME=sdk/automated
include ../../global-config.mk
......
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exslt="http://exslt.org/common"
extension-element-prefixes="exslt">
<!--
This transformation determines what percentage of the total samples
each task appeared in.
Output: the percentage, number of samples and name of each task
-->
<xsl:output method="text" />
<xsl:variable name="size">
<!-- the total number of samples in this entire run -->
<xsl:for-each select="/profile/size">
<!-- select the given value -->
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:template match="@*|node()">
<xsl:for-each select="/profile/objects/object">
<xsl:if test="starts-with(name, '&quot;[')">
<xsl:value-of select="format-number(total div number($size) * 100, '#.##')"/>
<xsl:text>% </xsl:text>
<xsl:value-of select="total"/>
<xsl:text> </xsl:text>
<xsl:value-of select="name"/>
<xsl:text>&#xa;</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
......@@ -2,15 +2,12 @@
# This runs a CPU-intensive program while running Sysprof. If
# XXX: keep this synchronized with the XSLT file's procName
TEST_DIR=$(dirname $0)
TEST_PROG=${TEST_DIR}/fib.pl
# calculate the Fibonacci sequence to position 40. Runtime increases
# exponentially by this number
TEST_PROG_ARGS="36"
SYSPROF_OUT_FILE="sysprof-out.xml"
XSLT_FILE="${TEST_DIR}/total-count.xsl"
MIN_PORTION="0.95"
SYSPROF_OUT_FILE="sysprof-out.capture"
die() {
echo $1
......@@ -47,34 +44,13 @@ if [ $kill_result -ne 0 ]; then
exit 0
fi
# ensure that sysprof has finished writing its file out before we parse it
# ensure that sysprof has finished writing its file out
wait $SYSPROF_PID
TEST_PROG_PORTION=$(xsltproc --nonet --novalid $XSLT_FILE $SYSPROF_OUT_FILE)
# Convert each to a percentage and drop any fractional part (so we can compare
# with [)
TEST_PCT=$(echo $TEST_PROG_PORTION 100 | awk '{print int($1*$2)}')
MIN_PCT=$(echo $MIN_PORTION 100 | awk '{print int($1*$2)}')
TEST_PCT_LC=$(echo $TEST_PCT | tr '[:upper:]' '[:lower:]')
# handle division by zero in case of catastrophic XSLT failure
if [ "x$TEST_PCT_LC" = "xnan" ]; then
TEST_PCT=0
fi
STATUS_STR="FAILED"
if [ $TEST_PCT -ge $MIN_PCT ]; then
# check that sysprof generated a binary capture file and that it is not empty
if [ $(stat --format=%s $SYSPROF_OUT_FILE) -gt 0 ]; then
STATUS_STR="PASSED"
fi
echo "sdk-performance-tools-sysprof-smoke-test: $STATUS_STR"
echo "Program ran in $TEST_PCT% of samples (>= $MIN_PCT% required)"
if [ "$STATUS_STR" = "FAILED" ]; then
echo "Contents of $SYSPROF_OUT_FILE:"
echo ""
cat $SYSPROF_OUT_FILE
echo ""
echo "Samples by each process:"
xsltproc --nonet --novalid ${TEST_DIR}/sysprof-usage.xsl $SYSPROF_OUT_FILE | sort -n -r
fi
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exslt="http://exslt.org/common"
extension-element-prefixes="exslt">
<!--
This transformation manipulates the sysprof output to determine the portion
of CPU time spent on our CPU-intense process. Our final check will be
whether this portion is significant enough to accept that sysprof
identified our process as burning up a lot of cycles.
More-exhaustive tests could potentially be done where we check the relative
processing time for each function within our test process. But that seems a
little too fragile and excessive at this point.
Output: a decimal number in range [0, 1] representing the portion of CPU
time spent on our test program while sysprof ran.
-->
<xsl:output method="text" />
<!-- XXX: keep this sync'd with the test script's TEST_PROG -->
<xsl:variable name="procName">fib.pl</xsl:variable>
<xsl:variable name="size">
<!-- the total number of samples in this entire run -->
<xsl:for-each select="/profile/size">
<!-- select the given value -->
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="procTotal">
<xsl:for-each select="/profile/objects/object">
<!-- match the process by name. Note this only works because the process
renames itself "[$0]" (cutting off any leading path in its name).
Additionally, sysprof wraps every sample object name with "" (hence
&quot;) -->
<!-- (we can't use a regex because we can't use XSLT 2.0) -->
<xsl:if test="starts-with(name, concat('&quot;[', $procName, ']&quot;'))">
<xsl:value-of select="total"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:template match="@*|node()">
<xsl:value-of select="number($procTotal) div number($size)"/>
</xsl:template>
</xsl:stylesheet>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment