Skip to content

Conversation

@midnightveil
Copy link
Contributor

Commit 1:

This would previously fail at runtime, but we can fail the build
instead and catch this earlier.

In file included from /src/helpers.h:13,
                 from /src/tests/ipc.c:13:
/projects/sel4test/apps/sel4test-tests/src/tests/ipc.c:
  In function ‘test_ipc_pair’:
/projects/seL4_libs/libsel4test/include/sel4test/test.h:243:10:
  error: static assertion failed: "sizeof(res) does not match
         sizeof(SUCCESS), use of test_eq incorrect"

  243 |          _Static_assert(sizeof(_a) == sizeof(_b), \
      |          ^~~~~~~~~~~~~~

/projects/seL4_libs/libsel4test/include/sel4test/test.h:270:24:
  note: in expansion of macro ‘test_op’

  270 | #define test_eq(a, b)  test_op(a, b, ==)
      |                        ^~~~~~~

/projects/sel4test/apps/sel4test-tests/src/tests/ipc.c:347:25:
  note: in expansion of macro ‘test_eq’

  347 |                         test_eq(res, SUCCESS);
      |                         ^~~~~~~

Commit 2:

On arm-none-elf-eabi-gcc, -fshort-enums is on by default and
is compatible with unsigned char (but not signed char) so we
need to add support for this to the test_op macros.

Also, _test_abort() when these type failures happen so that the
failure is more obviously an issue with the compiler/test setup,
not the tests themselves.

Test with: seL4/sel4test#145

This would previously fail at runtime, but we can fail the build
instead and catch this earlier.

In file included from /src/helpers.h:13,
                 from /src/tests/ipc.c:13:
/projects/sel4test/apps/sel4test-tests/src/tests/ipc.c:
  In function ‘test_ipc_pair’:
/projects/seL4_libs/libsel4test/include/sel4test/test.h:243:10:
  error: static assertion failed: "sizeof(res) does not match
         sizeof(SUCCESS), use of test_eq incorrect"

  243 |          _Static_assert(sizeof(_a) == sizeof(_b), \
      |          ^~~~~~~~~~~~~~

/projects/seL4_libs/libsel4test/include/sel4test/test.h:270:24:
  note: in expansion of macro ‘test_op’

  270 | #define test_eq(a, b)  test_op(a, b, ==)
      |                        ^~~~~~~

/projects/sel4test/apps/sel4test-tests/src/tests/ipc.c:347:25:
  note: in expansion of macro ‘test_eq’

  347 |                         test_eq(res, SUCCESS);
      |                         ^~~~~~~

Signed-off-by: julia <git.ts@trainwit.ch>
On arm-none-elf-eabi-gcc, -fshort-enums is on by default and
is compatible with unsigned char (but not *signed* char) so we
need to add support for this to the test_op macros.

Also, _test_abort() when these type failures happen so that the
failure is more obviously an issue with the compiler/test setup,
not the tests themselves.

Signed-off-by: julia <git.ts@trainwit.ch>
Copy link
Member

@lsf37 lsf37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. 👍

@lsf37 lsf37 merged commit 2580739 into seL4:master Jul 23, 2025
17 checks passed
@midnightveil midnightveil deleted the short-enums-fix branch July 23, 2025 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants