From 31ce147c50e853f63b70048b0bbf71bb8889ca18 Mon Sep 17 00:00:00 2001 From: egor-tensin Date: Mon, 28 Aug 2023 07:43:34 +0000 Subject: =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20egor-tensin/cimp?= =?UTF-8?q?le@efb0a921609cf06080308a6a7c321d451489db8a=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...storage.c.96d197609feea4b630e7b775fb18af81.html | 1070 ++++++++++++++++++++ 1 file changed, 1070 insertions(+) create mode 100644 coverage/index.storage.c.96d197609feea4b630e7b775fb18af81.html (limited to 'coverage/index.storage.c.96d197609feea4b630e7b775fb18af81.html') diff --git a/coverage/index.storage.c.96d197609feea4b630e7b775fb18af81.html b/coverage/index.storage.c.96d197609feea4b630e7b775fb18af81.html new file mode 100644 index 0000000..3b71233 --- /dev/null +++ b/coverage/index.storage.c.96d197609feea4b630e7b775fb18af81.html @@ -0,0 +1,1070 @@ + + + + + + GCC Code Coverage Report + + + + + +

GCC Code Coverage Report

+ +
+ +
+
+ + + + + + + + + + + + + +
Directory:src/
File:src/storage.c
Date:2023-08-28 07:33:56
+
+
+ + + + + + + + + + + + + + + + + + + +
ExecTotalCoverage
Lines:334475.0%
Branches:81844.4%
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineBranchExecSource
1 + /*
2 + * Copyright (c) 2022 Egor Tensin <Egor.Tensin@gmail.com>
3 + * This file is part of the "cimple" project.
4 + * For details, see https://github.com/egor-tensin/cimple.
5 + * Distributed under the MIT License.
6 + */
7 +
8 + #include "storage.h"
9 + #include "log.h"
10 + #include "process.h"
11 + #include "run_queue.h"
12 + #include "storage_sqlite.h"
13 +
14 + #include <stddef.h>
15 +
16 + typedef void (*storage_settings_destroy_t)(const struct storage_settings *);
17 + typedef int (*storage_create_t)(struct storage *, const struct storage_settings *);
18 + typedef void (*storage_destroy_t)(struct storage *);
19 +
20 + typedef int (*storage_run_create_t)(struct storage *, const char *repo_url, const char *rev);
21 + typedef int (*storage_run_finished_t)(struct storage *, int repo_id, const struct proc_output *);
22 + typedef int (*storage_get_run_queue_t)(struct storage *, struct run_queue *);
23 +
24 + struct storage_api {
25 + storage_settings_destroy_t destroy_settings;
26 + storage_create_t create;
27 + storage_destroy_t destroy;
28 +
29 + storage_run_create_t run_create;
30 + storage_run_finished_t run_finished;
31 + storage_get_run_queue_t get_run_queue;
32 + };
33 +
34 + static const struct storage_api apis[] = {
35 + {
36 + storage_sqlite_settings_destroy,
37 + storage_sqlite_create,
38 + storage_sqlite_destroy,
39 +
40 + storage_sqlite_run_create,
41 + storage_sqlite_run_finished,
42 + storage_sqlite_get_run_queue,
43 + },
44 + };
45 +
46 + 18476static size_t numof_apis(void)
47 + {
48 + 18476 return sizeof(apis) / sizeof(apis[0]);
49 + }
50 +
51 + 18476static const struct storage_api *get_api(enum storage_type type)
52 + {
53 + if (type < 0)
54 + goto invalid_type;
55 +
+ 1/2 +
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 18476 times.
+
+
+
18476 if ((size_t)type > numof_apis())
56 + goto invalid_type;
57 +
58 + 18476 return &apis[type];
59 +
60 + invalid_type:
61 + log_err("Unsupported storage type: %d\n", type);
62 + return NULL;
63 + }
64 +
65 + 29void storage_settings_destroy(const struct storage_settings *settings)
66 + {
67 + 29 const struct storage_api *api = get_api(settings->type);
68 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 29 times.
+
+
+
29 if (!api)
69 + return;
70 + 29 api->destroy_settings(settings);
71 + }
72 +
73 + 29int storage_create(struct storage *storage, const struct storage_settings *settings)
74 + {
75 + 29 int ret = 0;
76 + 29 const struct storage_api *api = get_api(settings->type);
77 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 29 times.
+
+
+
29 if (!api)
78 + return -1;
79 + 29 ret = api->create(storage, settings);
80 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 29 times.
+
+
+
29 if (ret < 0)
81 + return ret;
82 + 29 storage->type = settings->type;
83 + 29 return ret;
84 + }
85 +
86 + 29void storage_destroy(struct storage *storage)
87 + {
88 + 29 const struct storage_api *api = get_api(storage->type);
89 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 29 times.
+
+
+
29 if (!api)
90 + return;
91 + 29 api->destroy(storage);
92 + }
93 +
94 + 9180int storage_run_create(struct storage *storage, const char *repo_url, const char *rev)
95 + {
96 + 9180 const struct storage_api *api = get_api(storage->type);
97 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (!api)
98 + return -1;
99 + 9180 return api->run_create(storage, repo_url, rev);
100 + }
101 +
102 + 9180int storage_run_finished(struct storage *storage, int run_id, const struct proc_output *output)
103 + {
104 + 9180 const struct storage_api *api = get_api(storage->type);
105 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (!api)
106 + return -1;
107 + 9180 return api->run_finished(storage, run_id, output);
108 + }
109 +
110 + 29int storage_get_run_queue(struct storage *storage, struct run_queue *queue)
111 + {
112 + 29 const struct storage_api *api = get_api(storage->type);
113 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 29 times.
+
+
+
29 if (!api)
114 + return -1;
115 + 29 return api->get_run_queue(storage, queue);
116 + }
117 +
+
+ +
+ + + + -- cgit v1.2.3