1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
AT_BANNER([lockfile unit tests])
# CHECK_LOCKFILE([test-name], [number-children], [error-message]
# [skip-test-windows])
m4_define([CHECK_LOCKFILE],
[AT_SETUP([m4_translit([$1], [_], [ ])])
m4_if([$4], [yes], [AT_SKIP_IF([test "$IS_WIN32" = "yes"])])
AT_KEYWORDS([lockfile])
AT_CHECK([ovstest test-lockfile $1], [0], [$1: success (m4_if(
[$2], [1], [$2 child], [$2 children]))
], [stderr])
AT_CHECK([sed 's/pid [[0-9]]*/pid <pid>/' stderr], [0], [$3])
AT_CLEANUP])
CHECK_LOCKFILE([lock_and_unlock], [0])
CHECK_LOCKFILE([lock_and_unlock_twice], [0])
CHECK_LOCKFILE([lock_blocks_same_process], [0],
[lockfile|WARN|.file.~lock~: cannot lock file because this process has already locked it
])
CHECK_LOCKFILE([lock_blocks_same_process_twice], [0],
[lockfile|WARN|.file.~lock~: cannot lock file because this process has already locked it
lockfile|WARN|.file.~lock~: cannot lock file because this process has already locked it
])
CHECK_LOCKFILE([lock_blocks_other_process], [1],
[lockfile|WARN|.file.~lock~: child does not inherit lock
lockfile|WARN|.file.~lock~: cannot lock file because it is already locked by pid <pid>
], [yes])
CHECK_LOCKFILE([lock_twice_blocks_other_process], [1],
[lockfile|WARN|.file.~lock~: cannot lock file because this process has already locked it
lockfile|WARN|.file.~lock~: child does not inherit lock
lockfile|WARN|.file.~lock~: cannot lock file because it is already locked by pid <pid>
], [yes])
CHECK_LOCKFILE([lock_and_unlock_allows_other_process], [1], [], [yes])
CHECK_LOCKFILE([lock_multiple], [0],
[lockfile|WARN|.a.~lock~: cannot lock file because this process has already locked it
])
CHECK_LOCKFILE([lock_symlink], [0],
[lockfile|WARN|.a.~lock~: cannot lock file because this process has already locked it
lockfile|WARN|.b.~lock~: cannot lock file because this process has already locked it
lockfile|WARN|.b.~lock~: cannot lock file because this process has already locked it
lockfile|WARN|.a.~lock~: cannot lock file because this process has already locked it
], [yes])
CHECK_LOCKFILE([lock_symlink_to_dir], [0],
[lockfile|WARN|dir/.b.~lock~: cannot lock file because this process has already locked it
], [yes])
|