From cdbb1115186dce5eb4a0622696d22d8beeca6140 Mon Sep 17 00:00:00 2001 From: egor-tensin Date: Thu, 15 Oct 2026 11:02:19 +0000 Subject: Deploying to gh-pages from @ egor-tensin/cimple@92c4b4cd3c0b6dbdba1cd4ca286d3defa3af2097 🚀 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...n_queue.c.fdfaa39d71447cf1e7d01ff206bd91e5.html | 1578 ++++++++++++++++++++ 1 file changed, 1578 insertions(+) create mode 100644 coverage/index.run_queue.c.fdfaa39d71447cf1e7d01ff206bd91e5.html (limited to 'coverage/index.run_queue.c.fdfaa39d71447cf1e7d01ff206bd91e5.html') diff --git a/coverage/index.run_queue.c.fdfaa39d71447cf1e7d01ff206bd91e5.html b/coverage/index.run_queue.c.fdfaa39d71447cf1e7d01ff206bd91e5.html new file mode 100644 index 0000000..0dc77ab --- /dev/null +++ b/coverage/index.run_queue.c.fdfaa39d71447cf1e7d01ff206bd91e5.html @@ -0,0 +1,1578 @@ + + + + + + GCC Code Coverage Report + + + + + +
+

GCC Code Coverage Report

+ +
+ +
+
+ + + + + + + + + + + + + +
Directory:src/
File:src/run_queue.c
Date:2026-10-15 10:49:27
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
ExecTotalCoverage
Lines:8111173.0%
Functions:151693.8%
Branches:173647.2%
+
+
+ +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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 "run_queue.h"
9 +
10 + #include "json.h"
11 + #include "log.h"
12 +
13 + #include <json-c/json_object.h>
14 +
15 + #include <stdlib.h>
16 + #include <string.h>
17 + #include <sys/queue.h>
18 +
19 + struct run {
20 + int id;
21 + char* repo_url;
22 + char* repo_rev;
23 + int status;
24 + int exit_code;
25 +
26 + SIMPLEQ_ENTRY(run) entries;
27 + };
28 +
29 + 36720int run_new(
30 + struct run** _entry,
31 + int id,
32 + const char* _repo_url,
33 + const char* _repo_rev,
34 + enum run_status status,
35 + int exit_code
36 + ) {
37 + 36720 struct run* entry = malloc(sizeof(struct run));
38 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 36720 times.
+
+
+
36720 if (!entry) {
39 + ✗ log_errno("malloc");
40 + ✗ goto fail;
41 + }
42 +
43 + 36720 char* repo_url = strdup(_repo_url);
44 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 36720 times.
+
+
+
36720 if (!repo_url) {
45 + ✗ log_errno("strdup");
46 + ✗ goto free_entry;
47 + }
48 +
49 + 36720 char* repo_rev = strdup(_repo_rev);
50 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 36720 times.
+
+
+
36720 if (!repo_rev) {
51 + ✗ log_errno("strdup");
52 + ✗ goto free_repo_url;
53 + }
54 +
55 + 36720 entry->id = id;
56 + 36720 entry->repo_url = repo_url;
57 + 36720 entry->repo_rev = repo_rev;
58 + 36720 entry->status = status;
59 + 36720 entry->exit_code = exit_code;
60 +
61 + 36720 *_entry = entry;
62 + 36720 return 0;
63 +
64 + ✗free_repo_url:
65 + ✗ free(repo_url);
66 +
67 + ✗free_entry:
68 + ✗ free(entry);
69 +
70 + ✗fail:
71 + ✗ return -1;
72 + }
73 +
74 + 36720void run_destroy(struct run* entry) {
75 + 36720 free(entry->repo_rev);
76 + 36720 free(entry->repo_url);
77 + 36720 free(entry);
78 + 36720}
79 +
80 + 18360int run_queued(struct run** entry, const char* repo_url, const char* repo_rev) {
81 + 18360 return run_new(entry, -1, repo_url, repo_rev, RUN_STATUS_CREATED, -1);
82 + }
83 +
84 + 9180int run_created(struct run** entry, int id, const char* repo_url, const char* repo_rev) {
85 + 9180 return run_new(entry, id, repo_url, repo_rev, RUN_STATUS_CREATED, -1);
86 + }
87 +
88 + 9180int run_to_json(const struct run* entry, struct json_object** _json) {
89 + 9180 struct json_object* json = NULL;
90 + 9180 int ret = 0;
91 +
92 + 9180 ret = libjson_new_object(&json);
93 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (ret < 0)
94 + ✗ return -1;
95 + 9180 ret = libjson_set_int_const_key(json, "id", entry->id);
96 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (ret < 0)
97 + ✗ goto free;
98 + 9180 ret = libjson_set_int_const_key(json, "exit_code", entry->exit_code);
99 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (ret < 0)
100 + ✗ goto free;
101 + 9180 ret = libjson_set_string_const_key(json, "repo_url", entry->repo_url);
102 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (ret < 0)
103 + ✗ goto free;
104 + 9180 ret = libjson_set_string_const_key(json, "repo_rev", entry->repo_rev);
105 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (ret < 0)
106 + ✗ goto free;
107 +
108 + 9180 *_json = json;
109 + 9180 return ret;
110 +
111 + ✗free:
112 + ✗ libjson_free(json);
113 +
114 + ✗ return ret;
115 + }
116 +
117 + 45900int run_get_id(const struct run* entry) {
118 + 45900 return entry->id;
119 + }
120 +
121 + 64260const char* run_get_repo_url(const struct run* entry) {
122 + 64260 return entry->repo_url;
123 + }
124 +
125 + 36720const char* run_get_repo_rev(const struct run* entry) {
126 + 36720 return entry->repo_rev;
127 + }
128 +
129 + 9180void run_set_id(struct run* entry, int id) {
130 + 9180 entry->id = id;
131 + 9180}
132 +
133 + 55void run_queue_create(struct run_queue* queue) {
134 + 55 SIMPLEQ_INIT(queue);
135 + 55}
136 +
137 + 55void run_queue_destroy(struct run_queue* queue) {
138 + 55 struct run* entry1 = SIMPLEQ_FIRST(queue);
139 +
+ 2/2 +
+
✓ Branch 0 taken 9180 times.
+
✓ Branch 1 taken 55 times.
+
+
+
9235 while (entry1) {
140 + 9180 struct run* entry2 = SIMPLEQ_NEXT(entry1, entries);
141 + 9180 run_destroy(entry1);
142 + 9180 entry1 = entry2;
143 + }
144 + 55 SIMPLEQ_INIT(queue);
145 + 55}
146 +
147 + 26int run_queue_to_json(const struct run_queue* queue, struct json_object** _json) {
148 + 26 struct json_object* json = NULL;
149 + 26 int ret = 0;
150 +
151 + 26 ret = libjson_new_array(&json);
152 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 26 times.
+
+
+
26 if (ret < 0)
153 + ✗ return ret;
154 +
155 + 26 struct run* entry = NULL;
156 +
+ 2/2 +
+
✓ Branch 0 taken 9180 times.
+
✓ Branch 1 taken 26 times.
+
+
+
9206 SIMPLEQ_FOREACH(entry, queue, entries) {
157 + 9180 struct json_object* entry_json = NULL;
158 + 9180 ret = run_to_json(entry, &entry_json);
159 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (ret < 0)
160 + ✗ goto free;
161 +
162 + 9180 ret = libjson_append(json, entry_json);
163 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9180 times.
+
+
+
9180 if (ret < 0) {
164 + ✗ libjson_free(entry_json);
165 + ✗ goto free;
166 + }
167 + }
168 +
169 + 26 *_json = json;
170 + 26 return ret;
171 +
172 + ✗free:
173 + ✗ libjson_free(json);
174 +
175 + ✗ return ret;
176 + }
177 +
178 + 27393int run_queue_is_empty(const struct run_queue* queue) {
179 + 27393 return SIMPLEQ_EMPTY(queue);
180 + }
181 +
182 + ✗void run_queue_add_first(struct run_queue* queue, struct run* entry) {
183 + ✗ SIMPLEQ_INSERT_HEAD(queue, entry, entries);
184 + ✗}
185 +
186 + 18360void run_queue_add_last(struct run_queue* queue, struct run* entry) {
187 + 18360 SIMPLEQ_INSERT_TAIL(queue, entry, entries);
188 + 18360}
189 +
190 + 9180struct run* run_queue_remove_first(struct run_queue* queue) {
191 + 9180 struct run* entry = SIMPLEQ_FIRST(queue);
192 +
+ 2/2 +
+
✓ Branch 0 taken 77 times.
+
✓ Branch 1 taken 9103 times.
+
+
+
9180 SIMPLEQ_REMOVE_HEAD(queue, entries);
193 + 9180 return entry;
194 + }
195 +
+
+
+
+ + + + -- cgit v1.3