[ovs-dev] [PATCH 1/2] lockfile: In tests, also verify log messages.

Ben Pfaff blp at nicira.com
Thu Aug 30 22:29:49 UTC 2012


Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 tests/lockfile.at     |   46 ++++++++++++++++++++++++++++++++++++++--------
 tests/test-lockfile.c |    4 ++--
 2 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/tests/lockfile.at b/tests/lockfile.at
index 877cc87..50999e4 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 b37fd22..fe258c2 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",
-- 
1.7.2.5




More information about the dev mailing list