File: acats-killer.sh

package info (click to toggle)
gcc-4.8 4.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 587,180 kB
  • ctags: 425
  • sloc: makefile: 65,711; sh: 1,248; perl: 165; awk: 23; cpp: 14
file content (62 lines) | stat: -rw-r--r-- 1,087 bytes parent folder | download | duplicates (59)
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
#! /bin/sh

# on ia64 systems, the acats hangs in unaligned memory accesses.
# kill these testcases.

pidfile=acats-killer.pid

usage()
{
    echo >&2 "usage: `basename $0` [-p <pidfile>] <ada logfile> <next logfile>"
    exit 1
}

while [ $# -gt 0 ]; do
    case $1 in
    -p)
	pidfile=$2
	shift
	shift
	;;
    -*)
	usage
	;;
    *)
	break
    esac
done

[ $# -eq 2 ] || usage

logfile=$1
stopfile=$2
interval=30

echo $$ > $pidfile

while true; do
    if [ -f "$stopfile" ]; then
	echo "`basename $0`: finished."
	rm -f $pidfile
	exit 0
    fi
    sleep $interval
    if [ ! -f "$logfile" ]; then
	continue
    fi
    pids=$(ps aux | awk '/testsuite\/ada\/acats\/tests/ { print $2 }')
    if [ -n "$pids" ]; then
	sleep $interval
        pids2=$(ps aux | awk '/testsuite\/ada\/acats\/tests/ { print $2 }')
	if [ "$pids" = "$pids2" ]; then
	    #echo kill: $pids
	    kill $pids
	    sleep 1
            pids2=$(ps aux | awk '/testsuite\/ada\/acats\/tests/ { print $2 }')
	    if [ "$pids" = "$pids2" ]; then
	        #echo kill -9: $pids
	        kill -9 $pids
	    fi
	fi
    fi
done