File: 1145

package info (click to toggle)
pcp 4.3.2%2Breally4.3.1-0.1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 175,188 kB
  • sloc: ansic: 261,305; sh: 123,606; xml: 107,279; cpp: 72,127; perl: 18,283; python: 15,453; yacc: 8,249; lex: 2,585; makefile: 1,957; fortran: 60; java: 52
file content (72 lines) | stat: -rwxr-xr-x 2,556 bytes parent folder | download | duplicates (5)
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
#!/bin/sh
# PCP QA Test No. 1145
# Use libpcp_fault to exercise error paths in vpmprintf()
#
# Copyright (c) 2019 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

src/check_fault_injection >/dev/null 2>&1 || \
    _notrun "libpcp not built with fault injection enabled"

_cleanup()
{
    cd $here
    $sudo rm -rf $tmp $tmp.*
}

status=1	# failure is the default!
$sudo rm -rf $tmp $tmp.* $seq.full
trap "_cleanup; exit \$status" 0 1 2 3 15

export PM_FAULT_CONTROL=$tmp.control
export LD_PRELOAD=$PCP_LIB_DIR/libpcp_fault.so

# [Tue Feb  5 07:03:01] pcp(6045) Warning: vmprintf malloc: malloc(4096) failed: Cannot allocate memory
#
_filter()
{
    sed \
	-e 's/pcp([0-9][0-9]*)/pcp(PID)/' \
	-e 's/\[[A-Z][a-z][a-z] [A-Z][a-z][a-z]  *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]]/[DATE]/' \
    # end
}

# real QA test starts here

echo "force 1st malloc to fail"
cat >$tmp.control <<End-of-File
libpcp/util.c:1	== 1
End-of-File
src/pmprintf "foo" "bar" 2>&1 | _filter

# k is 1024 bytes long
#
k="0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123"

echo "force 1st realloc to fail"
cat >$tmp.control <<End-of-File
libpcp/util.c:2	== 1
End-of-File
src/pmprintf "X" $k "X" $k "X" $k "X" $k "X" 2>&1 \
| _filter

echo "force 2nd realloc to fail"
cat >$tmp.control <<End-of-File
libpcp/util.c:2	== 2
End-of-File
src/pmprintf "X" $k "X" $k "X" $k "X" $k "X" $k "X" $k "X" $k "X" $k "X" 2>&1 \
| _filter

# success, all done
status=0

exit