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
|
#!/bin/sh
# PCP QA Test No. 1606
# malloc/free integrity on pmDupContext error paths
#
# non-valgrind variant, see qa/1607 for the valgrind variant
#
# Copyright (c) 2025 Ken McDonell. All Rights Reserved.
#
if [ $# -eq 0 ]
then
seq=`basename $0`
echo "QA output created by $seq"
else
# use $seq from caller, unless not set
[ -n "$seq" ] || seq=`basename $0`
echo "QA output created by `basename $0` $*"
fi
# 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"
do_valgrind=false
if [ "$1" = "--valgrind" ]
then
_check_valgrind
do_valgrind=true
elif which valgrind >/dev/null 2>&1
then
[ "$PCPQA_VALGRIND" = both ] || \
_notrun "valgrind variant qa/1607 will be run"
fi
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.*
}
status=0 # success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_filter()
{
sed \
-e "s@$tmp@TMP@g" \
# end
}
_do_arch()
{
if $do_valgrind
then
_run_valgrind src/context_test -I -i2 "$@"
else
src/context_test -I -i2 "$@" 2>&1
fi \
| _filter
}
# avoid derived metrics
export PCP_DERIVED_CONFIG=
# setup mutiarchive dir
# - pmlogrewrite to "fix" hostname and timezone
#
mkdir $tmp || exit 1
cat >$tmp.rewrite <<End-of-File
global {
hostname -> pcp.qa.com
timezone -> "UTC"
}
End-of-File
for arch in archives/ok-bigbin archives/ok-mv-bigbin archives/ok-foo
do
if pmlogrewrite -c $tmp.rewrite $arch `echo $arch | sed -e "s@^archives/@$tmp/@"`
then
:
else
echo "Arrggh ... rewrite failed"
status=1
exit
fi
done
# setup using libpcp_fault
export PM_FAULT_CONTROL=$tmp.control
export LD_PRELOAD=$PCP_LIB_DIR/libpcp_fault.so
# real QA test starts here
echo "== initial profile malloc fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:0 == 1
End-of-File
_do_arch -h local:
echo
echo "== profile instances malloc fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:1 == 1
End-of-File
_do_arch -h local:
echo
echo "== clone c_archctl malloc fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:2 == 1
End-of-File
_do_arch -a tmparch/foo
echo
echo "== c_archctl->ac_log_list malloc fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:3 == 1
End-of-File
_do_arch -a tmparch/foo
echo
echo "== c_archctl->ac_log_list[0] malloc fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:4 == 1
End-of-File
_do_arch -a $tmp
echo
echo "== c_archctl->ac_log_list[2] malloc fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:4 == 3
End-of-File
_do_arch -a $tmp
echo
echo "== c_archctl->ac_log_list[0]->name strdup fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:5 == 1
End-of-File
_do_arch -a $tmp
echo
echo "== c_archctl->ac_log_list[1]->hostname strdup fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:6 == 2
End-of-File
_do_arch -a $tmp
echo
echo "== c_archctl->ac_log_list[2]->timezone strdup fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:7 == 3
End-of-File
_do_arch -a $tmp
echo
echo "== c_archctl->ac_log_list[0]->zoneinfo strdup fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:8 == 1
End-of-File
_do_arch -a tmparch/foo
echo
echo "== map_handle() fails"
cat >$tmp.control <<End-of-File
libpcp/context.c:9 == 1
End-of-File
_do_arch -h local:
# success, all done
exit
|