Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/arch warning #622

Merged
merged 25 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e2f2ebf
add tests on VM versus processor architecture
demarey Apr 18, 2023
4fe5070
Merge branch 'dev' into feature/arch-warning
demarey Jun 2, 2023
98c64be
Do not raise Error when invalid VM found. Error will be raised when v…
demarey Jun 2, 2023
b65c2c8
better explanation when cannot run a VM
demarey Jun 5, 2023
c4dddf0
fix dependency
demarey Jun 6, 2023
ea16753
use 64-bit image for testing
demarey Jun 6, 2023
56566ab
add detection of supported image
demarey Jun 6, 2023
07f2d99
allow to capture error dialogs shown by the app
demarey Jun 6, 2023
7a86e2d
remove debug code
demarey Jun 6, 2023
662ab71
Fix unix platform validation and test command.
demarey Jun 8, 2023
207bcce
fix exe architecture detection on linux
demarey Jun 9, 2023
786dce3
fix condition
demarey Jun 9, 2023
f2ffb87
avoid to download VMs
demarey Jun 9, 2023
71e8b0f
cannot check exe architecture if vm path not set
demarey Jun 9, 2023
28ccd14
Add a facility to use a specific OS Platform for tests.
demarey Jun 13, 2023
e0d8b9c
Merge 71e8b0f497384b36373e1c923b5f06aa3b26d9b8
demarey Jun 13, 2023
fa22227
fis plateform parameter
demarey Jun 14, 2023
df209aa
fix test
demarey Jun 14, 2023
c4b2ba5
Merge branch 'dev' into feature/arch-warning
demarey Aug 10, 2023
74d96f5
fix test
demarey Aug 21, 2023
c391b71
Merge branch 'dev' into feature/arch-warning
demarey May 14, 2024
8eff2d5
fix tests
demarey May 17, 2024
c1e25d1
fix tests
demarey May 21, 2024
96b751f
do not rely on current image version for dev version test
demarey May 22, 2024
3f89d4b
do not hardcode the list of Pharo versions
demarey May 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/PharoLauncher-CLI-Tests/PhLCliCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ PhLCliCommandTest >> assertSuccess [
self assert: self errorString equals: ''
]

{ #category : #instance }
PhLCliCommandTest >> defaultTemplateCategoryName [

^ PhLTemplateGroupRepository new defaultTemplateCategoryName
]

{ #category : #accessing }
PhLCliCommandTest >> errorString [
^ context stdio stderr contents utf8Decoded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,19 @@ PhLImageBisectCliCommandTest >> testFirstKnownFaultyImageTakesLastBuildValueIfNo

{ #category : #tests }
PhLImageBisectCliCommandTest >> testGetPharoDevVersionWhenNoVersionSpecified [

| devTemplate |
self launcherModel
templateRepository: PhLTemplateTestRepository new.
self addTemplateCategoryNamed: self defaultTemplateCategoryName.
self addTemplateNamed: 'Pharo 9 64bit stable' inCategory: self defaultTemplateCategoryName.
devTemplate := self addTemplateNamed: 'Pharo 10 64bit (development version, latest)' inCategory: self defaultTemplateCategoryName.
devTemplate setName: devTemplate name url: 'https://files.pharo.org/image/100/latest-64.zip' asZnUrl.

context arguments: #( 'launcher' 'image' 'bisect' ).

self
assert: context command pharoVersion
equals: (SystemVersion current major + 1) asString
"Pharo Launcher is based on the latest Pharo stable but we should find a way to control template sources in a test context"
equals: '10'
]

{ #category : #tests }
Expand Down
24 changes: 24 additions & 0 deletions src/PharoLauncher-CLI-Tests/PhLImageCliCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@ PhLImageCliCommandTest >> addInputAnswer: anObject [
addAnswer: anObject
]

{ #category : #creation }
PhLImageCliCommandTest >> addTemplateCategoryNamed: aTemplateCategoryName [
| templateCategory |
templateCategory := self launcherModel templateRepository
newRemoteTemplatesGroupNamed: aTemplateCategoryName.
self launcherModel templateRepository
setGroups: {templateCategory}
]

{ #category : #creation }
PhLImageCliCommandTest >> addTemplateNamed: aName inCategory: aCategoryName [
^ self launcherModel templateRepository
createTemplateNamed: aName
inCategory: aCategoryName
]

{ #category : #creation }
PhLImageCliCommandTest >> addTemplateNamed: aName shortName: aShortName inCategory: aCategoryName [
^ self launcherModel templateRepository
createTemplateNamed: aName
shortName: aShortName
inCategory: aCategoryName
]

{ #category : #accessing }
PhLImageCliCommandTest >> imageRepository [
^ self launcherModel imageRepository
Expand Down
29 changes: 0 additions & 29 deletions src/PharoLauncher-CLI-Tests/PhLImageCreateCliCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,6 @@ PhLImageCreateCliCommandTest >> addLocalTemplateNamed: aName [

]

{ #category : #creation }
PhLImageCreateCliCommandTest >> addTemplateCategoryNamed: aTemplateCategoryName [
| templateCategory |
templateCategory := self launcherModel templateRepository
newRemoteTemplatesGroupNamed: aTemplateCategoryName.
self launcherModel templateRepository
setGroups: {templateCategory}
]

{ #category : #'instance creation' }
PhLImageCreateCliCommandTest >> addTemplateNamed: aName inCategory: aCategoryName [
^ self launcherModel templateRepository
createTemplateNamed: aName
inCategory: aCategoryName
]

{ #category : #adding }
PhLImageCreateCliCommandTest >> addTemplateNamed: aName shortName: aShortName inCategory: aCategoryName [
^ self launcherModel templateRepository
createTemplateNamed: aName
shortName: aShortName
inCategory: aCategoryName
]

{ #category : #instance }
PhLImageCreateCliCommandTest >> defaultTemplateCategoryName [
^ 'Official distributions'
]

{ #category : #accessing }
PhLImageCreateCliCommandTest >> localTemplatesGroup [
^ context templateRepository localTemplatesGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PhLImagePackageCliCommandTest >> setUp [
vmStoreBackup := PhLVirtualMachineManager vmStore.
tempVmStoreFolder := self imageRepository baseDirectory fileSystem root / 'vms'.
PhLVirtualMachineManager vmStore: tempVmStoreFolder.
vmName := '70-x86'.
vmName := '70-x64'.
(PhLVirtualMachineManager vmStore / vmName) ensureCreateDirectory.
(PhLVirtualMachineManager vmStore / vmName / 'pharo') ensureCreateFile.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ PhLImageRecreateCliCommandTest >> testCanRecreateAnImageShouldSucceed [
DiskStore
currentFileSystem: self imageRepository baseDirectory fileSystem
during: [
self deny: imageFile contents equals: 'foo'.
self deny: imageFile binaryReadStream contents equals: self testTemplateContent.
self runCommand: #('launcher' 'image' 'recreate' 'myImage').
self assertSuccess.
self assert: imageFile exists.
self assert: imageFile contents equals: 'foo'].
self assert: imageFile binaryReadStream contents equals: self testTemplateContent ].

]

Expand All @@ -41,12 +41,18 @@ PhLImageRecreateCliCommandTest >> testCanRecreateAnImageWhenNoImageNameProvidedB
DiskStore
currentFileSystem: self imageRepository baseDirectory fileSystem
during: [
self deny: imageFile contents equals: 'foo'.
self deny: imageFile binaryReadStream contents equals: self testTemplateContent.

self runCommand: #('launcher' 'image' 'recreate').

self assertSuccess.
self assert: imageFile exists.
self assert: imageFile contents equals: 'foo'].
self assert: imageFile binaryReadStream contents equals: self testTemplateContent].

]

{ #category : #accessing }
PhLImageRecreateCliCommandTest >> testTemplateContent [

^ #[102 111 111] " 'foo' in binary) "
]
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ PhLTemplatesCliCommandTest >> createOfficialTemplatesCategoryWithSomeTemplates [
self addTemplateNamed: 'Pharo 9 64bit stable' inCategory: self defaultTemplateCategoryName.
]

{ #category : #instance }
PhLTemplatesCliCommandTest >> defaultTemplateCategoryName [
^ 'Official distributions'
]

{ #category : #accessing }
PhLTemplatesCliCommandTest >> localTemplatesGroup [
^ context templateRepository localTemplatesGroup
Expand Down
5 changes: 2 additions & 3 deletions src/PharoLauncher-CLI/PhLCliCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,12 @@ PhLCliCommand >> defaultTemplate [

{ #category : #default }
PhLCliCommand >> defaultTemplateCategory [
^ self templateRepository
categoryNamed: self defaultTemplateCategoryName
^ self templateRepository defaultTemplateCategory
]

{ #category : #default }
PhLCliCommand >> defaultTemplateCategoryName [
^ 'Official distributions'
^ self templateRepository defaultTemplateCategoryName
]

{ #category : #'accessing arguments' }
Expand Down
29 changes: 29 additions & 0 deletions src/PharoLauncher-Core/MacOSXPlatform.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,36 @@ MacOSXPlatform class >> intelArchitecture [
^ 'x86_64'
]

{ #category : #'*PharoLauncher-Core' }
MacOSXPlatform >> isValid: aPhLVirtualMachine [

| executableArchitecture |
executableArchitecture := (self architectureOf: aPhLVirtualMachine executablePath)
substrings: { Character space . $, }.
executableArchitecture := executableArchitecture collect: [ :each | each trimBoth ].
(executableArchitecture includes: #executable) ifFalse: [ ^ false ].

"64 bits exe and 32-bit PhLVirtualMachine or vice-versa"
((executableArchitecture includes: '64-bit') xor: [ aPhLVirtualMachine is64bit ])
ifTrue: [ ^ false ].

(executableArchitecture includes: 'arm64')
ifTrue: [ ^ self processorArchitecture = 'arm64' ]
ifFalse: [ self processorArchitecture = 'arm64'
ifTrue: [ self warnWhenWillLaunchInTranslatedMode ] ].

^ true
]

{ #category : #'*PharoLauncher-Core' }
MacOSXPlatform >> uname [
^ PhLVmProvider osDarwin
]

{ #category : #'*PharoLauncher-Core' }
MacOSXPlatform >> warnWhenWillLaunchInTranslatedMode [

PhLTranslatedModeWarning signal


]
23 changes: 23 additions & 0 deletions src/PharoLauncher-Core/OSPlatform.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ OSPlatform class >> archX86_64 [
^ 'x86_64'
]

{ #category : #'*PharoLauncher-Core' }
OSPlatform >> architectureOf: aPathString [

"ensure file is executable and "
^ LibC resultOfCommand: 'file -b ' , aPathString
]

{ #category : #'*PharoLauncher-Core' }
OSPlatform >> canRun32bitApp [
^ true
Expand All @@ -15,6 +22,22 @@ OSPlatform >> hostArchitecture [
self subclassResponsibility
]

{ #category : #'*PharoLauncher-Core' }
OSPlatform >> isValid: aPhLVirtualMachine [

| architecture |
architecture := $, split: (self architectureOf: aPhLVirtualMachine vmBinaryFullName ).
architecture := architecture collect: [ :each | each trimBoth ].
architecture detect: [ :each | each includesSubstring: #executable] ifNone: [ ^ false ].

"64 bits exe and 32-bit PhLVirtualMachine or vice-versa"
((architecture anySatisfy: [ :each | (each includesSubstring: 'x86-64') or: [each includesSubstring: 'x86_64'] ] )
xor: [ aPhLVirtualMachine is64bit ]) ifTrue: [ ^ false ].

^ true

]

{ #category : #'*PharoLauncher-Core' }
OSPlatform >> uname [
self subclassResponsibility
Expand Down
32 changes: 28 additions & 4 deletions src/PharoLauncher-Core/PhLArchitectureError.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,48 @@ Error raised when trying to run a 32-bit image whereas the underlying Operating
Class {
#name : #PhLArchitectureError,
#superclass : #PhLLaunchError,
#instVars : [
'description',
'configuration'
],
#category : #'PharoLauncher-Core-Model'
}

{ #category : #signalling }
PhLArchitectureError class >> signalImage: anImage [
PhLArchitectureError class >> signalConfiguration: aPhLConfiguration [
^ self new
configuration: aPhLConfiguration;
signal
]

{ #category : #signalling }
PhLArchitectureError class >> signalImageOsNon32bitCompliant: anImage [
^ self new
process: nil image: anImage;
osNon32bitCompliantDescription;
signal
]

{ #category : #initialization }
PhLArchitectureError >> configuration: aPhLLaunchConfiguration [

configuration := aPhLLaunchConfiguration
]

{ #category : #accessing }
PhLArchitectureError >> longDescription [
^ ('Cannot run {1} image!' format: { image name }),
String cr,
'This image requires a 32-bit VM to run and 32-bit applications are not supported on this Operating System!'
^ description
ifNil: [ 'Cannot run VM ''{1}'' on this system!' format: { configuration vm id } ]
]

{ #category : #accessing }
PhLArchitectureError >> name [
^ 'Architecture error'
]

{ #category : #accessing }
PhLArchitectureError >> osNon32bitCompliantDescription [
description := ('Cannot run {1} image!' format: { image name }),
String cr,
'This image requires a 32-bit VM to run and 32-bit applications are not supported on this Operating System!'
]
14 changes: 10 additions & 4 deletions src/PharoLauncher-Core/PhLImage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ PhLImage class >> example [
imageFile := fsRoot / 'foo64.image'.
imageFile binaryWriteStreamDo:
[ :stream |
(ZnEndianessReadWriteStream on: stream ) nextLittleEndianNumber: 4 put: PhLVirtualMachineManager imageFormat64bits ].
(ZnEndianessReadWriteStream on: stream )
nextLittleEndianNumber: 4
put: PhLVirtualMachineManager imageFormat64bits ].
^ self location: imageFile
]

Expand All @@ -90,7 +92,9 @@ PhLImage class >> example32 [
imageFile := fsRoot / 'foo32.image'.
imageFile binaryWriteStreamDo:
[ :stream |
(ZnEndianessReadWriteStream on: stream ) nextLittleEndianNumber: 4 put: PhLVirtualMachineManager imageFormat32bits ].
(ZnEndianessReadWriteStream on: stream )
nextLittleEndianNumber: 4
put: PhLVirtualMachineManager imageFormat32bits ].
^ self location: imageFile
]

Expand Down Expand Up @@ -399,8 +403,10 @@ PhLImage >> launchWithConfiguration: aPhLLaunchConfiguration detached: shouldBeD
| architectureWarningEnabled continue |

self canBeLaunched
ifFalse: [ PhLArchitectureError signalImage: self.
^ self ].
ifFalse: [ PhLArchitectureError signalImageOsNon32bitCompliant: self. ^ self ].
aPhLLaunchConfiguration canBeLaunched
ifFalse: [ PhLArchitectureError signalConfiguration: aPhLLaunchConfiguration. ^ self ].

architectureWarningEnabled := true.
continue := true.
[ ^ self basicLaunchWithConfiguration: aPhLLaunchConfiguration detached: shouldBeDetached ]
Expand Down
8 changes: 8 additions & 0 deletions src/PharoLauncher-Core/PhLLaunchConfiguration.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ PhLLaunchConfiguration >> = anObject [
^ self name = anObject name
]

{ #category : #testing }
PhLLaunchConfiguration >> canBeLaunched [

self vm isValidAfterUpdate ifFalse: [ ^ false ].
self vm isValidForArchitecture ifFalse: [ ^ false ].
^ true
]

{ #category : #querying }
PhLLaunchConfiguration >> commandString [
^ self launchProcess commandLineString
Expand Down
10 changes: 10 additions & 0 deletions src/PharoLauncher-Core/PhLTemplateGroupRepository.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ PhLTemplateGroupRepository >> createZipArchiveFrom: anImage named: aString [
archive writeToFile: (self localTemplatesDirectory / aString , 'zip')
]

{ #category : #accessing }
PhLTemplateGroupRepository >> defaultTemplateCategory [
^ self categoryNamed: self defaultTemplateCategoryName
]

{ #category : #accessing }
PhLTemplateGroupRepository >> defaultTemplateCategoryName [
^ 'Official distributions'
]

{ #category : #action }
PhLTemplateGroupRepository >> deleteTemplate: aTemplate [
aTemplate zipArchive delete.
Expand Down
9 changes: 9 additions & 0 deletions src/PharoLauncher-Core/PhLTranslatedModeWarning.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"
Warning raised when we try to launch an image with an intel VM on an ARM architecture (mac Os).
The VM is then translaetd by Rosetta, and the image runs very slowly.
"
Class {
#name : #PhLTranslatedModeWarning,
#superclass : #Warning,
#category : #'PharoLauncher-Core-Exceptions'
}
Loading
Loading