lockfile: In tests, also verify log messages.
authorBen Pfaff <blp@nicira.com>
Fri, 31 Aug 2012 17:10:13 +0000 (10:10 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 31 Aug 2012 17:10:13 +0000 (10:10 -0700)
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
tests/lockfile.at
tests/test-lockfile.c

index 877cc872fc257512179ae683397d09e8e4baa1a9..50999e47e1f372416afb525aeb270fa1e80c1ab0 100644 (file)
@@ -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
+])
index b37fd225badc443b8882c75475f724c494737945..fe258c24922a0c2b44183c24738af23c201f8a7a 100644 (file)
@@ -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",