display resultcheck
time


! verify that we are on a 1.x system with a 1.x image and that $GEMSTONE
! is set to a 1.1x product
expectvalue true
run
| ver |
"check image version"
ver := (Globals at: #ImageVersion) at: #gsVersion.
(ver at:1 equals:'1.1') ifFalse: [
  (ver at:1 equals:'1.2') ifFalse: [
  Object halt: 'need 1.1 or later image, found ImageVersion at: #gsVersion = ', ver
  ].
].
"check executable version"
ver := System gemVersionReport at: #gsRelease.
(ver at:1 equals:'1.1') ifFalse: [
  (ver at:1 equals:'1.2') ifFalse: [
  Object halt: 'need 1.1 or later system, found gsRelease = ',  ver
  ].
].
^true
%

! create the SmallDouble class if it does not already exist
input $GEMSTONE_22/upgrade/smalldoub_11to20.gs

! fixup Segments and reset DataCurator password
input $GEMSTONE_22/upgrade/segmentorder_1xto22.gs
commit


! Read the IdentitySet containing a list of classes that the User wants us to 
! locate all instances of during conversion.

expectvalue %Boolean
run

|setOfClasses outFile outFileName nextLine|

setOfClasses := System myUserProfile resolveSymbol: #ConversionClassesToFind.

(setOfClasses == nil)
  ifTrue:[^false].

setOfClasses := setOfClasses value.

(setOfClasses isKindOf: IdentitySet)
  ifFalse:[^String withAll: 'ConversionClassesToFind expected to be anIdentitySet'].

(setOfClasses size == 0)
  ifTrue:[^false].

outFileName := String withAll: '$upgradeLogDir'.
(outFileName last == $/)
  ifFalse:[outFileName add: $/].
outFileName addAll: 'ClassesForListInstances.txt'.
outFile := GsFile openOnServer: outFileName mode: 'w'.
(outFile == nil)
  ifTrue:[^(String withAll: 'Cannot open output file ') addAll: outFileName; yourself].

setOfClasses do:[:eachClass|
  (eachClass isBehavior _and:[eachClass isMeta not]) ifTrue:[
  |theName theOop|
  theName := eachClass name asString.
  theOop := eachClass asOop asString.
  outFile nextPutAll: theName; nextPut: $|; nextPutAll: theOop; lf.
  ].
].
outFile close.
^true
%

! Fix bug 35044 - force #reclaimDeadEnabled to be true before calling reclaimAll
time
expectvalue true
run
|gcUserUg val dnr|
gcUserUg := ((AllUsers userWithId:'GcUser' ) resolveSymbol: #UserGlobals ) value.
val := gcUserUg at: #reclaimDeadEnabled otherwise: false.
val ifFalse:[
	gcUserUg at: #reclaimDeadEnabled put: true.
	System commitTransaction.
].

SystemRepository reclaimAll.

val ifFalse:[
  gcUserUg at: #reclaimDeadEnabled put: false.
  System commitTransaction.
  "commit just made another shadow page!"
  SystemRepository reclaimAll.
].
^true
%
time
abort

! stop other sessions to get down to 1 CR
expectvalue System
run
System stopAllGcSessions
%
expectvalue System
run
System stopSymbolCreationSession
%

abort

expectvalue nil
run
[System currentSessions size == 1] whileFalse:[
System sleep: 1.
System abortTransaction.].
%

expectvalue 1
run
System _commitRecordBacklog
%

! Ensure all dead objects are GONE
expectvalue 0
run
System _deadNotReclaimedCount
%

! write the upgrade bitmap files
expectvalue %Array
run
SystemRepository writeConversionFilesToDirectory: '$upgradeLogDir'
%

! calling script responsible for clean shutdown of stone
