Skip to content
Merged
22 changes: 12 additions & 10 deletions .github/ciimage/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
# Use a specific Debian base image
FROM debian:buster
# Use a specific Debian Bookworm base image
FROM debian:bookworm

# Set environment variables to avoid interaction
ENV DEBIAN_FRONTEND=noninteractive \
TZ=UTC

# Install system dependencies and clean up
RUN apt-get update && \
apt-get install -y \
apt-get install -y --no-install-recommends \
build-essential \
clang \
gcc \
g++ \
gdb \
llvm \
libstdc++-8-dev \
libstdc++-12-dev \
wget \
python3 \
python3-full \
python3-pip \
git && \
git \
ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install Meson and Ninja
RUN python3 -m pip install --no-cache-dir meson ninja==1.10.2
# Install Meson and Ninja using pip
RUN python3 -m pip install --no-cache-dir meson==1.3.0 ninja==1.10.2 --break-system-packages

# Set environment variables
ENV CC=/usr/bin/clang
ENV CXX=/usr/bin/clang++
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV CC=clang \
CXX=clang++ \
LD_LIBRARY_PATH=/usr/local/lib

# Set working directory
WORKDIR /workspace
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ To get started with Pizza Test, ensure you have the following installed:
# ======================
[wrap-git]
url = https://github.com/fossillogic/fossil-test.git
revision = v1.2.4
revision = v1.2.5

[provide]
fossil-test = fossil_test_dep
Expand Down
2 changes: 1 addition & 1 deletion code/logic/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// macro definitions
// *****************************************************************************

#define FOSSIL_PIZZA_VERSION "1.2.4"
#define FOSSIL_PIZZA_VERSION "1.2.5"
#define FOSSIL_PIZZA_AUTHOR "Fossil Logic"
#define FOSSIL_PIZZA_WEBSITE "https://fossillogic.com"

Expand Down
86 changes: 86 additions & 0 deletions code/logic/fossil/pizza/sanity.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,36 @@ int fossil_sanity_sys_create_file(const char* filename);
*/
int fossil_sanity_sys_file_exists(const char* filename);

/**
* @brief Creates an empty directory at the specified location.
*
* This function attempts to create an empty directory with the given name. If the directory
* already exists, the function may return an error or success depending on the system's
* behavior. The function returns a status code indicating success or failure.
*
* @param dirname A null-terminated string representing the path to the directory to be created.
* The path can be relative or absolute.
* @return int Returns 0 on successful creation of the directory. Returns a negative value if
* the directory could not be created due to errors such as insufficient permissions
* or invalid paths.
*/
int fossil_sanity_sys_create_dir(const char* dirname);

/**
* @brief Checks whether a directory exists at the specified location.
*
* This function determines if a directory exists at the given path. It can be used to verify
* the presence of a directory before performing operations such as reading or writing. The
* function does not differentiate between regular directories and other file types.
*
* @param dirname A null-terminated string representing the path to the directory to check.
* The path can be relative or absolute.
* @return int Returns 1 if the directory exists, and 0 if it does not exist. Note that this
* function does not check for directory accessibility or permissions.
*/
int fossil_sanity_sys_dir_exists(const char* dirname);


#ifdef __cplusplus
}
#endif
Expand Down Expand Up @@ -166,6 +196,35 @@ int fossil_sanity_sys_file_exists(const char* filename);
#define _FOSSIL_SANITY_SYS_FILE_EXISTS(filename) \
fossil_sanity_sys_file_exists(filename)

/**
* @brief Creates an empty directory at the specified location.
* This function attempts to create an empty directory with the given name. If the directory
* already exists, the function may return an error or success depending on the system's
* behavior.
*
* @param dirname A null-terminated string representing the path to the directory to be created.
* The path can be relative or absolute.
* @return int Returns 0 on successful creation of the directory. Returns a negative value if
* the directory could not be created due to errors such as insufficient permissions
* or invalid paths.
*/
#define _FOSSIL_SANITY_SYS_CREATE_DIR(dirname) \
fossil_sanity_sys_create_dir(dirname)

/**
* @brief Checks whether a directory exists at the specified location.
* This function determines if a directory exists at the given path. It can be used to verify
* the presence of a directory before performing operations such as reading or writing. The
* function does not differentiate between regular files, directories, or other file types.
*
* @param dirname A null-terminated string representing the path to the directory to check.
* The path can be relative or absolute.
* @return int Returns 1 if the directory exists, and 0 if it does not exist. Note that this
* function does not check for directory accessibility or permissions.
*/
#define _FOSSIL_SANITY_SYS_DIR_EXISTS(dirname) \
fossil_sanity_sys_dir_exists(dirname)

// *****************************************************************************
// Public API Macros
// *****************************************************************************
Expand Down Expand Up @@ -237,4 +296,31 @@ int fossil_sanity_sys_file_exists(const char* filename);
#define FOSSIL_SANITY_SYS_FILE_EXISTS(filename) \
_FOSSIL_SANITY_SYS_FILE_EXISTS(filename)

/**
* @brief Creates an empty directory at the specified location.
* This macro is a wrapper around the _FOSSIL_SANITY_SYS_CREATE_DIR function.
* It is used to create an empty directory with the given name.
*
* @param dirname A null-terminated string representing the path to the directory to be created.
* The path can be relative or absolute.
* @return int Returns 0 on successful creation of the directory. Returns a negative value if
* the directory could not be created due to errors such as insufficient permissions
* or invalid paths.
*/
#define FOSSIL_SANITY_SYS_CREATE_DIR(dirname) \
_FOSSIL_SANITY_SYS_CREATE_DIR(dirname)

/**
* @brief Checks whether a directory exists at the specified location.
* This macro is a wrapper around the _FOSSIL_SANITY_SYS_DIR_EXISTS function.
* It is used to check if a directory exists at the given path.
*
* @param dirname A null-terminated string representing the path to the directory to check.
* The path can be relative or absolute.
* @return int Returns 1 if the directory exists, and 0 if it does not exist. Note that this
* function does not check for directory accessibility or permissions.
*/
#define FOSSIL_SANITY_SYS_DIR_EXISTS(dirname) \
_FOSSIL_SANITY_SYS_DIR_EXISTS(dirname)

#endif // FOSSIL_SANITY_H
18 changes: 18 additions & 0 deletions code/logic/sanity.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,21 @@ int fossil_sanity_sys_file_exists(const char* filename) {
return (stat(filename, &buffer) == 0); // On Unix-like systems, use the stat function to check if the file exists.
#endif
}

int fossil_sanity_sys_create_dir(const char* dirname) {
#ifdef _WIN32
return CreateDirectoryA(dirname, NULL) ? 0 : -1; // On Windows, use the CreateDirectoryA function to create the directory.
#else
return mkdir(dirname, 0755); // On Unix-like systems, use the mkdir function to create the directory.
#endif
}

int fossil_sanity_sys_dir_exists(const char* dirname) {
#ifdef _WIN32
struct _stat buffer;
return (_stat(dirname, &buffer) == 0 && (buffer.st_mode & _S_IFDIR)); // On Windows, use the _stat function to check if the directory exists.
#else
struct stat buffer;
return (stat(dirname, &buffer) == 0 && S_ISDIR(buffer.st_mode)); // On Unix-like systems, use the stat function to check if the directory exists.
#endif
}
2 changes: 1 addition & 1 deletion code/logic/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <time.h>
#include <sys/time.h>


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

Expand Down Expand Up @@ -503,7 +504,6 @@ void fossil_pizza_run_test(const fossil_pizza_engine_t* engine, fossil_pizza_cas
} else {
test_case->result = FOSSIL_PIZZA_CASE_FAIL;
if (engine->pallet.run.fail_fast) {
fossil_pizza_show_cases(suite, engine);
return; // Exit immediately if --fail-fast is enabled
}
}
Expand Down
29 changes: 29 additions & 0 deletions code/tests/cases/test_sanity.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,34 @@ FOSSIL_TEST(c_sanity_sys_file_exists) {
remove(filename);
} // end case

FOSSIL_TEST(c_sanity_sys_create_dir) {
const char *dirname = "test_dir";
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);

// Test cases
ASSUME_ITS_EQUAL_I32(result, 0); // Directory creation should succeed
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1); // Directory should exist

// Cleanup
rmdir(dirname);
} // end case

FOSSIL_TEST(c_sanity_sys_dir_exists) {
const char *dirname = "test_dir_exists";

// Ensure directory does not exist initially
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 0);

// Create the directory
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);
ASSUME_ITS_EQUAL_I32(result, 0);

// Test cases
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1);

// Cleanup
rmdir(dirname);
} // end case

// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Pool
Expand All @@ -97,6 +124,8 @@ FOSSIL_TEST_GROUP(c_sanity_test_cases) {
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_getpid);
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_create_file);
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_file_exists);
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_create_dir);
FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_dir_exists);

FOSSIL_TEST_REGISTER(c_sanity_suite);
} // end of group
29 changes: 29 additions & 0 deletions code/tests/cases/test_sanity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,34 @@ FOSSIL_TEST(cpp_sanity_sys_file_exists) {
remove(filename);
} // end case

FOSSIL_TEST(cpp_sanity_sys_create_dir) {
const char *dirname = "test_dir";
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);

// Test cases
ASSUME_ITS_EQUAL_I32(result, 0); // Directory creation should succeed
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1); // Directory should exist

// Cleanup
rmdir(dirname);
} // end case

FOSSIL_TEST(cpp_sanity_sys_dir_exists) {
const char *dirname = "test_dir_exists";

// Ensure directory does not exist initially
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 0);

// Create the directory
int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname);
ASSUME_ITS_EQUAL_I32(result, 0);

// Test cases
ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1);

// Cleanup
rmdir(dirname);
} // end case

// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Pool
Expand All @@ -97,6 +124,8 @@ FOSSIL_TEST_GROUP(cpp_sanity_test_cases) {
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_getpid);
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_create_file);
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_file_exists);
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_create_dir);
FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_dir_exists);

FOSSIL_TEST_REGISTER(cpp_sanity_suite);
} // end of group
1 change: 0 additions & 1 deletion code/tests/cases/test_tdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,6 @@ FOSSIL_TEST(c_assume_run_of_not_soap_tone_detected) {
ASSUME_NOT_SOAP_TONE_DETECTED(text, expected_tone);
} // end case


// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Pool
// * * * * * * * * * * * * * * * * * * * * * * * *
Expand Down
1 change: 0 additions & 1 deletion code/tests/cases/test_tdd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,6 @@ FOSSIL_TEST(cpp_assume_run_of_not_soap_tone_detected) {
ASSUME_NOT_SOAP_TONE_DETECTED(text, expected_tone);
} // end case


// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Pool
// * * * * * * * * * * * * * * * * * * * * * * * *
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('Pizza Test', 'c', 'cpp',
meson_version: '>=1.3.0',
license: 'MPL-2.0',
version: '1.2.4',
version: '1.2.5',
default_options: ['c_std=c11,c18', 'cpp_std=c++20'])

subdir('code')
Loading