OILS / test / bug-1986.sh View on Github | oilshell.org

122 lines, 40 significant
1#!/usr/bin/env bash
2#
3# Potentially Long-running stress tests
4#
5# Usage:
6# test/stress.sh <function name>
7
8set -o nounset
9set -o pipefail
10set -o errexit
11
12# GC bug?
13
14replace-ysh() {
15 #local ysh=_bin/cxx-opt/ysh
16 local ysh=_bin/cxx-dbg/ysh
17 #local ysh=_bin/cxx-asan/ysh
18 ninja $ysh
19
20 # gc_mylib.cc sets threshold to 50K
21 # it doesn't seem to matter!
22 #
23 # Oh does this have to do with recursively calling back into the interpreter?
24
25 #GDB='gdb --args '
26 GDB=''
27
28 # Stats show that there are 29 collections
29 OILS_GC_STATS=1 OILS_GC_VERBOSE=1 OILS_GC_THRESHOLD=10 $GDB $ysh -c '
30env | grep OILS
31
32var x = "z"
33var r = "replace"
34
35for i in (1 .. 2000) {
36 #echo $i
37
38 # creates exponentially sized strings!
39 # TODO: document string size limits
40 #setvar x = x=>replace("z", "zz")
41
42 # Works fine
43 #setvar x = x=>replace("z", "y")
44
45 # Hm does not crash?
46 setvar x = x=>replace("z", ^"hi $r")
47}
48echo $x
49'
50}
51
52shvar-replace() {
53 ### failing test from Julian
54
55 #local ysh=_bin/cxx-asan+gcalways/ysh
56 local ysh=_bin/cxx-dbg/ysh
57 #local ysh=_bin/cxx-asan/ysh
58 ninja $ysh
59 #GDB='gdb --args'
60 GDB=''
61
62 # Takes a few tries, even with OILS_GC_THRESHOLD
63
64 local i=0
65 while true; do
66 echo "=== try $i"
67
68 OILS_GC_STATS=1 OILS_GC_VERBOSE=1 OILS_GC_THRESHOLD=10 $GDB $ysh -c '
69shvar FOO=bar {
70 for x in (1 .. 500) {
71 var Q = "hello"
72 setvar Q = Q=>replace("hello","world")
73 }
74}
75echo $Q
76'
77 i=$(( i + 1 ))
78 done
79}
80
81replace-exp() {
82 local osh=_bin/cxx-opt/osh
83 ninja $osh
84
85 # 2.791 seconds for 19 iterations, up to 1 MB
86 SH=$osh
87
88 SH=bash
89 for sh in bash $osh; do
90 echo "=== $sh ==="
91 echo
92
93 time $sh -c '
94x=z
95for i in {1..19}; do
96 x=${x//z/zz}
97 echo len=${#x}
98done
99 '
100 done
101}
102
103# Reduce this bug
104# https://github.com/oilshell/oil/issues/1986
105
106bug-1986() {
107 local ysh=_bin/cxx-dbg/ysh
108 #local ysh=_bin/cxx-asan/ysh
109 ninja $ysh
110
111 local prefix
112 #prefix=''
113 #prefix="$PWD/$ysh -x"
114 prefix="gdb --args $PWD/$ysh"
115
116 cd bug/code
117
118 set -x
119 $prefix src/amd-scripts/amd-test --select imperfect aomp-amd-staging.cfg 14
120}
121
122"$@"