Added new test program + changes to make system. Tests recusive persisitifying
updates.
This commit is contained in:
parent
a7b1b70f74
commit
1627d00635
2 changed files with 79 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
noinst_PROGRAMS = test-list test-multilist
|
noinst_PROGRAMS = test-list test-multilist test-list2
|
||||||
LDADD = $(top_builddir)/src/pobj/libpobj.a $(top_builddir)/src/lladd/liblladd.a \
|
LDADD = $(top_builddir)/src/pobj/libpobj.a $(top_builddir)/src/lladd/liblladd.a \
|
||||||
$(top_builddir)/src/pbl/libpbl.a $(top_builddir)/src/libdfa/librw.a
|
$(top_builddir)/src/pbl/libpbl.a $(top_builddir)/src/libdfa/librw.a
|
||||||
CLEANFILES = storefile.txt logfile.txt blob0_file.txt blob1_file.txt
|
CLEANFILES = storefile.txt logfile.txt blob0_file.txt blob1_file.txt
|
||||||
|
|
78
test/pobj/test-list2.c
Normal file
78
test/pobj/test-list2.c
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <pobj/pobj.h>
|
||||||
|
|
||||||
|
|
||||||
|
struct data {
|
||||||
|
int val;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct item {
|
||||||
|
int val;
|
||||||
|
struct data *data;
|
||||||
|
struct item *next;
|
||||||
|
int dummy[45];
|
||||||
|
};
|
||||||
|
int item_ref_fields[] = {
|
||||||
|
member_offset(struct item, data),
|
||||||
|
member_offset(struct item, next),
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
static struct item *list = NULL;
|
||||||
|
struct data *data;
|
||||||
|
struct item *tmp, *next;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
switch (pobj_init (NULL, NULL)) {
|
||||||
|
case 0:
|
||||||
|
printf ("first-time init\n");
|
||||||
|
/* Build list. */
|
||||||
|
next = NULL;
|
||||||
|
for (i = 0; i < 15; i++) {
|
||||||
|
tmp = (struct item *) pobj_malloc_transient (sizeof (struct item));
|
||||||
|
data = (struct data *) pobj_malloc_transient (sizeof (struct data));
|
||||||
|
if (! (tmp && data)) {
|
||||||
|
printf ("allocation error\n");
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
pobj_ref_typify (tmp, item_ref_fields);
|
||||||
|
|
||||||
|
data->val = -i;
|
||||||
|
tmp->val = i;
|
||||||
|
tmp->data = data;
|
||||||
|
tmp->next = next;
|
||||||
|
|
||||||
|
next = tmp;
|
||||||
|
}
|
||||||
|
pobj_update_recursive (tmp, 1);
|
||||||
|
pobj_static_set_ref (&list, tmp);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
printf ("subsequent init\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case -1:
|
||||||
|
printf ("init error\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf ("unknown return value\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print list. */
|
||||||
|
printf ("printing list...\n");
|
||||||
|
for (tmp = list; tmp; tmp = tmp->next)
|
||||||
|
printf ("%p: val=%d next=%p data=%p data->val=%d\n",
|
||||||
|
(void *) tmp, tmp->val, (void *) tmp->next,
|
||||||
|
(void *) tmp->data, (tmp->data ? tmp->data->val : 0));
|
||||||
|
printf ("...done\n");
|
||||||
|
|
||||||
|
pobj_shutdown ();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue