From: Ben Pfaff Date: Fri, 31 Aug 2012 17:10:13 +0000 (-0700) Subject: lockfile: In tests, also verify log messages. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db90f94066dc645d8e777a9c43ad3f7e745393f9;p=openvswitch lockfile: In tests, also verify log messages. Signed-off-by: Ben Pfaff Acked-by: Ethan Jackson --- diff --git a/tests/lockfile.at b/tests/lockfile.at index 877cc872..50999e47 100644 --- a/tests/lockfile.at +++ b/tests/lockfile.at @@ -5,16 +5,46 @@ m4_define([CHECK_LOCKFILE], AT_KEYWORDS([lockfile]) AT_CHECK([test-lockfile $1], [0], [$1: success (m4_if( [$2], [1], [$2 child], [$2 children])) -]) +], [$3]) AT_CLEANUP]) CHECK_LOCKFILE([lock_and_unlock], [0]) + CHECK_LOCKFILE([lock_and_unlock_twice], [0]) -CHECK_LOCKFILE([lock_blocks_same_process], [0]) -CHECK_LOCKFILE([lock_blocks_same_process_twice], [0]) -CHECK_LOCKFILE([lock_blocks_other_process], [1]) -CHECK_LOCKFILE([lock_twice_blocks_other_process], [1]) + +CHECK_LOCKFILE([lock_blocks_same_process], [0], + [lockfile|WARN|.file.~lock~: failed to lock file: Resource deadlock avoided +]) + +CHECK_LOCKFILE([lock_blocks_same_process_twice], [0], + [lockfile|WARN|.file.~lock~: failed to lock file: Resource deadlock avoided +lockfile|WARN|.file.~lock~: failed to lock file: Resource deadlock avoided +]) + +CHECK_LOCKFILE([lock_blocks_other_process], [1], + [lockfile|WARN|.file.~lock~: child does not inherit lock +lockfile|WARN|.file.~lock~: failed to lock file: Resource temporarily unavailable +]) + +CHECK_LOCKFILE([lock_twice_blocks_other_process], [1], + [lockfile|WARN|.file.~lock~: failed to lock file: Resource deadlock avoided +lockfile|WARN|.file.~lock~: child does not inherit lock +lockfile|WARN|.file.~lock~: failed to lock file: Resource temporarily unavailable +]) + CHECK_LOCKFILE([lock_and_unlock_allows_other_process], [1]) -CHECK_LOCKFILE([lock_multiple], [0]) -CHECK_LOCKFILE([lock_symlink], [0]) -CHECK_LOCKFILE([lock_symlink_to_dir], [0]) + +CHECK_LOCKFILE([lock_multiple], [0], + [lockfile|WARN|.a.~lock~: failed to lock file: Resource deadlock avoided +]) + +CHECK_LOCKFILE([lock_symlink], [0], + [lockfile|WARN|.a.~lock~: failed to lock file: Resource deadlock avoided +lockfile|WARN|.b.~lock~: failed to lock file: Resource deadlock avoided +lockfile|WARN|.b.~lock~: failed to lock file: Resource deadlock avoided +lockfile|WARN|.a.~lock~: failed to lock file: Resource deadlock avoided +]) + +CHECK_LOCKFILE([lock_symlink_to_dir], [0], + [lockfile|WARN|dir/.b.~lock~: failed to lock file: Resource deadlock avoided +]) diff --git a/tests/test-lockfile.c b/tests/test-lockfile.c index b37fd225..fe258c24 100644 --- a/tests/test-lockfile.c +++ b/tests/test-lockfile.c @@ -270,11 +270,11 @@ static const struct test tests[] = { int main(int argc, char *argv[]) { - extern struct vlog_module VLM_lockfile; size_t i; set_program_name(argv[0]); - vlog_set_levels(&VLM_lockfile, VLF_ANY_FACILITY, VLL_ERR); + vlog_set_pattern(VLF_CONSOLE, "%c|%p|%m"); + vlog_set_levels(NULL, VLF_SYSLOG, VLL_OFF); if (argc != 2) { ovs_fatal(0, "exactly one argument required; use \"%s help\" for help",