Browse files

lockfile: In tests, also verify log messages.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
  • Loading branch information...
1 parent 079b594 commit db90f94066dc645d8e777a9c43ad3f7e745393f9 @blp blp committed Aug 31, 2012
Showing with 40 additions and 10 deletions.
  1. +38 −8 tests/lockfile.at
  2. +2 −2 tests/test-lockfile.c
View
46 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
+])
View
4 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",

0 comments on commit db90f94

Please sign in to comment.