diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-02-17 13:24:48 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-02-17 13:24:48 +0000 |
commit | 6f3a9afdda5c02dc84522fc8604addb7e5c8d7df (patch) | |
tree | 9b73d1072a2bd168ca04a7441a91d0b341ea0c0f /test/cminor/mainlists.c | |
parent | f6bdc196c093d413c900e38e894682b7b70d4483 (diff) | |
download | compcert-6f3a9afdda5c02dc84522fc8604addb7e5c8d7df.tar.gz compcert-6f3a9afdda5c02dc84522fc8604addb7e5c8d7df.zip |
Moved test harness C files here
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1251 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/cminor/mainlists.c')
-rw-r--r-- | test/cminor/mainlists.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/cminor/mainlists.c b/test/cminor/mainlists.c new file mode 100644 index 00000000..281b919f --- /dev/null +++ b/test/cminor/mainlists.c @@ -0,0 +1,35 @@ +#include <stdio.h> +#include <stddef.h> +#include <stdlib.h> + +struct cons { int hd; struct cons * tl; }; +typedef struct cons * list; + +extern list buildlist(int n); +extern list reverselist(list l); + +int checklist(int n, list l) +{ + int i; + for (i = 0; i <= n; i++) { + if (l == NULL) return 0; + if (l->hd != i) return 0; + l = l->tl; + } + return (l == NULL); +} + +int main(int argc, char ** argv) +{ + int n; + + if (argc >= 2) n = atoi(argv[1]); else n = 10; + if (checklist(n, reverselist(buildlist(n)))) { + printf("OK\n"); + return 0; + } else { + printf("Bug!\n"); + return 2; + } +} + |