stdio-test.sh 3.09 KB
Newer Older
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
#!/bin/bash

PROG=stdio-test

# set log file path; remove previous log if present
export DARSHAN_LOGFILE=$DARSHAN_TMP/${PROG}.darshan
rm -f ${DARSHAN_LOGFILE}

# compile
$DARSHAN_CC $DARSHAN_TESTDIR/test-cases/src/${PROG}.c -o $DARSHAN_TMP/${PROG}
if [ $? -ne 0 ]; then
    echo "Error: failed to compile ${PROG}" 1>&2
    exit 1
fi

# execute
$DARSHAN_RUNJOB $DARSHAN_TMP/${PROG} -f $DARSHAN_TMP/${PROG}.tmp.dat
if [ $? -ne 0 ]; then
    echo "Error: failed to execute ${PROG}" 1>&2
    exit 1
fi

# parse log
$DARSHAN_PATH/bin/darshan-parser $DARSHAN_LOGFILE > $DARSHAN_TMP/${PROG}.darshan.txt
if [ $? -ne 0 ]; then
    echo "Error: failed to parse ${DARSHAN_LOGFILE}" 1>&2
    exit 1
fi

30
# TODO: look for "head" commands in all of these test cases and remove them
31 32 33
# later.  Right now they are needed to make sure we only check 1 out of 4
# possible records because reduction is not implemented yet

34
# check results
35

36
# in this case we want to confirm that the STDIO counters were triggered
37
STDIO_OPENS=`grep STDIO_OPENS $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
38
if [ ! "$STDIO_OPENS" -gt 0 ]; then
39
    echo "Error: STDIO open count of $STDIO_OPENS is incorrect" 1>&2
40 41
    exit 1
fi
42 43 44 45 46
STDIO_BYTES_WRITTEN=`grep STDIO_BYTES_WRITTEN $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
if [ ! "$STDIO_BYTES_WRITTEN" -eq 6 ]; then
    echo "Error: STDIO open count of $STDIO_BYTES_WRITTEN is incorrect" 1>&2
    exit 1
fi
47 48 49 50 51
STDIO_BYTES_READ=`grep STDIO_BYTES_READ $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
if [ ! "$STDIO_BYTES_READ" -eq 6 ]; then
    echo "Error: STDIO open count of $STDIO_BYTES_READ is incorrect" 1>&2
    exit 1
fi
52

53

54 55
# make sure that some of the floating point counters are valid
# use bc for floating point comparison
56
STDIO_F_OPEN_START_TIMESTAMP=`grep STDIO_F_OPEN_START_TIMESTAMP $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
57 58 59 60
if [ ! $(echo "$STDIO_F_OPEN_START_TIMESTAMP > 0" | bc -l) ]; then
    echo "Error: counter is incorrect" 1>&2
    exit 1
fi
61
STDIO_F_OPEN_END_TIMESTAMP=`grep STDIO_F_OPEN_END_TIMESTAMP $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
62 63 64 65
if [ ! $(echo "$STDIO_F_OPEN_END_TIMESTAMP > 0" | bc -l) ]; then
    echo "Error: counter is incorrect" 1>&2
    exit 1
fi
66
STDIO_F_META_TIME=`grep STDIO_F_META_TIME $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
67 68 69 70
if [ ! $(echo "$STDIO_F_META_TIME > 0" | bc -l) ]; then
    echo "Error: counter is incorrect" 1>&2
    exit 1
fi
71 72 73 74 75 76
STDIO_F_WRITE_TIME=`grep STDIO_F_WRITE_TIME $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
if [ ! $(echo "$STDIO_F_WRITE_TIME > 0" | bc -l) ]; then
    echo "Error: counter is incorrect" 1>&2
    exit 1
fi
STDIO_F_CLOSE_START_TIMESTAMP=`grep STDIO_F_CLOSE_START_TIMESTAMP $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
77 78 79 80
if [ ! $(echo "$STDIO_F_CLOSE_START_TIMESTAMP > 0" | bc -l) ]; then
    echo "Error: counter is incorrect" 1>&2
    exit 1
fi
81
STDIO_F_CLOSE_END_TIMESTAMP=`grep STDIO_F_CLOSE_END_TIMESTAMP $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
82 83 84 85
if [ ! $(echo "$STDIO_F_CLOSE_END_TIMESTAMP > 0" | bc -l) ]; then
    echo "Error: counter is incorrect" 1>&2
    exit 1
fi
86 87


88
exit 0