Skip to content

Commit

Permalink
Merge pull request #47 from janvrany/pr/use-parametrized-tests
Browse files Browse the repository at this point in the history
Use parametrized tests
  • Loading branch information
janvrany authored May 22, 2024
2 parents 3de0545 + 8c23527 commit 1e47ec1
Show file tree
Hide file tree
Showing 18 changed files with 406 additions and 519 deletions.
2 changes: 2 additions & 0 deletions pharo/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ $(PROJECT).image: ../src/*/*.st
$(call pharo-load-local, $@, SmallRSP, $(SMALLRSP_DIR)/src)
$(call pharo-load-local, $@, LibUnix, $(PHARO_HACKS_DIR)/src)
$(call pharo-load-local, $@, LibCompat, $(PHARO_HACKS_DIR)/src)
$(call pharo-load-local, $@, LibCompat, $(PHARO_HACKS_DIR)/src)
$(call pharo-load-local, $@, SUnitParametrized,$(PHARO_HACKS_DIR)/src)
$(call pharo-load-local, $@, PTerm, $(PTERM_DIR))
$(call pharo-load-local, $@, LibGDBs, $(LIBGDBS_DIR)/ports/pharo/src-generated)
$(call pharo-load-local, $@, Tinyrossa, ../src)
Expand Down
7 changes: 6 additions & 1 deletion src/BaselineOfTinyrossa/BaselineOfTinyrossa.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ BaselineOfTinyrossa >> baseline: spec [
spec baseline: 'LibUnix' with: [
spec repository: 'github://janvrany/pharo-hacks'.
].


spec baseline: 'SUnitParametrized' with: [
spec repository: 'github://janvrany/pharo-hacks'.
].

spec baseline: 'Roassal3' with: [
spec repository: 'github://ObjectProfile/Roassal3:v0.9.2'
].
Expand All @@ -38,6 +42,7 @@ BaselineOfTinyrossa >> baseline: spec [
spec requires: 'ArchC'
];
package: #'Tinyrossa-Tests' with: [
spec requires: 'SUnitParametrized'.
spec requires: 'SmallRSP'.
];
package: #'Tinyrossa-RISCV' with: [
Expand Down
82 changes: 41 additions & 41 deletions src/Tinyrossa-POWER/TRPPC64Registers.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,56 +54,56 @@ TRPPC64Registers class >> initialize [
| gprs ccrs |

gprs := AcProcessorDescriptions powerpc64 maps at: 'reg'.
gr0 := TRRealRegister value: (gprs lookup: '0') kind: GPR.
gr1 := TRRealRegister value: (gprs lookup: '1') kind: GPR.
gr2 := TRRealRegister value: (gprs lookup: '2') kind: GPR.
gr3 := TRRealRegister value: (gprs lookup: '3') kind: GPR.
gr4 := TRRealRegister value: (gprs lookup: '4') kind: GPR.
gr5 := TRRealRegister value: (gprs lookup: '5') kind: GPR.
gr6 := TRRealRegister value: (gprs lookup: '6') kind: GPR.
gr7 := TRRealRegister value: (gprs lookup: '7') kind: GPR.
gr8 := TRRealRegister value: (gprs lookup: '8') kind: GPR.
gr9 := TRRealRegister value: (gprs lookup: '9') kind: GPR.
gr10 := TRRealRegister value: (gprs lookup: '10') kind: GPR.
gr11 := TRRealRegister value: (gprs lookup: '11') kind: GPR.
gr12 := TRRealRegister value: (gprs lookup: '12') kind: GPR.
gr13 := TRRealRegister value: (gprs lookup: '13') kind: GPR.
gr14 := TRRealRegister value: (gprs lookup: '14') kind: GPR.
gr15 := TRRealRegister value: (gprs lookup: '15') kind: GPR.
gr16 := TRRealRegister value: (gprs lookup: '16') kind: GPR.
gr17 := TRRealRegister value: (gprs lookup: '17') kind: GPR.
gr18 := TRRealRegister value: (gprs lookup: '18') kind: GPR.
gr19 := TRRealRegister value: (gprs lookup: '19') kind: GPR.
gr20 := TRRealRegister value: (gprs lookup: '20') kind: GPR.
gr21 := TRRealRegister value: (gprs lookup: '21') kind: GPR.
gr22 := TRRealRegister value: (gprs lookup: '22') kind: GPR.
gr23 := TRRealRegister value: (gprs lookup: '23') kind: GPR.
gr24 := TRRealRegister value: (gprs lookup: '24') kind: GPR.
gr25 := TRRealRegister value: (gprs lookup: '25') kind: GPR.
gr26 := TRRealRegister value: (gprs lookup: '26') kind: GPR.
gr27 := TRRealRegister value: (gprs lookup: '27') kind: GPR.
gr28 := TRRealRegister value: (gprs lookup: '28') kind: GPR.
gr29 := TRRealRegister value: (gprs lookup: '29') kind: GPR.
gr30 := TRRealRegister value: (gprs lookup: '30') kind: GPR.
gr31 := TRRealRegister value: (gprs lookup: '31') kind: GPR.
gr0 := TRPPCRegister value: (gprs lookup: '0') kind: GPR.
gr1 := TRPPCRegister value: (gprs lookup: '1') kind: GPR.
gr2 := TRPPCRegister value: (gprs lookup: '2') kind: GPR.
gr3 := TRPPCRegister value: (gprs lookup: '3') kind: GPR.
gr4 := TRPPCRegister value: (gprs lookup: '4') kind: GPR.
gr5 := TRPPCRegister value: (gprs lookup: '5') kind: GPR.
gr6 := TRPPCRegister value: (gprs lookup: '6') kind: GPR.
gr7 := TRPPCRegister value: (gprs lookup: '7') kind: GPR.
gr8 := TRPPCRegister value: (gprs lookup: '8') kind: GPR.
gr9 := TRPPCRegister value: (gprs lookup: '9') kind: GPR.
gr10 := TRPPCRegister value: (gprs lookup: '10') kind: GPR.
gr11 := TRPPCRegister value: (gprs lookup: '11') kind: GPR.
gr12 := TRPPCRegister value: (gprs lookup: '12') kind: GPR.
gr13 := TRPPCRegister value: (gprs lookup: '13') kind: GPR.
gr14 := TRPPCRegister value: (gprs lookup: '14') kind: GPR.
gr15 := TRPPCRegister value: (gprs lookup: '15') kind: GPR.
gr16 := TRPPCRegister value: (gprs lookup: '16') kind: GPR.
gr17 := TRPPCRegister value: (gprs lookup: '17') kind: GPR.
gr18 := TRPPCRegister value: (gprs lookup: '18') kind: GPR.
gr19 := TRPPCRegister value: (gprs lookup: '19') kind: GPR.
gr20 := TRPPCRegister value: (gprs lookup: '20') kind: GPR.
gr21 := TRPPCRegister value: (gprs lookup: '21') kind: GPR.
gr22 := TRPPCRegister value: (gprs lookup: '22') kind: GPR.
gr23 := TRPPCRegister value: (gprs lookup: '23') kind: GPR.
gr24 := TRPPCRegister value: (gprs lookup: '24') kind: GPR.
gr25 := TRPPCRegister value: (gprs lookup: '25') kind: GPR.
gr26 := TRPPCRegister value: (gprs lookup: '26') kind: GPR.
gr27 := TRPPCRegister value: (gprs lookup: '27') kind: GPR.
gr28 := TRPPCRegister value: (gprs lookup: '28') kind: GPR.
gr29 := TRPPCRegister value: (gprs lookup: '29') kind: GPR.
gr30 := TRPPCRegister value: (gprs lookup: '30') kind: GPR.
gr31 := TRPPCRegister value: (gprs lookup: '31') kind: GPR.

ccrs := AcProcessorDescriptions powerpc64 maps at: 'ccr'.
cr0 := TRRealRegister value: (ccrs lookup: 'cr0') kind: CCR.
cr1 := TRRealRegister value: (ccrs lookup: 'cr1') kind: CCR.
cr2 := TRRealRegister value: (ccrs lookup: 'cr2') kind: CCR.
cr3 := TRRealRegister value: (ccrs lookup: 'cr3') kind: CCR.
cr4 := TRRealRegister value: (ccrs lookup: 'cr4') kind: CCR.
cr5 := TRRealRegister value: (ccrs lookup: 'cr5') kind: CCR.
cr6 := TRRealRegister value: (ccrs lookup: 'cr6') kind: CCR.
cr7 := TRRealRegister value: (ccrs lookup: 'cr7') kind: CCR.
cr0 := TRPPCRegister value: (ccrs lookup: 'cr0') kind: CCR.
cr1 := TRPPCRegister value: (ccrs lookup: 'cr1') kind: CCR.
cr2 := TRPPCRegister value: (ccrs lookup: 'cr2') kind: CCR.
cr3 := TRPPCRegister value: (ccrs lookup: 'cr3') kind: CCR.
cr4 := TRPPCRegister value: (ccrs lookup: 'cr4') kind: CCR.
cr5 := TRPPCRegister value: (ccrs lookup: 'cr5') kind: CCR.
cr6 := TRPPCRegister value: (ccrs lookup: 'cr6') kind: CCR.
cr7 := TRPPCRegister value: (ccrs lookup: 'cr7') kind: CCR.


"
String streamContents: [ :s |
self bindingsDo: [ :binding |
(binding key startsWith:'gr') ifTrue: [
s nextPutAll: ' '; nextPutAll: binding key;
nextPutAll: ' := TRRealRegister value: (gprs lookup: '; nextPutAll: (binding key asString copyFrom:3) storeString;
nextPutAll: ' := TRPPCRegister value: (gprs lookup: '; nextPutAll: (binding key asString copyFrom:3) storeString;
nextPutAll: ') kind: GPR.'; cr.
]
].
Expand Down
22 changes: 22 additions & 0 deletions src/Tinyrossa-POWER/TRPPCRegister.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Class {
#name : #TRPPCRegister,
#superclass : #TRRealRegister,
#pools : [
'TRPPC64RegisterKinds'
],
#category : #'Tinyrossa-POWER-Codegen'
}

{ #category : #accessing }
TRPPCRegister >> name [
kind == GPR ifTrue: [
^ 'gr', value name
].
kind == FPR ifTrue: [
^ 'fp', value name
].
kind == CCR ifTrue: [
^ 'cr', value name
].
^ super name
]
212 changes: 3 additions & 209 deletions src/Tinyrossa-Tests-POWER/TRPPC64CompilationTests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,213 +4,7 @@ Class {
#category : #'Tinyrossa-Tests-POWER'
}

{ #category : #running }
TRPPC64CompilationTests >> setUp [
self setUpForTarget: TRPPC64Linux default
]

{ #category : #tests }
TRPPC64CompilationTests >> test01_bytecode_abs [
| debugger |

super test01_bytecode_abs.
"
VDBDebuggerAp
"
debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
debugger setRegister: 'r4' to: -12.

"
VDBDebuggerApplication openFor: debugger
"

debugger c.
self assert: (debugger getRegister: 'r4') equals: -12 abs.
]

{ #category : #tests }
TRPPC64CompilationTests >> test02_iconst_n [
| debugger |

super test02_iconst_n.
debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
"
VDBDebuggerApplication openFor: debugger
"
debugger c.
self assert: (debugger getRegister: 'r4') equals: -16r7FEDCBA9.
]

{ #category : #tests }
TRPPC64CompilationTests >> test02_iconst_p [
| debugger |

super test02_iconst_p.
debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
"
VDBDebuggerApplication openFor: debugger
"
debugger c.
self assert: (debugger getRegister: 'r4') equals: 16r7FEDCBA9.
]

{ #category : #tests }
TRPPC64CompilationTests >> test03_lconst_n [
| debugger |

self skip: 'Skipped since #loadConstant64:into: is not implemented for POWER'.

super test03_lconst_n.
debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
"
VDBDebuggerApplication openFor: debugger
"
debugger c.
self assert: (debugger getRegister: 'r4') hex equals: '-7AFEAFFECAFEAFFE'.
]

{ #category : #tests }
TRPPC64CompilationTests >> test03_lconst_p [
| debugger |

self skip: 'Skipped since #loadConstant64:into: is not implemented for POWER'.

super test03_lconst_p.
debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
"
VDBDebuggerApplication openFor: debugger
"
debugger c.
self assert: (debugger getRegister: 'r4') equals: 16r7AFEAFFECAFEAFFE.
]

{ #category : #'tests - examples' }
TRPPC64CompilationTests >> test_example01_meaningOfLife [
| debugger |

TRCompilationExamples new
compilation: compilation;
example01_meaningOfLife.

debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
debugger c.
self assert: (debugger getRegister: 'r4') equals: 42.
]

{ #category : #'tests - examples' }
TRPPC64CompilationTests >> test_example03_signum [
| debugger |

TRCompilationExamples new
compilation: compilation;
example03_signum.

debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
debugger setRegister: 'r4' to: 0.
debugger c.
self assert: (debugger getRegister: 'r4') equals: 0.
]

{ #category : #'tests - examples' }
TRPPC64CompilationTests >> test_example04_factorial_i [
| debugger |

TRCompilationExamples new
compilation: compilation;
example04_factorial_i.

debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
debugger setRegister: 'r4' to: 5.
debugger c.
self assert: (debugger getRegister: 'r4') equals: 5 factorial.
]

{ #category : #'tests - examples' }
TRPPC64CompilationTests >> test_example08_bytecode_compiler [
| debugger |

TRCompilationExamples new
compilation: compilation;
example08_bytecode_compiler.
"
VDBDebuggerAp
"
debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
debugger setRegister: 'r4' to: 6.

"
VDBDebuggerApplication openFor: debugger
"

debugger c.
self assert: (debugger getRegister: 'r4') equals: 6 factorial.
]

{ #category : #'tests - examples' }
TRPPC64CompilationTests >> test_example09_signum_2 [
| debugger |

TRCompilationExamples new
compilation: compilation;
example09_signum_2.

debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
debugger setRegister: 'r4' to: 0.
debugger c.
self assert: (debugger getRegister: 'r4') equals: 0.
]

{ #category : #'tests - examples' }
TRPPC64CompilationTests >> test_example15_add_with_overflow_check [
| debugger |

(TRPPC64CodeEvaluator methodDictionary at: #evaluate_overflowchk: ifAbsent:[nil]) isNil ifTrue: [
self skip: 'Skipped since #evaluate_overflowchk: is not implemented for POWER'
].

TRCompilationExamples new
compilation: compilation;
example15_add_with_overflow_check.

debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
debugger setRegister: 'r4' to: 0x7FFFFFFE.
debugger setRegister: 'r5' to: 2.
debugger c.
self assert: (debugger getRegister: 'gr4') equals: 0.
]

{ #category : #'tests - examples' }
TRPPC64CompilationTests >> test_example16_factorial_i_with_overflow [
| debugger |

(TRPPC64CodeEvaluator methodDictionary at: #evaluate_overflowchk: ifAbsent:[nil]) isNil ifTrue: [
self skip: 'Skipped since #evaluate_overflowchk: is not implemented for POWER'
].

TRCompilationExamples new
compilation: compilation;
example16_factorial_i_with_overflow.

debugger := shell debugger.
debugger memoryAt: shell nzone put: compilation codeBuffer bytes.
debugger setRegister: 'r4' to: 13.
debugger c.
self assert: (debugger getRegister: 'r4') equals: -1.


"
13 factorial > 0x7FFFFFFF
22 factorial > 0x7FFFFFFFFFFFFFFF
"
{ #category : #accessing }
TRPPC64CompilationTests >> target [
^ TRPPC64Linux default
]
21 changes: 21 additions & 0 deletions src/Tinyrossa-Tests-POWER/TRPPC64PSABILinkage.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Extension { #name : #TRPPC64PSABILinkage }

{ #category : #'*Tinyrossa-Tests-POWER' }
TRPPC64PSABILinkage >> parameterRegisters: kind [
"Return (ordered) list of parameter registers of given kind.
Note, that this method is used by tests only, compiler
does not use it."

^ self parameterRegisters select: [:r | r kind = kind ]
]

{ #category : #'*Tinyrossa-Tests-POWER' }
TRPPC64PSABILinkage >> returnRegisters: kind [
"Return (ordered) list of return registers of given kind.
Note, that this method is used by tests only, compiler
does not use it."

^ { gr4 } select: [:r | r kind = kind ]
]
Loading

0 comments on commit 1e47ec1

Please sign in to comment.