Skip to content

Commit

Permalink
Adding tests for use_mmap
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Oct 16, 2012
1 parent ecf9514 commit 5b522d2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/bloomd/runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ int main(void)
tcase_add_test(tc1, test_sane_flush_interval);
tcase_add_test(tc1, test_sane_cold_interval);
tcase_add_test(tc1, test_sane_in_memory);
tcase_add_test(tc1, test_sane_use_mmap);
tcase_add_test(tc1, test_sane_worker_threads);
tcase_add_test(tc1, test_filter_config_bad_file);
tcase_add_test(tc1, test_filter_config_empty_file);
Expand Down
22 changes: 22 additions & 0 deletions tests/bloomd/test_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ START_TEST(test_config_get_default)
fail_unless(config.probability_reduction == 0.9);
fail_unless(config.flush_interval == 60);
fail_unless(config.cold_interval == 3600);
fail_unless(config.in_memory == 0);
fail_unless(config.worker_threads == 1);
fail_unless(config.use_mmap == 0);
}
END_TEST

Expand All @@ -45,6 +48,9 @@ START_TEST(test_config_bad_file)
fail_unless(config.probability_reduction == 0.9);
fail_unless(config.flush_interval == 60);
fail_unless(config.cold_interval == 3600);
fail_unless(config.in_memory == 0);
fail_unless(config.worker_threads == 1);
fail_unless(config.use_mmap == 0);
}
END_TEST

Expand All @@ -70,6 +76,9 @@ START_TEST(test_config_empty_file)
fail_unless(config.probability_reduction == 0.9);
fail_unless(config.flush_interval == 60);
fail_unless(config.cold_interval == 3600);
fail_unless(config.in_memory == 0);
fail_unless(config.worker_threads == 1);
fail_unless(config.use_mmap == 0);

unlink("/tmp/zero_file");
}
Expand All @@ -89,6 +98,8 @@ initial_capacity = 2000000\n\
default_probability = 0.005\n\
probability_reduction = 0.8\n\
data_dir = /tmp/test\n\
workers = 2\n\
use_mmap = 1\n\
log_level = INFO\n";
write(fh, buf, strlen(buf));
fchmod(fh, 777);
Expand All @@ -110,6 +121,8 @@ log_level = INFO\n";
fail_unless(config.flush_interval == 120);
fail_unless(config.cold_interval == 12000);
fail_unless(config.in_memory == 1);
fail_unless(config.worker_threads == 2);
fail_unless(config.use_mmap == 1);

unlink("/tmp/basic_config");
}
Expand Down Expand Up @@ -253,6 +266,15 @@ START_TEST(test_sane_in_memory)
}
END_TEST

START_TEST(test_sane_use_mmap)
{
fail_unless(sane_use_mmap(-1) == 1);
fail_unless(sane_use_mmap(0) == 0);
fail_unless(sane_use_mmap(1) == 0);
fail_unless(sane_use_mmap(2) == 1);
}
END_TEST

START_TEST(test_sane_worker_threads)
{
fail_unless(sane_worker_threads(-1) == 1);
Expand Down

0 comments on commit 5b522d2

Please sign in to comment.