This file is indexed.

/var/lib/pcp/testsuite/src/chkconnect.c is in pcp-testsuite 3.9.10.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
 * Copyright (c) 1997-2001 Silicon Graphics, Inc.  All Rights Reserved.
 */

#include <unistd.h>
#include <ctype.h>
#include <pcp/pmapi.h>
#include <pcp/impl.h>

int
main(int argc, char **argv)
{
    int		j;
    int		numpmid;
    int		numval;
    char	*namelist[20];
    pmID	pmidlist[20];
    pmResult	*result;
    int		c;
    int		sts;
    int		i;
    int		errflag = 0;
    char	*host = "localhost";
    char	*namespace = PM_NS_DEFAULT;
    char	*endnum;
    int		iter = 100;

#ifdef PCP_DEBUG
    static char	*debug = "[-D N]";
#else
    static char	*debug = "";
#endif
    static char	*usage = "[-h hostname] [-i iterations] [-n namespace]";

    __pmSetProgname(argv[0]);

    while ((c = getopt(argc, argv, "D:h:i:n:")) != EOF) {
	switch (c) {

#ifdef PCP_DEBUG
	case 'D':	/* debug flag */
	    sts = __pmParseDebug(optarg);
	    if (sts < 0) {
		fprintf(stderr, "%s: unrecognized debug flag specification (%s)\n",
		    pmProgname, optarg);
		errflag++;
	    }
	    else
		pmDebug |= sts;
	    break;
#endif

	case 'h':	/* hostname for PMCD to contact */
	    host = optarg;
	    break;

	case 'i':	/* iteration count */
	    iter = (int)strtol(optarg, &endnum, 10);
	    if (*endnum != '\0') {
		fprintf(stderr, "%s: -i requires numeric argument\n", pmProgname);
		errflag++;
	    }
	    break;

	case 'n':	/* alternative name space file */
	    namespace = optarg;
	    break;

	case '?':
	default:
	    errflag++;
	    break;
	}
    }

    if (errflag) {
	fprintf(stderr, "Usage: %s %s%s\n", pmProgname, debug, usage);
	exit(1);
    }

    if ((sts = pmLoadNameSpace(namespace)) < 0) {
	fprintf(stderr, "pmLoadNameSpace(%s): %s\n", namespace, pmErrStr(sts));
	exit(1);
    }

    i = 0;
    namelist[i++] = "sample.control";
    namelist[i++] = "sampledso.control";
    namelist[i++] = "sampledso.control";
    namelist[i++] = "pmcd.control.debug";
    namelist[i++] = "sample.control";
    namelist[i++] = "pmcd.control.debug";
    namelist[i++] = "sampledso.control";
    namelist[i++] = "pmcd.control.debug";
    namelist[i++] = "sample.control";
    namelist[i++] = "sampledso.control";
    namelist[i++] = "pmcd.control.debug";
    namelist[i++] = "sample.control";
    numpmid = i;
    sts = pmLookupName(numpmid, namelist, pmidlist);
    if (sts < 0) {
	fprintf(stderr, "pmLookupName: %s\n", pmErrStr(sts));
	for (i = 0; i < numpmid; i++) {
	    if (pmidlist[i] == PM_ID_NULL)
		printf("	%s - not known\n", namelist[i]);
	}
	exit(1);
    }

    for (i = 0; i < iter; i++) {
	sts = pmNewContext(PM_CONTEXT_HOST, host);
	if (sts < 0) {
	    fprintf(stderr, "pmNewContext: [iteration %d] %s\n", i, pmErrStr(sts));
	    exit(1);
	}
	else if (sts != i * 2)
	    fprintf(stderr, "Error: [iteration %d] pmNewContext handle expected %d, got %d\n", i, i * 2, sts);

	numpmid = 1 + lrand48() % 12;
	if ((sts = pmFetch(numpmid, pmidlist, &result)) < 0) {
	    fprintf(stderr, "pmFetch: [iteration %d] %s\n", i, pmErrStr(sts));
	    exit(1);
	}
	numval = 0;
	for (j = 0; j < result->numpmid; j++) {
	    if (result->vset[j]->numval >= 0)
		numval += result->vset[j]->numval;
	}
	if (numval != numpmid) {
	    fprintf(stderr, "Error: [iteration %d] pmFetch numval expected %d, got %d\n", i, numpmid, numval);
	}
	pmFreeResult(result);

	sts = pmDupContext();
	if (sts < 0) {
	    fprintf(stderr, "pmDupContext: [iteration %d] %s\n", i, pmErrStr(sts));
	    exit(1);
	}
	else if (sts != i * 2 + 1)
	    fprintf(stderr, "Error: [iteration %d] pmDupContext handle expected %d, got %d\n", i, i * 2 + 1, sts);

	numpmid = 1 + lrand48() % 12;
	if ((sts = pmFetch(numpmid, pmidlist, &result)) < 0) {
	    fprintf(stderr, "pmFetch: [iteration %d, dup context] %s\n", i, pmErrStr(sts));
	    exit(1);
	}
	numval = 0;
	for (j = 0; j < result->numpmid; j++) {
	    if (result->vset[j]->numval >= 0)
		numval += result->vset[j]->numval;
	}
	if (numval != numpmid) {
	    fprintf(stderr, "Error: [iteration %d] pmFetch numval expected %d, got %d\n", i, numpmid, numval);
	}
	pmFreeResult(result);

	if ((sts = pmReconnectContext(i)) < 0) {
	    fprintf(stderr, "pmReconnectContext: [iteration %d] %s\n", i, pmErrStr(sts));
	    exit(1);
	}

	numpmid = 1 + lrand48() % 12;
	if ((sts = pmFetch(numpmid, pmidlist, &result)) < 0) {
	    fprintf(stderr, "pmFetch: [iteration %d, recon] %s\n", i, pmErrStr(sts));
	    exit(1);
	}
	numval = 0;
	for (j = 0; j < result->numpmid; j++) {
	    if (result->vset[j]->numval >= 0)
		numval += result->vset[j]->numval;
	}
	if (numval != numpmid) {
	    fprintf(stderr, "Error: [iteration %d, recon] pmFetch numval expected %d, got %d\n", i, numpmid, numval);
	}
	pmFreeResult(result);

    }

    return 0;
}