summaryrefslogtreecommitdiffstats
path: root/kernel/include/runtest.sh
blob: 94a2ff14c6426bc396da4cd5240a9c190e8e73ca (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh 
#
### Kernel Testing Include File

### Include these variables
#
# control where to log debug messages to:
# devnull = 1 : log to /dev/null
# devnull = 0 : log to file specified in ${DEBUGLOG}
devnull=0

# Create debug log
DEBUGLOG=`mktemp -p /mnt/testarea -t DeBug.XXXXXX`

# locking to avoid races
lck=$OUTPUTDIR/$(basename $0).lck

# Kernel Variables
K_NAME=`rpm -q --queryformat '%{name}\n' -qf /boot/config-$(uname -r)`
# example output: kernel
K_VER=`rpm -q --queryformat '%{version}\n' -qf /boot/config-$(uname -r)`
# example output: 2.6.32
K_REL=`rpm -q --queryformat '%{release}\n' -qf /boot/config-$(uname -r)`
# example output: 220.el6
K_SRC=`rpm -q --queryformat 'kernel-%{version}-%{release}.src.rpm\n' -qf /boot/config-$(uname -r)`
# example output: kernel-2.6.32-220.el6.src.rpm
K_BASE=`rpm -q --queryformat '%{name}-%{version}-%{release}.%{arch}\n' -qf /boot/config-$(uname -r)`
# example output: kernel-2.6.32-220.el6.x86_64
K_ARCH=$(rpm -q --queryformat '%{arch}' -f /boot/config-$(uname -r))
# example output: x86_64
# example output: armv7hl
# example output: armv7l
K_RUNNING=$(uname -r)
# example output: 2.6.32-220.el6.x86_64
K_RUNNING_VR=$(uname -r | sed -e "s/\.${K_ARCH}//")
# example output: 3.6.10-8.fc18.highbank
#
RH_REL=`cat /etc/redhat-release | cut -d" " -f7`
# example output: 6.2
TESTAREA="/mnt/testarea"

### Include these functions
#
# Print out a header
function DefaultHeader ()
{
    echo "*********************************************"
    echo "**        Sourcing: /kernel/include        **"
    echo "*********************************************"

}

# Log a message to the ${DEBUGLOG} or to /dev/null
function DeBug ()
{
    local msg="$1"
    local timestamp=$(date '+%F %T')
    if [ "$devnull" = "0" ]; then
        (
            flock -x 200 2>/dev/null
            echo -n "${timestamp}: " >>$DEBUGLOG 2>&1
            echo "${msg}" >>$DEBUGLOG 2>&1
        ) 200>$lck
    else
        echo "${msg}" >/dev/null 2>&1
    fi
}

function RprtRslt ()
{
    echo "" | tee -a $OUTPUTFILE
    echo "***** End of runtest.sh *****" | tee -a $OUTPUTFILE

    TEST=$1

    # Default result to FAIL
    export RESULT="FAIL"

    # SCORE of 0 is PASS. SCORE of 99 is PASS, as test is skipped
    # If no SCORE is given, default to fail and count the reported fails
    # Then post-process the results to find the regressions
    if test -z "$2" ; then
      export SCORE=`cat $OUTPUTFILE | grep "FAILED: " | wc -l`
    else
      export SCORE=$2
    fi

    if test ! -s "$OUTPUTFILE" ; then
        export RESULT="FAIL"
    else
        if [ "$SCORE" -eq "0" ] || [ "$SCORE" -eq "99" ]; then
            export RESULT="PASS"
        else
            export RESULT="FAIL"
        fi
    fi

    # File the results in the database
    report_result $TEST $RESULT $SCORE
    SubmitLog $DEBUGLOG
    exit 0
}

function SubmitLog ()
{
    LOG=$1
    rhts_submit_log -S $RESULT_SERVER -T $TESTID -l $LOG
}

# EndFile