~ubuntu-x-swat/xorg-server/xsmoke

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash

. $(dirname $)/lib/xsmoke.lib

usage () {
    cat <<EOF
Usage:  $0
    This test suite must be run with X and gdm shut down, and needs to
    be run as the root user.
EOF
}

# Verify running as root
if ! is_superuser ; then
    echo "This must be run as root"
    exit 1
fi

# Check that X is NOT up and running currently
if is_running "gdm" || is_running "X" ; then
    echo "Please exit all X sessions and shut down gdm before running this test"
    exit 1
fi

# Create results directory
i=0
RESULTS_DIR=$(printf "results-%04d" $i)
while [ -d "${RESULTS_DIR}" ] ; do
    let i=i+1
    RESULTS_DIR=$(printf "results-%04d" $i)
done
mkdir -p ${RESULTS_DIR}

# Check prerequisites
for case in tests/xst-*.sh ; do
    $case prerequisites
    test_xorg_restart
done

# Run the tests
i=0
declare -a result
for case in tests/xst-*.sh ; do
    json_file=${RESULTS_DIR}/$(basename ${case%.sh}.json)
    out_file=${RESULTS_DIR}/$(basename ${case%.sh}.out)
    $case ${json_file} | tee ${out_file} | grep -e "^\[[A-Z]\] "
    result[$i]=${case%.sh}":  "$(tail -n 1 ${out_file})
    test_xorg_restart > /dev/null
    # TODO:  Check test_xorg_restart() exit code
    let i=i+1
done

# Print testrun summary
for i in $( seq 0 $((${#result[@]} - 1)) ) ; do
    echo ${result[$i]}
done

exit 0