diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2014-05-10 11:21:40 +0100 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2014-05-10 11:21:40 +0100 |
commit | 60fc1f3f085983aa3fbb74102c270be8de15f9e5 (patch) | |
tree | 20a17a60bcfec3f6fb679e9c1f7bc4e3659e8f32 /tests | |
parent | 5a549e877b2d947cf2be0d0e9decc2b8158ee933 (diff) | |
download | bindfs-60fc1f3f085983aa3fbb74102c270be8de15f9e5.tar.gz |
Fix tests (#14)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 12 | ||||
-rwxr-xr-x | tests/test_bindfs.rb | 28 | ||||
-rw-r--r-- | tests/utimens_nofollow.c | 13 |
3 files changed, 32 insertions, 21 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 53a9081..eca8563 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,13 +1,9 @@ UNAME_S := $(shell uname -s) -if BUILD_OS_IS_DARWIN - noinst_PROGRAMS = readdir_inode - readdir_inode_SOURCES = readdir_inode.c -else - noinst_PROGRAMS = readdir_inode utimens_nofollow - readdir_inode_SOURCES = readdir_inode.c - utimens_nofollow_SOURCES = utimens_nofollow.c -endif + +noinst_PROGRAMS = readdir_inode utimens_nofollow +readdir_inode_SOURCES = readdir_inode.c +utimens_nofollow_SOURCES = utimens_nofollow.c TESTS = test_bindfs.rb SUBDIRS = internals diff --git a/tests/test_bindfs.rb b/tests/test_bindfs.rb index eb82c4f..a1f1526 100755 --- a/tests/test_bindfs.rb +++ b/tests/test_bindfs.rb @@ -231,7 +231,6 @@ testenv("--chmod-allow-x --chmod-ignore") do chmod(00077, 'mnt/file') # should change x bits; should not unset sticky bit assert { File.stat('src/file').mode & 07777 == 01611 } - mkdir('src/dir') chmod(0700, 'src/dir') chmod(0077, 'mnt/dir') # bits on dir should not change @@ -371,19 +370,22 @@ root_testenv("", :title => "setgid directories") do assert { File.stat('mnt/dir/file').gid == $nogroup_gid } end -root_testenv("", :title => "utimens on symlinks") do - touch('mnt/file') - Dir.chdir "mnt" do - system('ln -sf file link') +# utimensat() unavailable on OS X +unless RUBY_PLATFORM =~ /darwin/ + root_testenv("", :title => "utimens on symlinks") do + touch('mnt/file') + Dir.chdir "mnt" do + system('ln -sf file link') + end + + system("#{$tests_dir}/utimens_nofollow mnt/link 12 34 56 78") + raise "Failed to run utimens_nofollow: #{$?.inspect}" unless $?.success? + + assert { File.lstat('mnt/link').atime.to_i < 100 } + assert { File.lstat('mnt/link').mtime.to_i < 100 } + assert { File.lstat('mnt/file').atime.to_i > 100 } + assert { File.lstat('mnt/file').mtime.to_i > 100 } end - - system("#{$tests_dir}/utimens_nofollow mnt/link 12 34 56 78") - raise "Failed to run utimens_nofollow: #{$?.inspect}" unless $?.success? - - assert { File.lstat('mnt/link').atime.to_i < 100 } - assert { File.lstat('mnt/link').mtime.to_i < 100 } - assert { File.lstat('mnt/file').atime.to_i > 100 } - assert { File.lstat('mnt/file').mtime.to_i > 100 } end # FIXME: this stuff around testenv is a hax, and testenv may also exit(), which defeats the 'ensure' below. diff --git a/tests/utimens_nofollow.c b/tests/utimens_nofollow.c index b98275f..8316b26 100644 --- a/tests/utimens_nofollow.c +++ b/tests/utimens_nofollow.c @@ -1,4 +1,6 @@ +#ifndef __APPLE__ + #define _BSD_SOURCE /* For atoll */ #include <stdlib.h> @@ -30,3 +32,14 @@ int main(int argc, char* argv[]) return 0; } + +#else /* #ifndef __APPLE__ */ + +#include <stdio.h> +int main() +{ + fprintf("utimensat() unavailable on this platform\n"); + return 1; +} + +#endif /* #ifndef __APPLE__ */ |