xref: /OK3568_Linux_fs/external/xserver/test/scripts/run-piglit.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/bin/sh
2*4882a593Smuzhiyun
3*4882a593Smuzhiyunset -e
4*4882a593Smuzhiyun
5*4882a593Smuzhiyunif test "x$XTEST_DIR" = "x"; then
6*4882a593Smuzhiyun    echo "XTEST_DIR must be set to the directory of the xtest repository."
7*4882a593Smuzhiyun    # Exit as a "skip" so make check works even without piglit.
8*4882a593Smuzhiyun    exit 77
9*4882a593Smuzhiyunfi
10*4882a593Smuzhiyun
11*4882a593Smuzhiyunif test "x$PIGLIT_DIR" = "x"; then
12*4882a593Smuzhiyun    echo "PIGLIT_DIR must be set to the directory of the piglit repository."
13*4882a593Smuzhiyun    # Exit as a "skip" so make check works even without piglit.
14*4882a593Smuzhiyun    exit 77
15*4882a593Smuzhiyunfi
16*4882a593Smuzhiyun
17*4882a593Smuzhiyunif test "x$PIGLIT_RESULTS_DIR" = "x"; then
18*4882a593Smuzhiyun    echo "PIGLIT_RESULTS_DIR must be set to where to output piglit results."
19*4882a593Smuzhiyun    # Exit as a real failure because it should always be set.
20*4882a593Smuzhiyun    exit 1
21*4882a593Smuzhiyunfi
22*4882a593Smuzhiyun
23*4882a593Smuzhiyunif test "x$XSERVER_DIR" = "x"; then
24*4882a593Smuzhiyun    echo "XSERVER_DIR must be set to the directory of the xserver repository."
25*4882a593Smuzhiyun    # Exit as a real failure because it should always be set.
26*4882a593Smuzhiyun    exit 1
27*4882a593Smuzhiyunfi
28*4882a593Smuzhiyun
29*4882a593Smuzhiyunif test "x$XSERVER_BUILDDIR" = "x"; then
30*4882a593Smuzhiyun    echo "XSERVER_BUILDDIR must be set to the build directory of the xserver repository."
31*4882a593Smuzhiyun    # Exit as a real failure because it should always be set.
32*4882a593Smuzhiyun    exit 1
33*4882a593Smuzhiyunfi
34*4882a593Smuzhiyun
35*4882a593Smuzhiyunif test "x$SERVER_COMMAND" = "x"; then
36*4882a593Smuzhiyun    echo "SERVER_COMMAND must be set to the server to be spawned."
37*4882a593Smuzhiyun    # Exit as a real failure because it should always be set.
38*4882a593Smuzhiyun    exit 1
39*4882a593Smuzhiyunfi
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun$XSERVER_BUILDDIR/test/simple-xinit \
42*4882a593Smuzhiyun    $XSERVER_DIR/test/scripts/xinit-piglit-session.sh \
43*4882a593Smuzhiyun    -- \
44*4882a593Smuzhiyun    $SERVER_COMMAND
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun# Write out piglit-summaries.
47*4882a593SmuzhiyunSHORT_SUMMARY=$PIGLIT_RESULTS_DIR/summary
48*4882a593SmuzhiyunLONG_SUMMARY=$PIGLIT_RESULTS_DIR/long-summary
49*4882a593Smuzhiyun$PIGLIT_DIR/piglit summary console -s $PIGLIT_RESULTS_DIR > $SHORT_SUMMARY
50*4882a593Smuzhiyun$PIGLIT_DIR/piglit summary console $PIGLIT_RESULTS_DIR > $LONG_SUMMARY
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun# Write the short summary to make check's log file.
53*4882a593Smuzhiyuncat $SHORT_SUMMARY
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun# Parse the piglit summary to decide on our exit status.
56*4882a593Smuzhiyunstatus=0
57*4882a593Smuzhiyun# "pass: 0" would mean no tests actually ran.
58*4882a593Smuzhiyunif grep "^ *pass: *0$" $SHORT_SUMMARY > /dev/null; then
59*4882a593Smuzhiyun    status=1
60*4882a593Smuzhiyunfi
61*4882a593Smuzhiyun# Fails or crashes should be failures from make check's perspective.
62*4882a593Smuzhiyunif ! grep "^ *fail: *0$" $SHORT_SUMMARY > /dev/null; then
63*4882a593Smuzhiyun    status=1
64*4882a593Smuzhiyunfi
65*4882a593Smuzhiyunif ! grep "^ *crash: *0$" $SHORT_SUMMARY > /dev/null; then
66*4882a593Smuzhiyun    status=1
67*4882a593Smuzhiyunfi
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun$PIGLIT_DIR/piglit summary html \
70*4882a593Smuzhiyun	--overwrite \
71*4882a593Smuzhiyun	$PIGLIT_RESULTS_DIR/html \
72*4882a593Smuzhiyun	$PIGLIT_RESULTS_DIR
73*4882a593Smuzhiyun
74*4882a593Smuzhiyunif test $status != 0; then
75*4882a593Smuzhiyun    echo "Some piglit tests failed."
76*4882a593Smuzhiyun    echo "The list of failing tests can be found in $LONG_SUMMARY."
77*4882a593Smuzhiyunfi
78*4882a593Smuzhiyunecho "An html page of the test status can be found at $PIGLIT_RESULTS_DIR/html/index.html"
79*4882a593Smuzhiyun
80*4882a593Smuzhiyunexit $status
81