Pharo test defects

NA-platform-32bit

State
Not applicable
Defect in
none: tests for a 32-bit VM
Tests
5
Fix
none
Upstream repository
pharo-project/pharo

Record

All five tests start with a guard that skips unless Smalltalk vm wordSize = 4. They exist only for a 32-bit VM. This machine runs a 64-bit VM, and no 32-bit VM can run on macOS 27 arm64. The guard is correct and the tests cannot check anything here. I made no fix and wrote no fix file.

Test Defect in State Cause
IntegerTest>>testCreationFromBytes1 none-not-applicable not applicable Guard is Smalltalk vm wordSize = 4 ifFalse: [^self skip]. Measured with evalfile.sh on both VMs: wordSize=8, SmallInteger maxVal=1152921504606846975 (2^60-1). The test asserts that SmallInteger maxVal printStringHex has size 8 (a 32-bit value), so it cannot hold on a 64-bit VM. There is no 64-bit sibling of this test in IntegerTest; its only selectors with FromBytes are the three 32-bit ones.
IntegerTest>>testCreationFromBytes2 none-not-applicable not applicable Same guard (wordSize = 4), same measured value wordSize=8 on both VMs. The test builds the 8-hex-digit string of SmallInteger maxVal + 1 and asserts the result is not a SmallInteger. That is a 32-bit property: on 64-bit, 2^60 is a LargePositiveInteger with a 16-digit hex string.
IntegerTest>>testCreationFromBytes3 none-not-applicable not applicable Same guard (wordSize = 4), same measured value wordSize=8 on both VMs. The test asserts an 8-hex-digit string for SmallInteger maxVal - 1, which only holds on 32-bit.
FFIExternalStructurePlatformTest>>testStructureHasCorrectOffsets32bits none-not-applicable not applicable Guard is self is32bit ifFalse: [^self skip], and is32bit is Smalltalk vm is32bit, i.e. wordSize = 4. Measured on both VMs: is32bit=false, is64bit=true. This test is one of a pair. Its 64-bit sibling testStructureHasCorrectOffsets64bits runs the same check with expected OFFSET_POINTER 9 and PASSES on both VMs.
FFIExternalStructurePlatformTest>>testStructureHasCorrectSize32bits none-not-applicable not applicable Same is32bit guard, is32bit=false on both VMs. Its 64-bit sibling testStructureHasCorrectSize64bits expects size 16 and PASSES on both VMs.

Regression check: No fix was made, so there is nothing to regress. I ran FFIExternalStructurePlatformTest on our VM and on Cog: both give 2 PASS (the 64-bit siblings) and 2 SKIP (the 32-bit tests). I did not run IntegerTest.

Open points: None. A 32-bit VM cannot run on macOS 27 arm64, so these five tests will always skip here.

Upstream note: No upstream change proposed. One observation, not tested and not part of this cluster: Integer class>>byte1:byte2:byte3:byte4: hard-codes the 32-bit SmallInteger range (byte4 < 16r40). On a 64-bit image, a byte4 of 16r40 or more gives a 4-byte LargePositiveInteger below 2^60, which is not normalised to a SmallInteger. I did not run any code to confirm this.

Results

Last full sweeps of 2026-11-17: iospharo (sweep14-new14) and stock Cog with the Cog changes (sweepcogp14-new10), with all image fixes. "Before" is the state of the test before the repairs. The Stock Cog column has a value only where the record measured stock Cog: "PASS 3 of 3 (repair run)" is the check of each repair on stock Cog v12.0.6 with the fix entry; "-" is not measured separately.

TestBeforeStateiospharo VMPatched CogStock Cog
FFIExternalStructurePlatformTest>>testStructureHasCorrectOffsets32bitsSKIPnot applicableSKIPSKIP-
FFIExternalStructurePlatformTest>>testStructureHasCorrectSize32bitsSKIPnot applicableSKIPSKIP-
IntegerTest>>testCreationFromBytes1SKIPnot applicableSKIPSKIP-
IntegerTest>>testCreationFromBytes2SKIPnot applicableSKIPSKIP-
IntegerTest>>testCreationFromBytes3SKIPnot applicableSKIPSKIP-

Test

Run the tests in a Pharo 14 image on macOS arm64: they skip (the fixtures and the platform tests skip by design).

"Run in a Playground of a Pharo 14 image (Do it and print each line)."
((FFIExternalStructurePlatformTest selector: #testStructureHasCorrectOffsets32bits) run) printString.
((FFIExternalStructurePlatformTest selector: #testStructureHasCorrectSize32bits) run) printString.
((IntegerTest selector: #testCreationFromBytes1) run) printString.
((IntegerTest selector: #testCreationFromBytes2) run) printString.
((IntegerTest selector: #testCreationFromBytes3) run) printString.

Source of the tests before the fix

FFIExternalStructurePlatformTest>>testStructureHasCorrectOffsets32bits before the fix (Pharo 14 build 791)
testStructureHasCorrectOffsets32bits
	self is32bit ifFalse: [ ^ self skip ].

	FFITestStructureByPlatform compiledSpec. "Ensure fields are initialized"
	self assert: (FFITestStructureByPlatform readClassVariableNamed: #OFFSET_LONG) equals: 1.
	self assert: (FFITestStructureByPlatform readClassVariableNamed: #OFFSET_POINTER) equals: 5
FFIExternalStructurePlatformTest>>testStructureHasCorrectSize32bits before the fix (Pharo 14 build 791)
testStructureHasCorrectSize32bits
	self is32bit ifFalse: [ ^ self skip ].

	self
		assert: (FFIExternalType sizeOf: FFITestStructureByPlatform)
		equals: 8
IntegerTest>>testCreationFromBytes1 before the fix (Pharo 14 build 791)
testCreationFromBytes1
	"It is illegal for a LargeInteger to be less than SmallInteger maxVal. Here we test that Integer>>byte!byte2:byte3:byte4:
	 reconstructs SmallInteger maxVal as an instance of SmallInteger."

	| maxSmallInt hexString byte1 byte2 byte3 byte4 builtInteger |
	Smalltalk vm wordSize = 4 ifFalse: [ ^ self skip ].
	maxSmallInt := SmallInteger maxVal.
	hexString := maxSmallInt printStringHex.
	self assert: hexString size equals: 8.
	byte4 := Number readFrom: (hexString copyFrom: 1 to: 2) base: 16.
	byte3 := Number readFrom: (hexString copyFrom: 3 to: 4) base: 16.
	byte2 := Number readFrom: (hexString copyFrom: 5 to: 6) base: 16.
	byte1 := Number readFrom: (hexString copyFrom: 7 to: 8) base: 16.
	builtInteger := Integer byte1: byte1 byte2: byte2 byte3: byte3 byte4: byte4.
	self assert: builtInteger equals: maxSmallInt.
	self assert: builtInteger class equals: SmallInteger
IntegerTest>>testCreationFromBytes2 before the fix (Pharo 14 build 791)
testCreationFromBytes2
	"It is illegal for a LargeInteger to be less than SmallInteger maxVal. Here we test that Integer>>byte!byte2:byte3:byte4:
	 reconstructs (SmallInteger maxVal + 1) as an instance of LargePositiveInteger."

	| maxSmallInt hexString byte1 byte2 byte3 byte4 builtInteger |
	Smalltalk vm wordSize = 4 ifFalse: [ ^ self skip ].
	maxSmallInt := SmallInteger maxVal.
	hexString := (maxSmallInt + 1) printStringHex.
	self assert: hexString size equals: 8.
	byte4 := Number readFrom: (hexString copyFrom: 1 to: 2) base: 16.
	byte3 := Number readFrom: (hexString copyFrom: 3 to: 4) base: 16.
	byte2 := Number readFrom: (hexString copyFrom: 5 to: 6) base: 16.
	byte1 := Number readFrom: (hexString copyFrom: 7 to: 8) base: 16.
	builtInteger := Integer
		byte1: byte1
		byte2: byte2
		byte3: byte3
		byte4: byte4.
	self assert: builtInteger equals: maxSmallInt + 1.
	self deny: builtInteger class equals: SmallInteger
IntegerTest>>testCreationFromBytes3 before the fix (Pharo 14 build 791)
testCreationFromBytes3
	"It is illegal for a LargeInteger to be less than SmallInteger maxVal. Here we test that Integer>>byte!byte2:byte3:byte4:
	 reconstructs (SmallInteger maxVal - 1) as an instance of SmallInteger."

	| maxSmallInt hexString byte1 byte2 byte3 byte4 builtInteger |
	Smalltalk vm wordSize = 4 ifFalse: [ ^ self skip ].
	maxSmallInt := SmallInteger maxVal.
	hexString := (maxSmallInt - 1) printStringHex.
	self assert: hexString size equals: 8.
	byte4 := Number readFrom: (hexString copyFrom: 1 to: 2) base: 16.
	byte3 := Number readFrom: (hexString copyFrom: 3 to: 4) base: 16.
	byte2 := Number readFrom: (hexString copyFrom: 5 to: 6) base: 16.
	byte1 := Number readFrom: (hexString copyFrom: 7 to: 8) base: 16.
	builtInteger := Integer byte1: byte1 byte2: byte2 byte3: byte3 byte4: byte4.
	self assert: builtInteger equals: (maxSmallInt - 1).
	self assert: builtInteger class equals: SmallInteger

Fix

No fix: the tests cannot apply on this machine (proof in the record above).

State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.