Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
int pakfire_snapshot_create(struct pakfire* pakfire, FILE* f) {
int r = 1;
+ if (!f) {
+ errno = EINVAL;
+ return 1;
+ }
+
const char* root = pakfire_get_path(pakfire);
INFO(pakfire, "Creating snapshot of %s...\n", root);
int pakfire_snapshot_restore(struct pakfire* pakfire, FILE* f) {
struct pakfire_db* db = NULL;
+ if (!f) {
+ errno = EINVAL;
+ return 1;
+ }
+
// Extract the archive
int r = pakfire_snapshot_extract(pakfire, f);
if (r)
return r;
}
+static int test_invalid_inputs(const struct test* t) {
+ int r = EXIT_FAILURE;
+
+ // pakfire_snapshot_create
+ ASSERT_ERRNO(pakfire_snapshot_create(t->pakfire, NULL), EINVAL);
+
+ // pakfire_snapshot_restore
+ ASSERT_ERRNO(pakfire_snapshot_restore(t->pakfire, NULL), EINVAL);
+
+ // Everything passed
+ r = EXIT_SUCCESS;
+
+FAIL:
+ return r;
+}
+
int main(int argc, char** argv) {
testsuite_add_test(test_create_and_restore);
+ testsuite_add_test(test_invalid_inputs);
return testsuite_run();
}