| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
rm -f $TMP/*.json
|
| 5 |
|
| 6 |
OILS_CRASH_DUMP_DIR=$TMP $SH -c '
|
| 7 |
g() {
|
| 8 |
local glocal="glocal"
|
| 9 |
echo $(( 1 / 0 ))
|
| 10 |
}
|
| 11 |
f() {
|
| 12 |
local flocal="flocal"
|
| 13 |
shift
|
| 14 |
FOO=bar g
|
| 15 |
}
|
| 16 |
readonly array=(A B C)
|
| 17 |
f "${array[@]}"
|
| 18 |
' dummy a b c
|
| 19 |
|
| 20 |
echo status=$?
|
| 21 |
|
| 22 |
# Just check that we can parse it. TODO: Test properties.
|
| 23 |
python3 -c '
|
| 24 |
import json, sys
|
| 25 |
from pprint import pprint
|
| 26 |
|
| 27 |
for path in sys.argv[1:]:
|
| 28 |
#print(path)
|
| 29 |
with open(path) as f:
|
| 30 |
dump = json.load(f)
|
| 31 |
|
| 32 |
if 0:
|
| 33 |
print("DUMP")
|
| 34 |
print("status = %d" % dump["status"])
|
| 35 |
print("pid = %d" % dump["pid"])
|
| 36 |
|
| 37 |
if 0:
|
| 38 |
# This has msg, source, line
|
| 39 |
print("error %s" % dump["error"])
|
| 40 |
print()
|
| 41 |
|
| 42 |
if 0:
|
| 43 |
# It would be nice if this has the proc name, I guess debug_stack has it
|
| 44 |
print("argv_stack")
|
| 45 |
pprint(dump["argv_stack"])
|
| 46 |
print()
|
| 47 |
|
| 48 |
if 0:
|
| 49 |
print("debug_stack")
|
| 50 |
pprint(dump["debug_stack"])
|
| 51 |
print()
|
| 52 |
|
| 53 |
if 0:
|
| 54 |
print("var_stack")
|
| 55 |
pprint(dump["var_stack"])
|
| 56 |
|
| 57 |
' $TMP/*.json
|
| 58 |
echo status=$?
|
| 59 |
|
| 60 |
## STDOUT:
|
| 61 |
status=1
|
| 62 |
status=0
|
| 63 |
## END
|
| 64 |
|
| 65 |
|
| 66 |
# TODO: The failure is not propagated through 'source'. Failure only happens
|
| 67 |
# on 'errexit'.
|
| 68 |
#rm -f $TMP/*.json
|
| 69 |
OILS_CRASH_DUMP_DIR=$TMP $SH -c "
|
| 70 |
set -o errexit
|
| 71 |
source $REPO_ROOT/spec/testdata/crash.sh
|
| 72 |
"
|
| 73 |
echo crash status=$?
|
| 74 |
|
| 75 |
# Now try to parse crash dumps
|
| 76 |
set -o xtrace
|
| 77 |
set -o errexit
|
| 78 |
|
| 79 |
# Enumerate crash dumps
|
| 80 |
ok=0
|
| 81 |
for dump in $TMP/*.json; do
|
| 82 |
# Workaround for test issue: release binaries leave empty files because they
|
| 83 |
# don't have the json module.
|
| 84 |
if test -s $dump; then # non-empty
|
| 85 |
python2 -m json.tool $dump > /dev/null
|
| 86 |
echo "OK $dump" >&2
|
| 87 |
(( ++ok ))
|
| 88 |
fi
|
| 89 |
done
|
| 90 |
|
| 91 |
if test $ok -ge 1; then # make sure we parsed at least once crash dump
|
| 92 |
echo 'found crash dump'
|
| 93 |
fi
|
| 94 |
|
| 95 |
## STDOUT:
|
| 96 |
crash status=1
|
| 97 |
found crash dump
|
| 98 |
## END
|
| 99 |
|
| 100 |
# NOTE: strict_arith has one case in arith.test.sh), strict_word-eval has a case in var-op-other.
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
$SH --tool cat-em zzZZ
|
| 106 |
echo status=$?
|
| 107 |
|
| 108 |
$SH --tool cat-em stdlib/math.ysh > /dev/null
|
| 109 |
echo status=$?
|
| 110 |
|
| 111 |
$SH --tool cat-em zzZZ stdlib/math.ysh > /dev/null
|
| 112 |
echo status=$?
|
| 113 |
|
| 114 |
## STDOUT:
|
| 115 |
status=1
|
| 116 |
status=0
|
| 117 |
status=1
|
| 118 |
## END
|
| 119 |
|
| 120 |
|