From dc768f82c1072791c4d5ad86ebfb3717270b1f17 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Fri, 19 Feb 1999 05:56:39 +0000 Subject: [PATCH] test_parse.c (main): Add a call to profile_verify_node so we can test the internal rep invariants. prof_tree.c (profile_verify_node): Fix bug in profile_verify_node in the group_level test. Also make profile_verify_node check the return code when it is recursively testing the child nodes. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11189 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/profile/ChangeLog | 10 ++++++++++ src/util/profile/prof_tree.c | 9 ++++++--- src/util/profile/test_parse.c | 9 ++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index 2d764879f..db27227cc 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,13 @@ +Fri Feb 19 00:49:10 1999 Theodore Y. Ts'o + + * test_parse.c (main): Add a call to profile_verify_node so we can + test the internal rep invariants. + + * prof_tree.c (profile_verify_node): Fix bug in + profile_verify_node in the group_level test. Also make + profile_verify_node check the return code when it is + recursively testing the child nodes. + Mon Jan 25 18:44:26 1999 Theodore Y. Ts'o * prof_tree.c (profile_node_iterator): Added comments indicating diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index 499296c74..a95ce213b 100644 --- a/src/util/profile/prof_tree.c +++ b/src/util/profile/prof_tree.c @@ -109,7 +109,8 @@ errcode_t profile_verify_node(node) struct profile_node *node; { struct profile_node *p, *last; - + errcode_t retval; + CHECK_MAGIC(node); if (node->value && node->first_child) @@ -121,11 +122,13 @@ errcode_t profile_verify_node(node) return PROF_BAD_LINK_LIST; if (last && (last->next != p)) return PROF_BAD_LINK_LIST; - if (node->group_level != p->group_level+1) + if (node->group_level+1 != p->group_level) return PROF_BAD_GROUP_LVL; if (p->parent != node) return PROF_BAD_PARENT_PTR; - profile_verify_node(p); + retval = profile_verify_node(p); + if (retval) + return retval; } return 0; } diff --git a/src/util/profile/test_parse.c b/src/util/profile/test_parse.c index accd04aa9..2f00d9e81 100644 --- a/src/util/profile/test_parse.c +++ b/src/util/profile/test_parse.c @@ -33,7 +33,7 @@ int main(argc, argv) retval = profile_parse_file(f, &root); if (retval) { printf("profile_parse_file error %s\n", error_message(retval)); - return 0; + exit(1); } fclose(f); @@ -44,6 +44,13 @@ int main(argc, argv) dump_profile_to_file(root, 0, stdout); #endif + retval = profile_verify_node(root); + if (retval) { + printf("profile_verify_node reported an error: %s\n", + error_message(retval)); + exit(1); + } + profile_free_node(root); return 0; -- 2.26.2