Skip to content

Commit

Permalink
CHERI: adding ci tests for the new elaboration of readonly objects
Browse files Browse the repository at this point in the history
  • Loading branch information
kmemarian committed Sep 15, 2024
1 parent 56a0662 commit d218bd4
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/cheri-ci/0337-CHERI_const1.undef.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
int main(void)
{
const int xxx = 42;
int *p = (int*)&xxx;
xxx;
*p = 100; // undefined
}
10 changes: 10 additions & 0 deletions tests/cheri-ci/0338-CHERI_const2.undef.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
int aux(int *p)
{
return p?(*p = 10):10;
}

int main(void)
{
const int xxx = (aux((int*)&xxx), xxx); // the store in aux() is undefined
aux((int*)&xxx); // the store in aux() is undefined
}
10 changes: 10 additions & 0 deletions tests/cheri-ci/0339-CHERI_const3.undef.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
int aux(int *p)
{
return p?(*p = 10):10;
}

int main(void)
{
const int xxx = (aux(0), xxx);
aux((int*)&xxx); // the store in aux() is undefined
}
6 changes: 6 additions & 0 deletions tests/cheri-ci/0340-CHERI_string-literal.undef.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
int main(void)
{
char *str = "string";
str[0];
str[0] = 'S'; // undefined
}
1 change: 1 addition & 0 deletions tests/cheri-ci/expected/0337-CHERI_const1.undef.c.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Undefined {ub: "UB064_modifying_const", stderr: "", loc: "<6:3--6:11>"}
1 change: 1 addition & 0 deletions tests/cheri-ci/expected/0338-CHERI_const2.undef.c.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Undefined {ub: "UB_CHERI_InsufficientPermissions", stderr: "", loc: "<3:12--3:21>"}
1 change: 1 addition & 0 deletions tests/cheri-ci/expected/0339-CHERI_const3.undef.c.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Undefined {ub: "UB064_modifying_const", stderr: "", loc: "<3:12--3:21>"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Undefined {ub: "UB033_modifying_string_literal", stderr: "", loc: "<5:3--5:15>"}
14 changes: 14 additions & 0 deletions tests/ci/0341-misaligned_pointer_implicit_conversion.undef.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdlib.h>

void func(void *p0)
{
int **p1 = p0; // undef
}

int main(void)
{
char *p = malloc(sizeof(int*)+1);
void *p0 = (void*)(p+1);

func(p0);
}
4 changes: 4 additions & 0 deletions tests/tests-cheri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ citests=(
0332-rvalue-temporary-lifetime-pointer-zap.c
0333-shifts_non_representable.undef.c
0336-memcpy-ovelap.undef.c
0337-CHERI_const1.undef.c
0338-CHERI_const2.undef.c
0339-CHERI_const3.undef.c
0340-CHERI_string-literal.undef.c
)

# TESTS THAT ARE KNOW TO FAIL (for example .error test for which we need to improve the message)
Expand Down

0 comments on commit d218bd4

Please sign in to comment.