Skip to content

Commit 03ad7d9

Browse files
committed
Add regression test for fix to unified goto program processing
This adds a regression test that checks to ensure that goto-analyser reaches the "Checking assertions" phase of it's execution. This also fails on any invariant violation.
1 parent 8e533b7 commit 03ad7d9

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
extern void free(void *__ptr) __attribute__((__nothrow__, __leaf__));
2+
struct evp_md_ctx_st {
3+
const void *digest;
4+
};
5+
struct s2n_evp_digest {
6+
struct evp_md_ctx_st *ctx;
7+
};
8+
union s2n_hash_low_level_digest {
9+
};
10+
struct s2n_hash_evp_digest {
11+
struct s2n_evp_digest evp_md5_secondary;
12+
};
13+
struct s2n_hash_state {
14+
const struct s2n_hash *hash_impl;
15+
union {
16+
union s2n_hash_low_level_digest low_level;
17+
struct s2n_hash_evp_digest high_level;
18+
} digest;
19+
};
20+
struct s2n_hash {
21+
int (*free)(struct s2n_hash_state *state);
22+
};
23+
void EVP_MD_CTX_free(struct evp_md_ctx_st *ctx) {
24+
free(ctx->digest);
25+
free(ctx);
26+
}
27+
static int s2n_evp_hash_free(struct s2n_hash_state *state) {
28+
(EVP_MD_CTX_free((state->digest.high_level.evp_md5_secondary.ctx)));
29+
return 0;
30+
}
31+
static const struct s2n_hash s2n_evp_hash = {
32+
.free = &s2n_evp_hash_free,
33+
};
34+
static int s2n_hash_set_impl(struct s2n_hash_state *state) {
35+
state->hash_impl = &s2n_evp_hash;
36+
return 0;
37+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
void s2n_hash_free_harness()
2+
{
3+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CORE
2+
test.c
3+
--verify
4+
Checking assertions
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
Invariant check failed
9+
--
10+
This test checks that after building the goto binary (see test.sh)
11+
that there is no errors that lead to invariant violations.
12+
This was created after a bug was found due to the
13+
instrument_preconditions code not correctly fixing locations and
14+
the invariant check of partial inlining detecting this location
15+
inconsistency.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
goto_cc=$1
5+
is_windows=$2
6+
7+
if [[ "${is_windows}" == "true" ]]; then
8+
${goto_cc} --export-file-local-symbols simple.c
9+
mv simple.exe simple.gb
10+
${goto_cc} --export-file-local-symbols s2n_hash_inlined.c
11+
mv s2n_hash_inlined.exe s2n_hash_inlined.gb
12+
${goto_cc} --function s2n_hash_free_harness simple.gb s2n_hash_inlined.gb
13+
mv test.exe test.gb
14+
else
15+
${goto_cc} --export-file-local-symbols simple.c -o simple.gb
16+
${goto_cc} --export-file-local-symbols s2n_hash_inlined.c -o s2n_hash_inlined.gb
17+
${goto_cc} --function s2n_hash_free_harness simple.gb s2n_hash_inlined.gb -o test.gb
18+
fi

0 commit comments

Comments
 (0)