2 * Copyright (c) 2017 Stefan Sperling <stsp@openbsd.org>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include "got_error.h"
23 #include "got_repository.h"
25 #define RUN_TEST(expr, name) \
26 if (!(expr)) { printf("test %s failed", (name)); failure = 1; }
28 #define GOT_REPO_PATH "../../../"
31 repo_open_test(const char *repo_path)
33 const struct got_error *err;
34 struct got_repository *repo;
38 err = got_repo_open(&repo, repo_path);
39 ret = (err == NULL && repo != NULL);
45 repo_get_head_ref(const char *repo_path)
47 const struct got_error *err;
48 struct got_repository *repo;
49 struct got_reference *head_ref;
52 err = got_repo_open(&repo, repo_path);
53 if (err != NULL || repo == NULL)
55 err = got_repo_get_reference(&head_ref, repo, GOT_REF_HEAD);
56 if (err != NULL || head_ref == NULL)
58 got_ref_close(head_ref);
64 main(int argc, const char *argv[])
67 const char *repo_path;
70 repo_path = GOT_REPO_PATH;
74 fprintf(stderr, "usage: repository_test [REPO_PATH]\n");
78 RUN_TEST(repo_open_test(repo_path), "repo_open");
79 RUN_TEST(repo_get_head_ref(repo_path), "get_head_ref");
81 return failure ? 1 : 0;