Faculty of Information Technology
Software Engineering Group

Ticket #86: bug_86_starting_stx_with_saved_image_kills_the_whole_environment.rb

File bug_86_starting_stx_with_saved_image_kills_the_whole_environment.rb, 2.4 KB (added by Jan Vrany, 4 years ago)
Line 
1#!/usr/bin/ruby
2
3require 'fileutils'
4require 'rbconfig'
5include FileUtils
6
7rc_d = 'rc.d'
8if not File.exist? rc_d then
9  rc_d = "../lib/smalltalkx/6.2.5/lib/rc.d"
10end
11
12token="bug_86_starting_stx_with_saved_image_kills_the_whole_environment"
13
14
15stx_cmd = nil
16if File.exist? 'stx.com' then
17  stx_cmd = 'stx.com'
18elsif File.exist? 'stx-bin.com' then
19  stx_cmd = 'stx-bin.com'
20else
21  stx_cmd = './stx'
22end
23puts "stx_cmd = #{stx_cmd.inspect}"
24
25File.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]
63END
64end     
65
66ENV[token] = '1'
67
68# Step 1.
69rm_f 'st.img'; rm_f 'st.sav'; rm_f 'st.chg'
70
71# Step 2.
72system "#{stx_cmd} -I --quick"
73if $?.exitstatus != 123 then
74  raise Exception.new("stx failed to execute (status #{$?.exitstatus})");
75end
76
77if not File.exist? 'st.img' then
78  raise Exception.new("st.img was not saved")
79end
80
81# Step 3.
82system "#{stx_cmd} -i st.img"
83if $?.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})");
90end
91
92puts 
93puts "PASSED"