Skip to content

Commit 88c7834

Browse files
Merge pull request #131 from dreamer-coding/main
Patch update
2 parents ca49ed0 + 3f199c6 commit 88c7834

File tree

11 files changed

+178
-16
lines changed

11 files changed

+178
-16
lines changed

.github/ciimage/Dockerfile.debian

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
# Use a specific Debian base image
2-
FROM debian:buster
1+
# Use a specific Debian Bookworm base image
2+
FROM debian:bookworm
33

44
# Set environment variables to avoid interaction
55
ENV DEBIAN_FRONTEND=noninteractive \
66
TZ=UTC
77

88
# Install system dependencies and clean up
99
RUN apt-get update && \
10-
apt-get install -y \
10+
apt-get install -y --no-install-recommends \
1111
build-essential \
1212
clang \
1313
gcc \
1414
g++ \
1515
gdb \
1616
llvm \
17-
libstdc++-8-dev \
17+
libstdc++-12-dev \
1818
wget \
1919
python3 \
20+
python3-full \
2021
python3-pip \
21-
git && \
22+
git \
23+
ca-certificates && \
2224
apt-get clean && \
2325
rm -rf /var/lib/apt/lists/*
2426

25-
# Install Meson and Ninja
26-
RUN python3 -m pip install --no-cache-dir meson ninja==1.10.2
27+
# Install Meson and Ninja using pip
28+
RUN python3 -m pip install --no-cache-dir meson==1.3.0 ninja==1.10.2 --break-system-packages
2729

2830
# Set environment variables
29-
ENV CC=/usr/bin/clang
30-
ENV CXX=/usr/bin/clang++
31-
ENV LD_LIBRARY_PATH=/usr/local/lib
31+
ENV CC=clang \
32+
CXX=clang++ \
33+
LD_LIBRARY_PATH=/usr/local/lib
3234

3335
# Set working directory
3436
WORKDIR /workspace

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ To get started with Pizza Test, ensure you have the following installed:
4343
# ======================
4444
[wrap-git]
4545
url = https://github.com/fossillogic/fossil-test.git
46-
revision = v1.2.4
46+
revision = v1.2.5
4747

4848
[provide]
4949
fossil-test = fossil_test_dep

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.4"
22+
#define FOSSIL_PIZZA_VERSION "1.2.5"
2323
#define FOSSIL_PIZZA_AUTHOR "Fossil Logic"
2424
#define FOSSIL_PIZZA_WEBSITE "https://fossillogic.com"
2525

code/logic/fossil/pizza/sanity.h

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,36 @@ int fossil_sanity_sys_create_file(const char* filename);
8787
*/
8888
int fossil_sanity_sys_file_exists(const char* filename);
8989

90+
/**
91+
* @brief Creates an empty directory at the specified location.
92+
*
93+
* This function attempts to create an empty directory with the given name. If the directory
94+
* already exists, the function may return an error or success depending on the system's
95+
* behavior. The function returns a status code indicating success or failure.
96+
*
97+
* @param dirname A null-terminated string representing the path to the directory to be created.
98+
* The path can be relative or absolute.
99+
* @return int Returns 0 on successful creation of the directory. Returns a negative value if
100+
* the directory could not be created due to errors such as insufficient permissions
101+
* or invalid paths.
102+
*/
103+
int fossil_sanity_sys_create_dir(const char* dirname);
104+
105+
/**
106+
* @brief Checks whether a directory exists at the specified location.
107+
*
108+
* This function determines if a directory exists at the given path. It can be used to verify
109+
* the presence of a directory before performing operations such as reading or writing. The
110+
* function does not differentiate between regular directories and other file types.
111+
*
112+
* @param dirname A null-terminated string representing the path to the directory to check.
113+
* The path can be relative or absolute.
114+
* @return int Returns 1 if the directory exists, and 0 if it does not exist. Note that this
115+
* function does not check for directory accessibility or permissions.
116+
*/
117+
int fossil_sanity_sys_dir_exists(const char* dirname);
118+
119+
90120
#ifdef __cplusplus
91121
}
92122
#endif
@@ -166,6 +196,35 @@ int fossil_sanity_sys_file_exists(const char* filename);
166196
#define _FOSSIL_SANITY_SYS_FILE_EXISTS(filename) \
167197
fossil_sanity_sys_file_exists(filename)
168198

199+
/**
200+
* @brief Creates an empty directory at the specified location.
201+
* This function attempts to create an empty directory with the given name. If the directory
202+
* already exists, the function may return an error or success depending on the system's
203+
* behavior.
204+
*
205+
* @param dirname A null-terminated string representing the path to the directory to be created.
206+
* The path can be relative or absolute.
207+
* @return int Returns 0 on successful creation of the directory. Returns a negative value if
208+
* the directory could not be created due to errors such as insufficient permissions
209+
* or invalid paths.
210+
*/
211+
#define _FOSSIL_SANITY_SYS_CREATE_DIR(dirname) \
212+
fossil_sanity_sys_create_dir(dirname)
213+
214+
/**
215+
* @brief Checks whether a directory exists at the specified location.
216+
* This function determines if a directory exists at the given path. It can be used to verify
217+
* the presence of a directory before performing operations such as reading or writing. The
218+
* function does not differentiate between regular files, directories, or other file types.
219+
*
220+
* @param dirname A null-terminated string representing the path to the directory to check.
221+
* The path can be relative or absolute.
222+
* @return int Returns 1 if the directory exists, and 0 if it does not exist. Note that this
223+
* function does not check for directory accessibility or permissions.
224+
*/
225+
#define _FOSSIL_SANITY_SYS_DIR_EXISTS(dirname) \
226+
fossil_sanity_sys_dir_exists(dirname)
227+
169228
// *****************************************************************************
170229
// Public API Macros
171230
// *****************************************************************************
@@ -237,4 +296,31 @@ int fossil_sanity_sys_file_exists(const char* filename);
237296
#define FOSSIL_SANITY_SYS_FILE_EXISTS(filename) \
238297
_FOSSIL_SANITY_SYS_FILE_EXISTS(filename)
239298

299+
/**
300+
* @brief Creates an empty directory at the specified location.
301+
* This macro is a wrapper around the _FOSSIL_SANITY_SYS_CREATE_DIR function.
302+
* It is used to create an empty directory with the given name.
303+
*
304+
* @param dirname A null-terminated string representing the path to the directory to be created.
305+
* The path can be relative or absolute.
306+
* @return int Returns 0 on successful creation of the directory. Returns a negative value if
307+
* the directory could not be created due to errors such as insufficient permissions
308+
* or invalid paths.
309+
*/
310+
#define FOSSIL_SANITY_SYS_CREATE_DIR(dirname) \
311+
_FOSSIL_SANITY_SYS_CREATE_DIR(dirname)
312+
313+
/**
314+
* @brief Checks whether a directory exists at the specified location.
315+
* This macro is a wrapper around the _FOSSIL_SANITY_SYS_DIR_EXISTS function.
316+
* It is used to check if a directory exists at the given path.
317+
*
318+
* @param dirname A null-terminated string representing the path to the directory to check.
319+
* The path can be relative or absolute.
320+
* @return int Returns 1 if the directory exists, and 0 if it does not exist. Note that this
321+
* function does not check for directory accessibility or permissions.
322+
*/
323+
#define FOSSIL_SANITY_SYS_DIR_EXISTS(dirname) \
324+
_FOSSIL_SANITY_SYS_DIR_EXISTS(dirname)
325+
240326
#endif // FOSSIL_SANITY_H

code/logic/sanity.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,21 @@ int fossil_sanity_sys_file_exists(const char* filename) {
8585
return (stat(filename, &buffer) == 0); // On Unix-like systems, use the stat function to check if the file exists.
8686
#endif
8787
}
88+
89+
int fossil_sanity_sys_create_dir(const char* dirname) {
90+
#ifdef _WIN32
91+
return CreateDirectoryA(dirname, NULL) ? 0 : -1; // On Windows, use the CreateDirectoryA function to create the directory.
92+
#else
93+
return mkdir(dirname, 0755); // On Unix-like systems, use the mkdir function to create the directory.
94+
#endif
95+
}
96+
97+
int fossil_sanity_sys_dir_exists(const char* dirname) {
98+
#ifdef _WIN32
99+
struct _stat buffer;
100+
return (_stat(dirname, &buffer) == 0 && (buffer.st_mode & _S_IFDIR)); // On Windows, use the _stat function to check if the directory exists.
101+
#else
102+
struct stat buffer;
103+
return (stat(dirname, &buffer) == 0 && S_ISDIR(buffer.st_mode)); // On Unix-like systems, use the stat function to check if the directory exists.
104+
#endif
105+
}

code/logic/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <time.h>
2222
#include <sys/time.h>
2323

24+
2425
jmp_buf test_jump_buffer; // This will hold the jump buffer for longjmp
2526
static int _ASSERT_COUNT = 0; // Counter for the number of assertions
2627

@@ -503,7 +504,6 @@ void fossil_pizza_run_test(const fossil_pizza_engine_t* engine, fossil_pizza_cas
503504
} else {
504505
test_case->result = FOSSIL_PIZZA_CASE_FAIL;
505506
if (engine->pallet.run.fail_fast) {
506-
fossil_pizza_show_cases(suite, engine);
507507
return; // Exit immediately if --fail-fast is enabled
508508
}
509509
}

code/tests/cases/test_sanity.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,34 @@ FOSSIL_TEST(c_sanity_sys_file_exists) {
8787
remove(filename);
8888
} // end case
8989

90+
FOSSIL_TEST(c_sanity_sys_create_dir) {
91+
const char *dirname = "test_dir";
92+
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);
9093

94+
// Test cases
95+
ASSUME_ITS_EQUAL_I32(result, 0); // Directory creation should succeed
96+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1); // Directory should exist
97+
98+
// Cleanup
99+
rmdir(dirname);
100+
} // end case
101+
102+
FOSSIL_TEST(c_sanity_sys_dir_exists) {
103+
const char *dirname = "test_dir_exists";
104+
105+
// Ensure directory does not exist initially
106+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 0);
107+
108+
// Create the directory
109+
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);
110+
ASSUME_ITS_EQUAL_I32(result, 0);
111+
112+
// Test cases
113+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1);
114+
115+
// Cleanup
116+
rmdir(dirname);
117+
} // end case
91118

92119
// * * * * * * * * * * * * * * * * * * * * * * * *
93120
// * Fossil Logic Test Pool
@@ -97,6 +124,8 @@ FOSSIL_TEST_GROUP(c_sanity_test_cases) {
97124
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_getpid);
98125
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_create_file);
99126
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_file_exists);
127+
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_create_dir);
128+
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_dir_exists);
100129

101130
FOSSIL_TEST_REGISTER(c_sanity_suite);
102131
} // end of group

code/tests/cases/test_sanity.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,34 @@ FOSSIL_TEST(cpp_sanity_sys_file_exists) {
8787
remove(filename);
8888
} // end case
8989

90+
FOSSIL_TEST(cpp_sanity_sys_create_dir) {
91+
const char *dirname = "test_dir";
92+
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);
9093

94+
// Test cases
95+
ASSUME_ITS_EQUAL_I32(result, 0); // Directory creation should succeed
96+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1); // Directory should exist
97+
98+
// Cleanup
99+
rmdir(dirname);
100+
} // end case
101+
102+
FOSSIL_TEST(cpp_sanity_sys_dir_exists) {
103+
const char *dirname = "test_dir_exists";
104+
105+
// Ensure directory does not exist initially
106+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 0);
107+
108+
// Create the directory
109+
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);
110+
ASSUME_ITS_EQUAL_I32(result, 0);
111+
112+
// Test cases
113+
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1);
114+
115+
// Cleanup
116+
rmdir(dirname);
117+
} // end case
91118

92119
// * * * * * * * * * * * * * * * * * * * * * * * *
93120
// * Fossil Logic Test Pool
@@ -97,6 +124,8 @@ FOSSIL_TEST_GROUP(cpp_sanity_test_cases) {
97124
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_getpid);
98125
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_create_file);
99126
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_file_exists);
127+
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_create_dir);
128+
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_dir_exists);
100129

101130
FOSSIL_TEST_REGISTER(cpp_sanity_suite);
102131
} // end of group

code/tests/cases/test_tdd.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,6 @@ FOSSIL_TEST(c_assume_run_of_not_soap_tone_detected) {
948948
ASSUME_NOT_SOAP_TONE_DETECTED(text, expected_tone);
949949
} // end case
950950

951-
952951
// * * * * * * * * * * * * * * * * * * * * * * * *
953952
// * Fossil Logic Test Pool
954953
// * * * * * * * * * * * * * * * * * * * * * * * *

code/tests/cases/test_tdd.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,6 @@ FOSSIL_TEST(cpp_assume_run_of_not_soap_tone_detected) {
944944
ASSUME_NOT_SOAP_TONE_DETECTED(text, expected_tone);
945945
} // end case
946946

947-
948947
// * * * * * * * * * * * * * * * * * * * * * * * *
949948
// * Fossil Logic Test Pool
950949
// * * * * * * * * * * * * * * * * * * * * * * * *

0 commit comments

Comments
 (0)