Skip to content

Commit bc4bea4

Browse files
Merge pull request #136 from dreamer-coding/extend_sanity
2 parents 8ae78aa + 2aa7f32 commit bc4bea4

File tree

6 files changed

+411
-6
lines changed

6 files changed

+411
-6
lines changed

.github/workflows/meson_ci.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
runs-on: macos-latest
6565
strategy:
6666
matrix:
67-
xcode_version: ["16.0", "16.1", "16.2", "16.3", "16.4"]
67+
xcode_version: ["15.0", "15.1", "15.2", "15.3", "15.4"]
6868
steps:
6969
- name: Checkout code
7070
uses: actions/checkout@v4
@@ -84,11 +84,21 @@ jobs:
8484
python -m pip install meson ninja
8585
8686
- name: Configure
87-
run: meson setup builddir -Dwith_test=enabled -Dwarning_level=3
87+
run: meson setup builddir --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3
88+
89+
- name: Compile
90+
run: meson compile -C builddir
8891

8992
- name: Run Tests
90-
run: meson test -C builddir -v --test-args='show --mode tree --verbose ci --result fail'
91-
93+
run: meson test -C builddir -v
94+
95+
- name: Upload Test Log
96+
if: failure()
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: macos_xcode_${{ matrix.xcode_version }}_meson_testlog
100+
path: builddir/meson-logs/testlog.txt
101+
92102
build_msys:
93103
name: Building on MSYS ${{ matrix.architecture }}
94104
runs-on: windows-latest

code/logic/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// macro definitions
2020
// *****************************************************************************
2121

22-
#define FOSSIL_PIZZA_VERSION "1.2.6"
22+
#define FOSSIL_PIZZA_VERSION "1.2.7"
2323
#define FOSSIL_PIZZA_AUTHOR "Fossil Logic"
2424
#define FOSSIL_PIZZA_WEBSITE "https://fossillogic.com"
2525

code/logic/fossil/pizza/sanity.h

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,81 @@ int fossil_sanity_sys_create_dir(const char* dirname);
116116
*/
117117
int fossil_sanity_sys_dir_exists(const char* dirname);
118118

119+
/**
120+
* @brief Reads the entire contents of a file into memory.
121+
*
122+
* The returned buffer is null-terminated and allocated dynamically.
123+
* The caller is responsible for freeing the returned memory using free().
124+
*
125+
* @param filename Path to the file to read.
126+
* @return char* Pointer to allocated null-terminated buffer on success,
127+
* or NULL on failure.
128+
*/
129+
char* fossil_sanity_sys_read_file(const char* filename);
130+
131+
/**
132+
* @brief Writes data to a file, replacing any existing contents.
133+
*
134+
* @param filename Path to the file.
135+
* @param data Null-terminated string to write.
136+
* @return int Returns 0 on success, negative on failure.
137+
*/
138+
int fossil_sanity_sys_write_file(const char* filename, const char* data);
139+
140+
/**
141+
* @brief Deletes a file from the filesystem.
142+
*
143+
* @param filename Path to the file to delete.
144+
* @return int Returns 0 on success, negative on failure.
145+
*/
146+
int fossil_sanity_sys_delete_file(const char* filename);
147+
148+
/**
149+
* @brief Retrieves the value of an environment variable.
150+
*
151+
* @param name Name of the environment variable.
152+
* @return const char* Value of the variable, or NULL if not found.
153+
*/
154+
const char* fossil_sanity_sys_getenv(const char* name);
155+
156+
/**
157+
* @brief Sets or overrides an environment variable.
158+
*
159+
* @param name Name of the environment variable.
160+
* @param value Value to set.
161+
* @return int Returns 0 on success, negative on failure.
162+
*/
163+
int fossil_sanity_sys_setenv(const char* name, const char* value);
164+
165+
/**
166+
* @brief Retrieves the current system timestamp as a formatted string.
167+
*
168+
* @return char* Newly allocated string with timestamp (caller must free).
169+
*/
170+
char* fossil_sanity_sys_timestamp(void);
171+
172+
/**
173+
* @brief Returns uptime in milliseconds since process start.
174+
*
175+
* @return long long Milliseconds since process launch.
176+
*/
177+
long long fossil_sanity_sys_uptime_ms(void);
178+
179+
/**
180+
* @brief Checks if a process is still running.
181+
*
182+
* @param pid Process ID.
183+
* @return int Returns 1 if running, 0 if not, negative on error.
184+
*/
185+
int fossil_sanity_sys_is_running(int pid);
186+
187+
/**
188+
* @brief Attempts to terminate a process by PID.
189+
*
190+
* @param pid Process ID.
191+
* @return int Returns 0 on success, negative on failure.
192+
*/
193+
int fossil_sanity_sys_kill(int pid);
119194

120195
#ifdef __cplusplus
121196
}
@@ -225,6 +300,91 @@ int fossil_sanity_sys_dir_exists(const char* dirname);
225300
#define _FOSSIL_SANITY_SYS_DIR_EXISTS(dirname) \
226301
fossil_sanity_sys_dir_exists(dirname)
227302

303+
/**
304+
* @brief Reads the entire contents of a file into memory.
305+
*
306+
* The returned buffer is null-terminated and allocated dynamically.
307+
* The caller is responsible for freeing the returned memory using free().
308+
*
309+
* @param filename Path to the file to read.
310+
* @return char* Pointer to allocated null-terminated buffer on success,
311+
* or NULL on failure.
312+
*/
313+
#define _FOSSIL_SANITY_SYS_READ_FILE(filename) \
314+
fossil_sanity_sys_read_file(filename)
315+
316+
/**
317+
* @brief Writes data to a file, replacing any existing contents.
318+
*
319+
* @param filename Path to the file.
320+
* @param data Null-terminated string to write.
321+
* @return int Returns 0 on success, negative on failure.
322+
*/
323+
#define _FOSSIL_SANITY_SYS_WRITE_FILE(filename, data) \
324+
fossil_sanity_sys_write_file(filename, data)
325+
326+
/**
327+
* @brief Deletes a file from the filesystem.
328+
*
329+
* @param filename Path to the file to delete.
330+
* @return int Returns 0 on success, negative on failure.
331+
*/
332+
#define _FOSSIL_SANITY_SYS_DELETE_FILE(filename) \
333+
fossil_sanity_sys_delete_file(filename)
334+
335+
/**
336+
* @brief Retrieves the value of an environment variable.
337+
*
338+
* @param name Name of the environment variable.
339+
* @return const char* Value of the variable, or NULL if not found.
340+
*/
341+
#define _FOSSIL_SANITY_SYS_GETENV(name) \
342+
fossil_sanity_sys_getenv(name)
343+
344+
/**
345+
* @brief Sets or overrides an environment variable.
346+
*
347+
* @param name Name of the environment variable.
348+
* @param value Value to set.
349+
* @return int Returns 0 on success, negative on failure.
350+
*/
351+
#define _FOSSIL_SANITY_SYS_SETENV(name, value) \
352+
fossil_sanity_sys_setenv(name, value)
353+
354+
/**
355+
* @brief Retrieves the current system timestamp as a formatted string.
356+
*
357+
* @return char* Newly allocated string with timestamp (caller must free).
358+
*/
359+
#define _FOSSIL_SANITY_SYS_TIMESTAMP() \
360+
fossil_sanity_sys_timestamp()
361+
362+
/**
363+
* @brief Returns uptime in milliseconds since process start.
364+
*
365+
* @return long long Milliseconds since process launch.
366+
*/
367+
#define _FOSSIL_SANITY_SYS_UPTIME_MS() \
368+
fossil_sanity_sys_uptime_ms()
369+
370+
/**
371+
* @brief Checks if a process is still running.
372+
*
373+
* @param pid Process ID.
374+
* @return int Returns 1 if running, 0 if not, negative on error.
375+
*/
376+
#define _FOSSIL_SANITY_SYS_IS_RUNNING(pid) \
377+
fossil_sanity_sys_is_running(pid)
378+
379+
/**
380+
* @brief Attempts to terminate a process by PID.
381+
*
382+
* @param pid Process ID.
383+
* @return int Returns 0 on success, negative on failure.
384+
*/
385+
#define _FOSSIL_SANITY_SYS_KILL(pid) \
386+
fossil_sanity_sys_kill(pid)
387+
228388
// *****************************************************************************
229389
// Public API Macros
230390
// *****************************************************************************
@@ -323,4 +483,89 @@ int fossil_sanity_sys_dir_exists(const char* dirname);
323483
#define FOSSIL_SANITY_SYS_DIR_EXISTS(dirname) \
324484
_FOSSIL_SANITY_SYS_DIR_EXISTS(dirname)
325485

486+
/**
487+
* @brief Reads the entire contents of a file into memory.
488+
*
489+
* The returned buffer is null-terminated and allocated dynamically.
490+
* The caller is responsible for freeing the returned memory using free().
491+
*
492+
* @param filename Path to the file to read.
493+
* @return char* Pointer to allocated null-terminated buffer on success,
494+
* or NULL on failure.
495+
*/
496+
#define FOSSIL_SANITY_SYS_READ_FILE(filename) \
497+
_FOSSIL_SANITY_SYS_READ_FILE(filename)
498+
499+
/**
500+
* @brief Writes data to a file, replacing any existing contents.
501+
*
502+
* @param filename Path to the file.
503+
* @param data Null-terminated string to write.
504+
* @return int Returns 0 on success, negative on failure.
505+
*/
506+
#define FOSSIL_SANITY_SYS_WRITE_FILE(filename, data) \
507+
_FOSSIL_SANITY_SYS_WRITE_FILE(filename, data)
508+
509+
/**
510+
* @brief Deletes a file from the filesystem.
511+
*
512+
* @param filename Path to the file to delete.
513+
* @return int Returns 0 on success, negative on failure.
514+
*/
515+
#define FOSSIL_SANITY_SYS_DELETE_FILE(filename) \
516+
_FOSSIL_SANITY_SYS_DELETE_FILE(filename)
517+
518+
/**
519+
* @brief Retrieves the value of an environment variable.
520+
*
521+
* @param name Name of the environment variable.
522+
* @return const char* Value of the variable, or NULL if not found.
523+
*/
524+
#define FOSSIL_SANITY_SYS_GETENV(name) \
525+
_FOSSIL_SANITY_SYS_GETENV(name)
526+
527+
/**
528+
* @brief Sets or overrides an environment variable.
529+
*
530+
* @param name Name of the environment variable.
531+
* @param value Value to set.
532+
* @return int Returns 0 on success, negative on failure.
533+
*/
534+
#define FOSSIL_SANITY_SYS_SETENV(name, value) \
535+
_FOSSIL_SANITY_SYS_SETENV(name, value)
536+
537+
/**
538+
* @brief Retrieves the current system timestamp as a formatted string.
539+
*
540+
* @return char* Newly allocated string with timestamp (caller must free).
541+
*/
542+
#define FOSSIL_SANITY_SYS_TIMESTAMP() \
543+
_FOSSIL_SANITY_SYS_TIMESTAMP()
544+
545+
/**
546+
* @brief Returns uptime in milliseconds since process start.
547+
*
548+
* @return long long Milliseconds since process launch.
549+
*/
550+
#define FOSSIL_SANITY_SYS_UPTIME_MS() \
551+
_FOSSIL_SANITY_SYS_UPTIME_MS()
552+
553+
/**
554+
* @brief Checks if a process is still running.
555+
*
556+
* @param pid Process ID.
557+
* @return int Returns 1 if running, 0 if not, negative on error.
558+
*/
559+
#define FOSSIL_SANITY_SYS_IS_RUNNING(pid) \
560+
_FOSSIL_SANITY_SYS_IS_RUNNING(pid)
561+
562+
/**
563+
* @brief Kills a running process.
564+
*
565+
* @param pid Process ID.
566+
* @return int Returns 0 on success, negative on failure.
567+
*/
568+
#define FOSSIL_SANITY_SYS_KILL(pid) \
569+
_FOSSIL_SANITY_SYS_KILL(pid)
570+
326571
#endif // FOSSIL_SANITY_H

0 commit comments

Comments
 (0)