about summary refs log tree commit diff
path: root/cover.c
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2025-10-16 13:58:22 +0900
committerNguyễn Gia Phong <cnx@loang.net>2025-10-16 13:58:22 +0900
commit35059bc54f443ae105e3b66d719d18e2b1e879b8 (patch)
tree640d5ff9f9007562063e4cdd2b49ba29c7692020 /cover.c
parentfaf230926c2313065a728699b2906c310730d4d9 (diff)
downloadtaosc-35059bc54f443ae105e3b66d719d18e2b1e879b8.tar.gz
Implement patch location coverage checker
Diffstat (limited to 'cover.c')
-rw-r--r--cover.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/cover.c b/cover.c
new file mode 100644
index 0000000..3061646
--- /dev/null
+++ b/cover.c
@@ -0,0 +1,44 @@
+/*
+ * Live variable collector
+ * Copyright (C) 2024-2025  Nguyễn Gia Phong
+ *
+ * This file is part of taosc.
+ *
+ * Taosc is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Taosc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with taosc.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "stdlib.c"
+
+static int output_file = -1;
+
+void init(int argc, const char *const *argv, char **envp)
+{
+	environ = envp;
+	const char *const path = getenv("TAOSC_OUTPUT");
+	if (path != NULL)
+		output_file = open(path, O_WRONLY | O_CREAT | O_EXCL, 0644);
+	if (output_file == -1) {
+		const char *msg = "cannot open $TAOSC_OUTPUT for writing\n";
+		write(2, msg, strlen(msg));
+		fsync(2);
+		exit(128);
+	}
+	write(output_file, "\n", 1);
+	fsync(output_file);
+}
+
+void report(void)
+{
+	ftruncate(output_file, 0);
+}