aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/common.rb8
-rw-r--r--tests/internals/test_internals.c24
-rw-r--r--tests/readdir_inode.c10
-rwxr-xr-xtests/stress_test.rb24
-rwxr-xr-xtests/test_concurrent.rb4
5 files changed, 35 insertions, 35 deletions
diff --git a/tests/common.rb b/tests/common.rb
index c99016b..36576e5 100755
--- a/tests/common.rb
+++ b/tests/common.rb
@@ -53,7 +53,7 @@ def wait_for(options = {}, &condition)
:max_sleep => 0.5,
:max_time => 5
}.merge(options)
-
+
start_time = Time.now
sleep_time = options[:initial_sleep]
while !`mount`.include?(`pwd`.strip)
@@ -85,12 +85,12 @@ def testenv(bindfs_args, options = {}, &block)
:valgrind => valgrind_options != nil,
:valgrind_opts => valgrind_options
}.merge(options)
-
+
# todo: less repetitive and more careful error handling and cleanup
puts "--- #{options[:title]} ---"
puts "[ #{bindfs_args} ]"
-
+
begin
Dir.mkdir TESTDIR_NAME
rescue Exception => ex
@@ -145,7 +145,7 @@ def testenv(bindfs_args, options = {}, &block)
fail("ERROR: failed to umount")
testcase_ok = false
end
-
+
if !$?.success?
fail("exit status: #{$?}")
testcase_ok = false
diff --git a/tests/internals/test_internals.c b/tests/internals/test_internals.c
index b388ddb..cf7a18b 100644
--- a/tests/internals/test_internals.c
+++ b/tests/internals/test_internals.c
@@ -11,47 +11,47 @@ int failures = 0;
void test_my_dirname(char *arg, const char *expected)
{
char *orig = strdup(arg);
-
+
const char *ret = my_dirname(arg);
if (strcmp(ret, expected) != 0) {
printf("Expected my_dirname(`%s') to return `%s' but got `%s'\n", orig, expected, ret);
failures++;
}
-
+
free(orig);
}
void my_dirname_suite()
{
char buf[256];
-
+
strcpy(buf, "/foo/bar/baz");
test_my_dirname(buf, "/foo/bar");
-
+
strcpy(buf, "/foo/bar");
test_my_dirname(buf, "/foo");
-
+
strcpy(buf, "/foo");
test_my_dirname(buf, "/");
-
+
strcpy(buf, "/foo/");
test_my_dirname(buf, "/foo");
-
+
strcpy(buf, "/");
test_my_dirname(buf, "/");
-
+
strcpy(buf, "foo");
test_my_dirname(buf, ".");
-
+
strcpy(buf, "foo/bar");
test_my_dirname(buf, "foo");
-
+
strcpy(buf, "./foo/bar");
test_my_dirname(buf, "./foo");
-
+
strcpy(buf, "./foo");
test_my_dirname(buf, ".");
-
+
strcpy(buf, ".");
test_my_dirname(buf, "..");
}
diff --git a/tests/readdir_inode.c b/tests/readdir_inode.c
index a216c7e..ed413be 100644
--- a/tests/readdir_inode.c
+++ b/tests/readdir_inode.c
@@ -8,18 +8,18 @@ int main(int argc, char* argv[])
{
DIR* dirp;
struct dirent* dent;
-
+
if (argc != 2) {
fprintf(stderr, "Usage: readdir_inode dir\n");
return 1;
}
-
+
dirp = opendir(argv[1]);
if (dirp == NULL) {
perror("failed to open directory");
return 2;
}
-
+
dent = readdir(dirp);
while (dent != NULL) {
if (errno != 0) {
@@ -29,8 +29,8 @@ int main(int argc, char* argv[])
printf("%llu %s\n", (unsigned long long)dent->d_ino, dent->d_name);
dent = readdir(dirp);
}
-
+
closedir(dirp);
-
+
return 0;
}
diff --git a/tests/stress_test.rb b/tests/stress_test.rb
index 6c0e41c..88804ba 100755
--- a/tests/stress_test.rb
+++ b/tests/stress_test.rb
@@ -27,25 +27,25 @@ class ChildProcess
run
end
end
-
+
attr_reader :pid
-
+
def run
raise "undefined"
end
-
+
def interrupt
ensure_started
Process.kill("INT", @pid)
end
-
+
def wait
ensure_started
Process.waitpid @pid
@pid = nil
$?
end
-
+
def ensure_started
raise "Not started" if !@pid
end
@@ -55,7 +55,7 @@ class BindfsRunner < ChildProcess
def initialize(options = {})
@valgrind = options[:valgrind]
@valgrind_tool = options[:valgrind_tool] || 'memcheck'
-
+
if @valgrind && Process.uid != 0
raise "This must be run as root due to valgrind's limitations"
end
@@ -68,7 +68,7 @@ class BindfsRunner < ChildProcess
SRC_DIR,
MNT_DIR
]
-
+
if @valgrind
cmd = [
'valgrind',
@@ -78,7 +78,7 @@ class BindfsRunner < ChildProcess
'--'
] + cmd
end
-
+
cmd_str = Shellwords.join(cmd) + ' > stress_test.log 2>&1'
puts "Starting #{cmd_str}"
Process.exec(cmd_str)
@@ -93,21 +93,21 @@ class FileCopier < ChildProcess
:size => "100M",
:iterations => 10
}.merge(options)
-
+
puts "Creating template file, size = #{@options[:size]}"
src_dir_src_file = "#{SRC_DIR}/#{@options[:prefix]}_src"
output = `dd if=/dev/urandom of='#{src_dir_src_file}' bs=#{@options[:size]} count=1 2>&1`
raise "#{$?.inspect} with output:\n#{output}" unless $?.success?
end
-
+
def mnt_prefix
"#{MNT_DIR}/#{@options[:prefix]}"
end
-
+
def src_file
"#{mnt_prefix}_src"
end
-
+
def run
task_desc = "#{@options[:num_copies]} copies of #{@options[:size]} in #{@options[:iterations]} iterations"
puts "Making #{task_desc}"
diff --git a/tests/test_concurrent.rb b/tests/test_concurrent.rb
index 3b2030d..f981332 100755
--- a/tests/test_concurrent.rb
+++ b/tests/test_concurrent.rb
@@ -30,12 +30,12 @@ raise "Give two _different_ users as parameters" unless user1 != user2
testenv "--mirror=#{user1},#{user2}" do
touch('src/file')
-
+
count = 0
10.times do |i|
out1 = `su #{user1} -c "stat --format=%U mnt/file"`
out2 = `su #{user2} -c "stat --format=%U mnt/file"`
-
+
out1.strip!
out2.strip!
puts "#{i+1}: #{out1} #{out2}"