File: run.sh

package info (click to toggle)
devicexlib 0.8.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,364 kB
  • sloc: f90: 77,678; sh: 3,701; fortran: 773; makefile: 268; python: 246; ansic: 69; awk: 36
file content (116 lines) | stat: -rwxr-xr-x 2,486 bytes parent folder | download
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
111
112
113
114
115
116
#! /usr/bin/env bash
#
# General utility to run tests
#
#================================================================
#
# Input flags for this script (./run.sh FLAG): 
#
MANUAL=" 
 Usage
   run.sh [-h,--help] [-l,--list] [-v,--verbose] [-a,--all] [-c,--clean] [<tests>]

 run deviceXlib tests
 When the command line is empty the following manual page is printed:
 
 -h,--help       print this manual    
 -l,--list       print the list of existing tests
 -v,--verbose    print verbose output
 -a,--all        run all tests
 -c,--clean      clean tests outputs
 <tests>         a list of the tests to run (eg 'linalg' 'memcpy' )

"
#
#================================================================
#
# List of tests
#
TEST_LIST=" 
 Tests:

   linalg        Linear algebra wrappers
   malloc        Memory allocations on GPUs
   mapping       Memory mapping (HOST/DEV)
   buffer        Buffers on GPU memory 
   memcpy        Memory copies
   memcpy_async  Memory copies (Async)
   memset        Memory init
   pinned        Handling of pinned memory
"
#
#================================================================
#
testdir=`echo $0 | sed 's/\(.*\)\/.*/\1/'`
bindir=$testdir/../bin
bold_on=""
bold_off=""
#
# parse command line input
#
LIST=
CLEAN=
VERBOSE=
#
for OPT in $*
do
  case $OPT in
  ("-h" | "--help") echo "$MANUAL" ; exit 0 ;;
  ("-l" | "--list") echo "$TEST_LIST" ; exit 0 ;;
  ("-a" | "--all")      LIST="ALL" ;;
  ("-v" | "--verbose")  VERBOSE="yes" ;;
  ("-c" | "--clean")    CLEAN="yes" ;;
  (*)                   LIST="$LIST $OPT" ;;
  esac
done
# 
if [ "$CLEAN" = "yes" ] ; then rm -f $testdir/*.out ; exit 0 ; fi
#
if [ "$LIST" == "ALL" ] ; then
   LIST=`echo "$TEST_LIST" | awk '{ if (NR<=3) {next} else {print $1} }'`
fi
if [ -z "$LIST" ] ; then echo "$MANUAL" ; exit 0 ; fi

#
# reporting
#
echo "
${bold_on}Running tests:${bold_off} 
"
ind=0
for mytest in $LIST ; do
  var=$((ind++))
  echo "  ($ind)  $mytest"
done
echo

#
# perform the required tasks
#
for mytest in $LIST
do
    testfile=$bindir/test_${mytest}.x    
    output=$testdir/test_${mytest}.out
    #
    if [ ! -x $testfile ] ; then
        echo "  file $testfile does not exist" ; exit 3
    fi
    # 
    # running test 
    #
    echo
    echo " Running ${bold_on}${mytest}${bold_off}"
    #
    $testfile > $output
    if [ "$VERBOSE" = "yes" ] ; then cat $output | grep -v "\#" ; fi
    cat $output | grep '\#' | awk -f $testdir/fmt_output.awk
    #
done

echo
exit 0