labs/lab-05: Fix improper testing of 128 bit sum in sum-array subtask#164
Open
AndreiDurlea wants to merge 3 commits intocs-pub-ro:mainfrom
Open
labs/lab-05: Fix improper testing of 128 bit sum in sum-array subtask#164AndreiDurlea wants to merge 3 commits intocs-pub-ro:mainfrom
AndreiDurlea wants to merge 3 commits intocs-pub-ro:mainfrom
Conversation
Author
|
@rarescazan30 @teodutu can you review this when you're free? |
teodutu
approved these changes
Mar 29, 2026
teodutu
left a comment
There was a problem hiding this comment.
Thanks @AndreiDurlea, nice catch. Before I merge this, fix the checkpatch errors [1]: add a commit description and a signed-off line.
Changed a int comparison to a string comparison in test.sh in order to accomodate >64-bit addition Signed-off-by: Durlea Andrei<andrei.durlea@stud.acs.upb.ro>
…DurleaEX/hardware-software-interface into andreidurlea-lab-05-fixes
Author
|
*Fixed the commit description |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix improper testing of 128 bit sum in sum-array subtask
This fixes #165
TL;DR
I found a test in
sum-arrayof HSI lab-05 which did passed my improper 128-bit addition code with full marks. Fixed it hereProblem description
In
labs/lab-05/tasks/sum-array, thetest.shchecker expects the last subtask (128-bit addition) to result in0x1565ddbe509d3ffe8, which is a 65-bit value.The test used bash arithmetic evaluation with the
-eqoperator:Because bash evaluates arithmetic as 64-bit signed integers,
$((0x1565ddbe509d3ffe8))removes the top bit and compares against the lower 64-bits, making any logic for 128-bit addition redundant.If a student's assembly code incorrectly computes the sum by simply ignoring the carry for the 128-bit addition and prints the lower 64-bits in decimal, they still get full marks.
Proof
Given my lazy solution
This will produce
128-bit addition example: 6223372036854775288. Because6223372036854775288 -eq 6223372036854775288within the bounds of-eq, the bash check returnedtruesuccessfully.Fix
Replaced the numerical comparison
-eqwith an exact string comparison==intests/test.sh.