], [ignore])
AT_CLEANUP
+
+AT_SETUP([gen-tree.awk])
+AT_DATA([tree.def],
+[[ROOT0
+ r0a, r0a_OFFSET
+ r0b, r0b_OFFSET
+ r0c
+ r0d
+ r0e, r0e_OFFSET
+ r0f
+ r0g
+ROOT1
+ r1a, r1a_OFFSET
+ r1b, r1b_OFFSET
+ r1b
+ r1e
+ r1b
+ r1c, r1c_OFFSET
+ r1d, r1d_OFFSET
+ r1e
+ r1b
+ r1e
+]])
+
+AT_CHECK([$AWK -f "$builddir/scripts/gen-tree.awk" <tree.def >tree.h])
+
+AT_DATA([test0.c],
+[[#include "tree.h"
+#include <stdio.h>
+
+struct tree { unsigned id, subtree; };
+
+static const struct tree tree0[] = {
+ ROOT0_INITIALIZER
+};
+static const struct tree tree1[] = {
+ ROOT1_INITIALIZER
+};
+
+void print_subtree(const struct tree *root, unsigned offset, int depth)
+{
+ const struct tree *node;
+
+ for (node = &root[offset]; node->id; node++) {
+ printf("%*s%s", 2*depth, "", &tree_strtab[node->id]);
+ if (node->subtree) {
+ printf(", %s_OFFSET\n", &tree_strtab[node->id]);
+ print_subtree(root, node->subtree, depth+1);
+ } else {
+ putchar('\n');
+ }
+ }
+}
+
+int main(void)
+{
+ printf("ROOT0\n");
+ print_subtree(tree0, 0, 1);
+ printf("ROOT1\n");
+ print_subtree(tree1, 0, 1);
+}
+]])
+cp tree.def expout
+AT_CHECK([$CC -o test0$EXEEXT test0.c && ./test0$EXEEXT], [0], [expout])
+
+AT_CLEANUP