File: 1059

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (115 lines) | stat: -rwxr-xr-x 2,900 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
#!/bin/sh
# PCP QA Test No. 1059
# pmcd run file and (maybe) unix domain socket are all OK
#
# Copyright (c) 2017 Ken McDonell.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

status=0	# success is the default!
trap "cd $here; $sudo rm -rf $tmp $tmp.*; exit \$status" 0 1 2 3 15

error=false
warn=false

_filter_run_dir()
{
    sed -e "s,$PCP_RUN_DIR,PCP_RUN_DIR,g"
}

# real QA test starts here
_get_pids_by_name -a pmcd >$tmp.pid

if [ ! -s $tmp.pid ]
then
    echo "Error: no running pmcd process"
    error=true
else
    if [ "`wc -l <$tmp.pid | sed -e 's/ //g'`" -gt 1 ]
    then
	echo "Error: multiple pmcd processes running"
	$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep -E '[P]PID|/[p]mcd( |$)'
	error=true
    fi
    if [ -d $PCP_RUN_DIR ]
    then
	if [ ! -f $PCP_RUN_DIR/pmcd.pid ]
	then
	    echo "Error: no $PCP_RUN_DIR/pmcd.pid file"
	    error=true
	else
	    if grep "^`cat $PCP_RUN_DIR/pmcd.pid`\$" $tmp.pid >/dev/null
	    then
		echo "Info: pmcd's PID matches $PCP_RUN_DIR/pmcd.pid" | _filter_run_dir
	    else
		echo "Error: $PCP_RUN_DIR/pmcd.pid (`cat $PCP_RUN_DIR/pmcd.pid`) does not match running pmcds:"
		sed -e 's/^/	/' <$tmp.out
		error=true
	    fi
	    if grep -v "^`cat $PCP_RUN_DIR/pmcd.pid`\$" $tmp.pid >$tmp.out
	    then
		echo "Error: $PCP_RUN_DIR/pmcd.pid (`cat $PCP_RUN_DIR/pmcd.pid`) does not match these pmcd PID(s):"
		sed -e 's/^/	/' <$tmp.out
	    fi
	fi
	if [ -e $PCP_RUN_DIR/pmcd.socket ]
	then
	    if [ -S $PCP_RUN_DIR/pmcd.socket ]
	    then
		if which lsof >/dev/null 2>&1
		then
		    $sudo lsof -U 2>/dev/null \
		    | grep $PCP_RUN_DIR/pmcd.socket \
		    | $PCP_AWK_PROG '$1 != "COMMAND" { print $1,$2 }' \
		    | sort \
		    | uniq >$tmp.tmp
		    if grep "^pmcd `cat $PCP_RUN_DIR/pmcd.pid`\$" $tmp.tmp >/dev/null
		    then
			echo "Info: pmcd's PID matches $PCP_RUN_DIR/pmcd.socket owner" | _filter_run_dir
		    else
			echo "Error: pmcd's PMID (`cat $PCP_RUN_DIR/pmcd.pid`) does not match $PCP_RUN_DIR/pmcd.socket owner"
			$sudo lsof -U | grep $PCP_RUN_DIR/pmcd.socket
			error=true
		    fi
		    if grep -v "^pmcd `cat $PCP_RUN_DIR/pmcd.pid`\$" $tmp.tmp >$tmp.out
		    then
			echo "Error: $PCP_RUN_DIR/pmcd.socket attached to processes other than pmcd:"
			sed -e 's/^/	/' <$tmp.out
		    fi
		else
		    # no lsof, sigh ... fake it
		    echo "Info: pmcd's PID matches $PCP_RUN_DIR/pmcd.socket owner" | _filter_run_dir
		fi
	    else
		echo "Error: $PCP_RUN_DIR/pmcd.socket is not a socket"
		ls -l $PCP_RUN_DIR/pmcd.socket
	    fi
	else
	    echo "Error: no $PCP_RUN_DIR/pmcd.socket socket"
	fi
    else
	echo "Warning: no $PCP_RUN_DIR directory"
	warn=true
    fi
fi

# all done, exit status depends on errors or warnings
#
if $error
then
    status=4
elif $warn
then
    status=1
else
    status=0
fi

exit