Skip to content

Commit 6e6c6d6

Browse files
committed
Assert stack alignment in test callbacks.
1 parent d66de64 commit 6e6c6d6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tests/test.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <stdint.h>
88

99

10+
#define assert_align(p) assert((intptr_t)(p) == STACKMAN_SP_ALIGN(p))
11+
1012
/* simple test ithout modifying stack pointers.
1113
* test that the callback is called wiht valid
1214
* stackpoiners and the stage member in the
@@ -83,6 +85,7 @@ void restore_stack(void *sp, void *buf, size_t size)
8385

8486
void *jmp_cb(void* context, int opcode, void *sp)
8587
{
88+
assert_align(sp);
8689
jmp *c = (jmp*)context;
8790
c->log[c->counter++] = c->val;
8891
if (c->val == 0) {
@@ -191,6 +194,7 @@ void test_03(void *stack_marker)
191194
void *test_04_cb(void* context, int _opcode, void *old_sp)
192195
{
193196

197+
assert_align(old_sp);
194198
ctxt01 *c = (ctxt01*)context;
195199
stackman_op_t opcode = (stackman_op_t)_opcode;
196200
assert(opcode == STACKMAN_OP_CALL || opcode == 100);

0 commit comments

Comments
 (0)