From d1cd99244f96bd95bbd67cc737248df346dec08b Mon Sep 17 00:00:00 2001 From: egor-tensin Date: Thu, 25 Apr 2024 03:50:51 +0000 Subject: =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20egor-tensin/cimp?= =?UTF-8?q?le@8e652dd2cb69928ea1596aa3e59845fef6854e2c=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...storage.c.96d197609feea4b630e7b775fb18af81.html | 1189 ++++++++++++++++++++ 1 file changed, 1189 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..97fd758 --- /dev/null +++ b/coverage/index.storage.c.96d197609feea4b630e7b775fb18af81.html @@ -0,0 +1,1189 @@ + + + + + + GCC Code Coverage Report + + + + + +

GCC Code Coverage Report

+ +
+ +
+
+ + + + + + + + + + + + + +
Directory:src/
File:src/storage.c
Date:2024-04-25 03:45:42
+
+
+ + + + + + + + + + + + + + + + + + + +
ExecTotalCoverage
Lines:374975.5%
Branches:92045.0%
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineBranchExecSource
1 + /*
2 + * Copyright (c) 2022 Egor Tensin <egor@tensin.name>
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 +
23 + typedef int (*storage_get_runs_t)(struct storage *, struct run_queue *);
24 + typedef storage_get_runs_t storage_get_run_queue_t;
25 +
26 + struct storage_api {
27 + storage_settings_destroy_t destroy_settings;
28 + storage_create_t create;
29 + storage_destroy_t destroy;
30 +
31 + storage_run_create_t run_create;
32 + storage_run_finished_t run_finished;
33 +
34 + storage_get_runs_t get_runs;
35 + storage_get_run_queue_t get_run_queue;
36 + };
37 +
38 + static const struct storage_api apis[] = {
39 + {
40 + storage_sqlite_settings_destroy,
41 + storage_sqlite_create,
42 + storage_sqlite_destroy,
43 +
44 + storage_sqlite_run_create,
45 + storage_sqlite_run_finished,
46 +
47 + storage_sqlite_get_runs,
48 + storage_sqlite_get_run_queue,
49 + },
50 + };
51 +
52 + 18502static size_t numof_apis(void)
53 + {
54 + 18502 return sizeof(apis) / sizeof(apis[0]);
55 + }
56 +
57 + 18502static const struct storage_api *get_api(enum storage_type type)
58 + {
59 + if (type < 0)
60 + goto invalid_type;
61 +
+ 1/2 +
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 18502 times.
+
+
+
18502 if ((size_t)type > numof_apis())
62 + goto invalid_type;
63 +
64 + 18502 return &apis[type];
65 +
66 + invalid_type:
67 + log_err("Unsupported storage type: %d\n", type);
68 + return NULL;
69 + }
70 +
71 + 29void storage_settings_destroy(const struct storage_settings *settings)
72 + {
73 + 29 const struct storage_api *api = get_api(settings->type);
74 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 29 times.
+
+
+
29 if (!api)
75 + return;
76 + 29 api->destroy_settings(settings);
77 + }
78 +
79 + 29int storage_create(struct storage *storage, const struct storage_settings *settings)
80 + {
81 + 29 int ret = 0;
82 + 29 const struct storage_api *api = get_api(settings->type);
83 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 29 times.
+
+
+
29 if (!api)
84 + return -1;
85 + 29 ret = api->create(storage, settings);
86 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 29 times.
+
+
+
29 if (ret < 0)
87 + return ret;
88 + 29 storage->type = settings->type;
89 + 29 return ret;
90 + }
91 +
92 + 29void storage_destroy(struct storage *storage)
93 + {
94 + 29 const struct storage_api *api = get_api(storage->type);
95 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 29 times.
+
+
+
29 if (!api)
96 + return;
97 + 29 api->destroy(storage);
98 + }
99 +
100 + 9180int storage_run_create(struct storage *storage, const char *repo_url, const char *rev)
101 + {
102 + 9180 const struct storage_api *api = get_api(storage->type);
103 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (!api)
104 + return -1;
105 + 9180 return api->run_create(storage, repo_url, rev);
106 + }
107 +
108 + 9180int storage_run_finished(struct storage *storage, int run_id, const struct proc_output *output)
109 + {
110 + 9180 const struct storage_api *api = get_api(storage->type);
111 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (!api)
112 + return -1;
113 + 9180 return api->run_finished(storage, run_id, output);
114 + }
115 +
116 + 26int storage_get_runs(struct storage *storage, struct run_queue *queue)
117 + {
118 + 26 const struct storage_api *api = get_api(storage->type);
119 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 26 times.
+
+
+
26 if (!api)
120 + return -1;
121 + 26 return api->get_runs(storage, queue);
122 + }
123 +
124 + 29int storage_get_run_queue(struct storage *storage, struct run_queue *queue)
125 + {
126 + 29 const struct storage_api *api = get_api(storage->type);
127 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 29 times.
+
+
+
29 if (!api)
128 + return -1;
129 + 29 return api->get_run_queue(storage, queue);
130 + }
131 +
+
+ +
+ + + + -- cgit v1.2.3