Adds a test suite for the hardening bonus. The following things are tested and should be handled appropriately by a student's implementation:
Missing magic constant
Sizes of constant and text pool exceed file size
For the above tests the student's implementation should return -1 for init_ijvm.
Invalid instructions (both normal and after WIDE)
Underflowing the stack
DUP, IFEQ, IFLT, ISTORE, and IRETURN on an empty stack
IADD, IAND, IOR, ISUB, SWAP, and IF_ICMPEQ on a stack with a single element
GOTO, IFEQ, IFLT, IF_ICMPEQ, LDC_W, IINC, and INVOKEVIRTUAL are only followed by one byte
GOTO, IFEQ, IFLT, IF_ICMPEQ, and INVOKEVIRTUAL branching outside the text area
LDC_W on an empty constant pool
ILOAD, ISTORE, and WIDE do not have a successive byte
INVOKEVIRTUAL's short is not a valid index into the constant pool
IRETURN on the "main" method
For the above tests the student's implementation should cause a successive call to finished() to return true. The invalid code should not cause any errors like segmentation faults, but an error message can be printed.
IADD and ISUB overflow
IADD and ISUB underflow
For the above tests the student's implementation should match the behaviour of Java. For an overflow that means that the number rolls over from 2147483647 to -2147483648 and continues the operation from there. For an underflow that means that the number rolls over from -2147483648 to 2147483647 and continues the operation from there.
Sanitizers should be run separately and should not indicate any errors.
Adds a test suite for the hardening bonus. The following things are tested and should be handled appropriately by a student's implementation:
For the above tests the student's implementation should return -1 for init_ijvm.
For the above tests the student's implementation should cause a successive call to
finished()
to returntrue
. The invalid code should not cause any errors like segmentation faults, but an error message can be printed.For the above tests the student's implementation should match the behaviour of Java. For an overflow that means that the number rolls over from 2147483647 to -2147483648 and continues the operation from there. For an underflow that means that the number rolls over from -2147483648 to 2147483647 and continues the operation from there.
Sanitizers should be run separately and should not indicate any errors.