-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from akgrant43/Issue233
Limit the gloablSessionID (which is signed 64 bits) to 31 bits
- Loading branch information
Showing
3 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Class { | ||
#name : #VMSessionIdTest, | ||
#superclass : #VMInterpreterTests, | ||
#category : #'VMMakerTests-InterpreterTests' | ||
} | ||
|
||
{ #category : #tests } | ||
VMSessionIdTest >> testGlobalSessionID [ | ||
"The globalSessionID is stored as a 64 bit number, but for compatibility with older plugins, is restricted to postive signed 32 bit values" | ||
| vm predicted diff | | ||
|
||
"The globalSessionID is the Unix time at startup + startMicroseconds. | ||
The simulator allows startMicroseconds to be set, so we can force the value to have the top bit set in a 32 bit signed integer" | ||
vm := StackInterpreterSimulator newWithOptions: { | ||
#ObjectMemory -> #Spur64BitMemoryManager. | ||
#startMicroseconds -> 16r80000000. } asDictionary. | ||
vm initializeGlobalSessionID. | ||
|
||
"Check that startMicroseconds is the expected value" | ||
self assert: vm ioUTCStartMicroseconds equals: 16r80000000. | ||
"Check that the globalSessionID is close to what we expect (allowing for a generous execution time" | ||
predicted := DateAndTime now asUnixTime + (vm ioUTCMicroseconds // 1000). | ||
diff := (predicted - vm getThisSessionID) abs. | ||
self assert: diff < 180. | ||
|
||
"Ensure that bit 32 isn't set" | ||
self assert: vm getThisSessionID < 16r80000000. | ||
] |