diff options
author | Umang Jain <umang@endlessm.com> | 2018-08-31 20:20:23 +0530 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-09-04 21:31:34 +0000 |
commit | a70d2f67310bd869c6a40c4013dc51a3e2f2d2a8 (patch) | |
tree | 47bd9920069b9a6c1d87f39623a9af2905b59df5 | |
parent | 68420f70bbb288cbd4424413f86f6cfecc06d7b1 (diff) | |
download | ostree-a70d2f67310bd869c6a40c4013dc51a3e2f2d2a8.tar.gz |
Add tests for ostree_repo_get_min_free_space_bytes
https://phabricator.endlessm.com/T23694
Closes: #1715
Approved by: cgwalters
-rw-r--r-- | src/libostree/libostree-devel.sym | 2 | ||||
-rw-r--r-- | tests/test-repo.c | 54 |
2 files changed, 55 insertions, 1 deletions
diff --git a/src/libostree/libostree-devel.sym b/src/libostree/libostree-devel.sym index 0bdade75..0ba9a215 100644 --- a/src/libostree/libostree-devel.sym +++ b/src/libostree/libostree-devel.sym @@ -19,7 +19,7 @@ /* Add new symbols here. Release commits should copy this section into -released.sym. */ LIBOSTREE_2018.9 { -ostree_repo_get_min_free_space_bytes; + ostree_repo_get_min_free_space_bytes; } LIBOSTREE_2018.7; /* Stub section for the stable release *after* this development one; don't diff --git a/tests/test-repo.c b/tests/test-repo.c index edccef59..c56f60c5 100644 --- a/tests/test-repo.c +++ b/tests/test-repo.c @@ -151,6 +151,57 @@ test_repo_equal (Fixture *fixture, g_assert_false (ostree_repo_equal (closed_repo, closed_repo)); } +static void +test_repo_get_min_free_space (Fixture *fixture, + gconstpointer test_data) +{ + g_autoptr (GKeyFile) config = NULL; + g_autoptr(GError) error = NULL; + typedef struct + { + const char *val; + gboolean should_succeed; + } min_free_space_value; + + g_autoptr(OstreeRepo) repo = ostree_repo_create_at (fixture->tmpdir.fd, ".", + OSTREE_REPO_MODE_ARCHIVE, + NULL, + NULL, &error); + g_assert_no_error (error); + + min_free_space_value values_to_test[] = { + {"500MB", TRUE }, + { "0MB", TRUE }, + { "17179869185GB", FALSE }, /* Overflow parameter: bytes > G_MAXUINT64 */ + { NULL, FALSE } + }; + + config = ostree_repo_copy_config (repo); + + for (guint i = 0; values_to_test[i].val != NULL; i++) + { + g_key_file_remove_key (config, "core", "min-free-space-size", NULL); + g_key_file_set_string (config, "core", "min-free-space-size", values_to_test[i].val); + + ostree_repo_write_config (repo, config, &error); + g_assert_no_error (error); + ostree_repo_reload_config (repo, NULL, &error); + g_assert_no_error (error); + + ostree_repo_prepare_transaction (repo, FALSE, NULL, &error); + if (values_to_test[i].should_succeed) + g_assert_no_error (error); + else + continue; + + ostree_repo_get_min_free_space_bytes (repo); + g_assert_no_error (error); + + ostree_repo_commit_transaction (repo, NULL, NULL, &error); + g_assert_no_error (error); + } +} + int main (int argc, char **argv) @@ -164,6 +215,9 @@ main (int argc, test_repo_hash_closed, teardown); g_test_add ("/repo/equal", Fixture, NULL, setup, test_repo_equal, teardown); + g_test_add ("/repo/get_min_free_space", Fixture, NULL, setup, + test_repo_get_min_free_space, teardown); + return g_test_run (); } |