1 | #!/usr/bin/ruby
|
---|
2 |
|
---|
3 | require 'fileutils'
|
---|
4 | require 'rbconfig'
|
---|
5 | include FileUtils
|
---|
6 |
|
---|
7 | rc_d = 'rc.d'
|
---|
8 | if not File.exist? rc_d then
|
---|
9 | rc_d = "../lib/smalltalkx/6.2.5/lib/rc.d"
|
---|
10 | end
|
---|
11 |
|
---|
12 | token="bug_86_starting_stx_with_saved_image_kills_the_whole_environment"
|
---|
13 |
|
---|
14 |
|
---|
15 | stx_cmd = nil
|
---|
16 | if File.exist? 'stx.com' then
|
---|
17 | stx_cmd = 'stx.com'
|
---|
18 | elsif File.exist? 'stx-bin.com' then
|
---|
19 | stx_cmd = 'stx-bin.com'
|
---|
20 | else
|
---|
21 | stx_cmd = './stx'
|
---|
22 | end
|
---|
23 | puts "stx_cmd = #{stx_cmd.inspect}"
|
---|
24 |
|
---|
25 | File.open("#{rc_d}/99-#{token}.rc", "w") do | f |
|
---|
26 | f.write <<END
|
---|
27 | (OperatingSystem getEnvironment: '#{token}') = '1' ifTrue:[
|
---|
28 | Smalltalk addStartBlock:[
|
---|
29 | | p |
|
---|
30 | [
|
---|
31 | "FRESH start"
|
---|
32 | Smalltalk addImageStartBlock:[
|
---|
33 | "RESTARTING from a snapshot"
|
---|
34 | [
|
---|
35 | Stdout nextPutLine: 'Restarted from snapshot.'.
|
---|
36 | Delay waitForSeconds: 3.
|
---|
37 | (Smalltalk at:#WinWorkstation) notNil ifTrue:[
|
---|
38 | WinWorkstation printHandleCounts; printGuiResourceCounts.
|
---|
39 | ].
|
---|
40 | (OperatingSystem getEnvironment: '#{token}') = '1' ifTrue:[
|
---|
41 | Smalltalk exit: 121.
|
---|
42 | ].
|
---|
43 | ] fork.
|
---|
44 | ].
|
---|
45 | p := UIPainter new.
|
---|
46 | p open.
|
---|
47 | p gridShownHolder value: true.
|
---|
48 | p alignToGridHolder value: true.
|
---|
49 | p := nil.
|
---|
50 | Dialog information: 'Do some work in UI painter - add some widgets and move them around, then close UI Painter and press OK'.
|
---|
51 | Stdout nextPutLine: 'Will save a snapshot and exit in 3 seconds.'.
|
---|
52 | Delay waitForSeconds: 3.
|
---|
53 | Smalltalk garbageCollect.
|
---|
54 | (Smalltalk at:#WinWorkstation) notNil ifTrue:[
|
---|
55 | WinWorkstation printHandleCounts; printGuiResourceCounts.
|
---|
56 | ].
|
---|
57 |
|
---|
58 | ObjectMemory snapShot.
|
---|
59 | Smalltalk exit: 123.
|
---|
60 | ] fork.
|
---|
61 | ].
|
---|
62 | ]
|
---|
63 | END
|
---|
64 | end
|
---|
65 |
|
---|
66 | ENV[token] = '1'
|
---|
67 |
|
---|
68 | # Step 1.
|
---|
69 | rm_f 'st.img'; rm_f 'st.sav'; rm_f 'st.chg'
|
---|
70 |
|
---|
71 | # Step 2.
|
---|
72 | system "#{stx_cmd} -I --quick"
|
---|
73 | if $?.exitstatus != 123 then
|
---|
74 | raise Exception.new("stx failed to execute (status #{$?.exitstatus})");
|
---|
75 | end
|
---|
76 |
|
---|
77 | if not File.exist? 'st.img' then
|
---|
78 | raise Exception.new("st.img was not saved")
|
---|
79 | end
|
---|
80 |
|
---|
81 | # Step 3.
|
---|
82 | system "#{stx_cmd} -i st.img"
|
---|
83 | if $?.exitstatus != 121 then
|
---|
84 | puts
|
---|
85 | puts "Start gdb as:"
|
---|
86 | puts
|
---|
87 | puts ' C:\mingw64\bin\gdb.exe --args stx-bin.com -i st.img'
|
---|
88 | puts
|
---|
89 | raise Exception.new("stx failed to restart from a snapshot (status #{$?.exitstatus})");
|
---|
90 | end
|
---|
91 |
|
---|
92 | puts
|
---|
93 | puts "PASSED"
|
---|