From 4f1c77c4b6bce02a19cc9ee93ab3a05bd137d63c Mon Sep 17 00:00:00 2001 From: "Enrico Fraccaroli (Galfurian)" Date: Mon, 9 Mar 2026 12:06:04 +0100 Subject: [PATCH 1/3] refactor(tests): centralize big-write logic; expose scheduler type to userspace and misc updates --- kernel/src/tests/unit/test_fpu.c | 2 +- lib/inc/sched.h | 2 + userspace/bin/runtests.c | 26 +- userspace/tests/CMakeLists.txt | 79 +++-- userspace/tests/t_big_write.c | 118 ++++---- userspace/tests/t_ext2_audit_mount_cache.c | 202 ------------- userspace/tests/t_ext2_audit_overflow.c | 177 ------------ userspace/tests/t_ext2_audit_read_failure.c | 272 ------------------ userspace/tests/t_ext2_audit_write_boundary.c | 230 --------------- userspace/tests/t_periodic1.c | 4 + userspace/tests/t_periodic2.c | 4 + userspace/tests/t_periodic3.c | 4 + userspace/tests/t_scanf.c | 29 -- userspace/tests/t_time.c | 7 +- 14 files changed, 140 insertions(+), 1016 deletions(-) delete mode 100644 userspace/tests/t_ext2_audit_mount_cache.c delete mode 100644 userspace/tests/t_ext2_audit_overflow.c delete mode 100644 userspace/tests/t_ext2_audit_read_failure.c delete mode 100644 userspace/tests/t_ext2_audit_write_boundary.c delete mode 100644 userspace/tests/t_scanf.c diff --git a/kernel/src/tests/unit/test_fpu.c b/kernel/src/tests/unit/test_fpu.c index 8def6b24..ad2079f1 100644 --- a/kernel/src/tests/unit/test_fpu.c +++ b/kernel/src/tests/unit/test_fpu.c @@ -165,4 +165,4 @@ void test_fpu(void) test_fpu_exp(); test_fpu_pi_precision(); test_fpu_loop_accumulation(); -} \ No newline at end of file +} diff --git a/lib/inc/sched.h b/lib/inc/sched.h index 0bfc5c37..15a84117 100644 --- a/lib/inc/sched.h +++ b/lib/inc/sched.h @@ -7,6 +7,8 @@ #include "sys/types.h" #include "time.h" +#define REALTIME_SCHEDULER_SUPPORT !SCHEDULER_RR + /// @brief Structure that describes scheduling parameters. typedef struct sched_param { /// Static execution priority. diff --git a/userspace/bin/runtests.c b/userspace/bin/runtests.c index a668df06..eea0bbc5 100644 --- a/userspace/bin/runtests.c +++ b/userspace/bin/runtests.c @@ -28,12 +28,14 @@ static char *all_tests[] = { "t_creat", "t_dup", "t_environ", - "t_exit", "t_exec", + "t_exit", + "t_fflush", + "t_fhs", "t_fork", "t_gid", - "t_grp", "t_groups", + "t_grp", "t_hashmap", "t_itimer", "t_kill", @@ -42,9 +44,9 @@ static char *all_tests[] = { "t_mkdir", "t_msgget", "t_ndtree", - // "t_periodic1", - // "t_periodic2", - // "t_periodic3", + "t_periodic1", + "t_periodic2", + "t_periodic3", "t_pipe_blocking", "t_pipe_non_blocking", "t_pwd", @@ -63,7 +65,7 @@ static char *all_tests[] = { "t_spwd", "t_stopcont", "t_syslog", - // "t_time", + "t_time", "t_write_read", }; @@ -78,12 +80,12 @@ static int test_err_fd; static int init; -#define append(...) \ - do { \ - bufpos += sprintf(bufpos, __VA_ARGS__); \ - if (bufpos >= buf + sizeof(buf)) { \ - return -1; \ - } \ +#define append(...) \ + do { \ + bufpos += sprintf(bufpos, __VA_ARGS__); \ + if (bufpos >= buf + sizeof(buf)) { \ + return -1; \ + } \ } while (0); static int test_out_flush(void) diff --git a/userspace/tests/CMakeLists.txt b/userspace/tests/CMakeLists.txt index 598cc704..57b9b3d3 100644 --- a/userspace/tests/CMakeLists.txt +++ b/userspace/tests/CMakeLists.txt @@ -1,56 +1,51 @@ # List of programs. set(TEST_LIST - t_exit.c - # t_time.c # Temporarily disabled - t_chdir.c - t_grp.c - t_pwd.c - t_mkdir.c t_dup.c + t_hashmap.c + t_list.c + t_msgget.c + t_pipe_blocking.c + t_syslog.c + t_periodic2.c + t_sigfpe.c t_creat.c + t_itimer.c + t_schedfb.c t_write_read.c + t_abort.c + t_shmget.c + t_exec.c t_gid.c + t_grp.c + t_stopcont.c + t_ndtree.c + t_pwd.c + t_fflush.c + t_sigusr.c + t_kill.c + t_periodic1.c + t_chdir.c + t_fhs.c + t_spwd.c + t_shm.c + t_semget.c + t_mkdir.c t_alarm.c - t_periodic3.c + t_exit.c t_environ.c - t_itimer.c - t_fork.c - t_semget.c - t_exec.c - t_sleep.c - t_periodic2.c - t_pipe_blocking.c + t_siginfo.c t_pipe_non_blocking.c - t_sigfpe.c + t_sleep.c + t_mem.c + t_fork.c + t_semflg.c + t_time.c + t_big_write.c t_sigmask.c - t_sigusr.c - t_shmget.c - t_stopcont.c - t_semop.c t_sigaction.c - t_schedfb.c - t_siginfo.c + t_periodic3.c + t_semop.c t_groups.c - t_semflg.c - t_abort.c - t_msgget.c - t_periodic1.c - t_kill.c - t_shm.c - t_mem.c - t_spwd.c - t_big_write.c - t_syslog.c - t_ndtree.c - t_list.c - t_hashmap.c - t_scanf.c - t_fflush.c - t_fhs.c - t_ext2_audit_write_boundary.c - t_ext2_audit_overflow.c - t_ext2_audit_read_failure.c - t_ext2_audit_mount_cache.c ) # Set the directory where the compiled binaries will be placed. @@ -90,6 +85,8 @@ foreach(FILE_NAME ${TEST_LIST}) target_link_libraries(${TARGET_NAME} libc) # We need to specify the name of the entry function. target_compile_options(${TARGET_NAME} PRIVATE -u_start) + # Add the define stating which scheduler is currently active. + target_compile_definitions(${TARGET_NAME} PRIVATE ${SCHEDULER_TYPE}) # Add the linking properties. set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "-Wl,-Ttext=${TEXT_ADDR},-e_start,-melf_i386") # Set the output directory. diff --git a/userspace/tests/t_big_write.c b/userspace/tests/t_big_write.c index 2438569a..b54bb108 100644 --- a/userspace/tests/t_big_write.c +++ b/userspace/tests/t_big_write.c @@ -15,84 +15,104 @@ #include #include -#define FILENAME "/home/user/test.txt" -#define ITERATIONS 8 +#define FILENAME "/tmp/test.txt" +#define ITERATIONS 4 #define BUFFER_SIZE BUFSIZ -int main(int argc, char *argv[]) +int write_test_data(const char *filename, int iterations) { - mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; - char write_buffer[BUFFER_SIZE] = {0}; - char read_buffer[BUFFER_SIZE] = {0}; - - // Open the file with specified flags and mode. - int fd = open(FILENAME, O_WRONLY | O_CREAT | O_TRUNC, mode); + int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); if (fd < 0) { - syslog(LOG_ERR, "[t_big_write] Failed to open file %s: %s\n", FILENAME, strerror(errno)); + syslog(LOG_ERR, "Failed to open file %s: %s\n", filename, strerror(errno)); return EXIT_FAILURE; } - - // Write test data to the file. - for (unsigned times = 0; times < ITERATIONS; ++times) { + int result = EXIT_SUCCESS; + char buffer[BUFFER_SIZE]; + for (unsigned times = 0; times < iterations; ++times) { for (unsigned i = 'A'; i < 'z'; ++i) { - memset(write_buffer, i, sizeof(write_buffer)); - if (write(fd, write_buffer, sizeof(write_buffer)) < 0) { - syslog(LOG_ERR, "[t_big_write] Writing to file %s failed: %s\n", FILENAME, strerror(errno)); - close(fd); - unlink(FILENAME); - return EXIT_FAILURE; + memset(buffer, i, sizeof(buffer)); + if (write(fd, buffer, sizeof(buffer)) < 0) { + syslog(LOG_ERR, "Writing to file %s failed: %s\n", filename, strerror(errno)); + result = EXIT_FAILURE; + goto write_close_and_cleanup; } } } - // Close the file descriptor. +write_close_and_cleanup: + // Close the file descriptor and unlink the file after the test is done. if (close(fd) < 0) { - syslog(LOG_ERR, "[t_big_write] Failed to close file %s: %s\n", FILENAME, strerror(errno)); - unlink(FILENAME); - return EXIT_FAILURE; + syslog(LOG_ERR, "Failed to close file %s: %s\n", filename, strerror(errno)); + result = EXIT_FAILURE; + } + // Unlink the file after the test is done. + if (unlink(FILENAME) < 0) { + syslog(LOG_ERR, "Failed to delete file %s: %s\n", FILENAME, strerror(errno)); + result = EXIT_FAILURE; } + return result; +} - // Open the file with specified flags and mode. - fd = open(FILENAME, O_RDONLY, mode); +int read_and_verify_test_data(const char *filename, int iterations) +{ + int fd = open(filename, O_RDONLY, 0); if (fd < 0) { - syslog(LOG_ERR, "[t_big_write] Failed to open file %s: %s\n", FILENAME, strerror(errno)); - unlink(FILENAME); + syslog(LOG_ERR, "Failed to open file %s: %s\n", filename, strerror(errno)); return EXIT_FAILURE; } - // Read and verify data from the file. - for (unsigned times = 0; times < ITERATIONS; ++times) { - for (unsigned i = 'A'; i < 'z'; ++i) { - memset(write_buffer, i, sizeof(write_buffer)); - if (read(fd, read_buffer, sizeof(read_buffer)) < 0) { - syslog(LOG_ERR, "[t_big_write] Reading from file %s failed: %s\n", FILENAME, strerror(errno)); - close(fd); - unlink(FILENAME); - return EXIT_FAILURE; + int result = EXIT_SUCCESS; + char read_buf[BUFFER_SIZE]; + char expected[BUFFER_SIZE]; + + for (unsigned pass = 0; pass < iterations; ++pass) { + for (unsigned ch = 'A'; ch < 'z'; ++ch) { + /* prepare the expected pattern for this character */ + memset(expected, ch, sizeof(expected)); + + ssize_t got = read(fd, read_buf, sizeof(read_buf)); + if (got < 0) { + syslog(LOG_ERR, "Reading from file %s failed: %s\n", filename, strerror(errno)); + result = EXIT_FAILURE; + goto read_close_and_cleanup; } - // Verify read data matches what was written. - if (memcmp(write_buffer, read_buffer, sizeof(write_buffer)) != 0) { - syslog(LOG_ERR, "[t_big_write] Data mismatch in file %s at iteration %u, char %c\n", FILENAME, times, i); - close(fd); - unlink(FILENAME); - return EXIT_FAILURE; + if (got != (ssize_t)sizeof(read_buf)) { + syslog(LOG_ERR, "Unexpected read length %zd from %s\n", got, filename); + result = EXIT_FAILURE; + goto read_close_and_cleanup; + } + + if (memcmp(read_buf, expected, sizeof(read_buf)) != 0) { + syslog(LOG_ERR, "Data mismatch in file %s at iteration %u, char %c\n", filename, pass, ch); + result = EXIT_FAILURE; + goto read_close_and_cleanup; } } } - // Close the file descriptor. +read_close_and_cleanup: + // Close the file descriptor and unlink the file after the test is done. if (close(fd) < 0) { - syslog(LOG_ERR, "[t_big_write] Failed to close file %s: %s\n", FILENAME, strerror(errno)); - unlink(FILENAME); - return EXIT_FAILURE; + syslog(LOG_ERR, "Failed to close file %s: %s\n", filename, strerror(errno)); + result = EXIT_FAILURE; } - - // Delete the test file. + // Unlink the file after the test is done. if (unlink(FILENAME) < 0) { - syslog(LOG_ERR, "[t_big_write] Failed to delete file %s: %s\n", FILENAME, strerror(errno)); + syslog(LOG_ERR, "Failed to delete file %s: %s\n", FILENAME, strerror(errno)); + result = EXIT_FAILURE; + } + return result; +} + +int main(int argc, char *argv[]) +{ + if (write_test_data(FILENAME, ITERATIONS) != EXIT_SUCCESS) { return EXIT_FAILURE; } + if (read_and_verify_test_data(FILENAME, ITERATIONS) != EXIT_SUCCESS) { + return EXIT_FAILURE; + } return EXIT_SUCCESS; } diff --git a/userspace/tests/t_ext2_audit_mount_cache.c b/userspace/tests/t_ext2_audit_mount_cache.c deleted file mode 100644 index 2aa6d3d5..00000000 --- a/userspace/tests/t_ext2_audit_mount_cache.c +++ /dev/null @@ -1,202 +0,0 @@ -/// @file t_mount_cache.c -/// @brief Test case for Issue #4: Missing NULL check after kmem_cache_create -/// @details -/// This test verifies that filesystem mounting handles cache allocation -/// failures gracefully. The bug: kmem_cache_create() result not checked, -/// could lead to NULL pointer dereference. -/// -/// This test mainly validates that normal mount completes successfully -/// and can perform basic I/O operations that would use the cache. -/// -/// @copyright (c) 2024 - Audit Fix Test -/// @see EXT2_AUDIT_REPORT.md - Issue #4 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TEST_FILE "/tmp/test_mount_cache.txt" -#define TEST_DATA "CACHE_TEST_DATA" - -/// @brief Test that filesystem is operational after mount -/// This indirectly verifies the cache was properly initialized -/// @return 0 on success, 1 on failure -int test_mount_operational(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] [TEST] Filesystem operational after mount...\n"); - - // If the filesystem mounted successfully and is operational, - // the cache must have been created properly - - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] Failed to open file - filesystem may not be mounted: %s\n", strerror(errno)); - return 1; - } - - // Try to write - this uses the cache system - ssize_t written = write(fd, TEST_DATA, strlen(TEST_DATA)); - close(fd); - - if (written != (ssize_t)strlen(TEST_DATA)) { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] Write failed or incomplete\n"); - return 1; - } - - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] ✓ File write successful (cache operational)\n"); - return 0; -} - -/// @brief Test that multiple operations work (stress the cache) -/// @return 0 on success, 1 on failure -int test_cache_under_load(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] [TEST] Cache under load...\n"); - - // Create multiple files in quick succession - // This stresses the cache system - - for (int i = 0; i < 10; i++) { - char filename[64]; - snprintf(filename, sizeof(filename), "/tmp/cache_test_%d.txt", i); - - int fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] Failed to create file %d", i); - return 1; - } - - // Write different amount of data to each - char data[1024]; - memset(data, (char)('0' + i), sizeof(data)); - - ssize_t to_write = (i + 1) * 100; // 100, 200, 300... - ssize_t written = write(fd, data, to_write); - close(fd); - - if (written != to_write) { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] Write to file %d incomplete: %ld of %ld\n", i, written, to_write); - return 1; - } - } - - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] ✓ Multiple operations successful\n"); - return 0; -} - -/// @brief Test that reads also use cache properly -/// @return 0 on success, 1 on failure -int test_cache_on_reads(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] [TEST] Cache used on reads...\n"); - - // Create a file with multi-block data - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] Failed to create file: %s\n", strerror(errno)); - return 1; - } - - char data[8192]; - memset(data, 0x42, sizeof(data)); - - write(fd, data, sizeof(data)); - close(fd); - - // Read it back - uses cache - fd = open(TEST_FILE, O_RDONLY, 0); - char buffer[8192]; - ssize_t bytes = read(fd, buffer, sizeof(buffer)); - close(fd); - - if (bytes != sizeof(data)) { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] Read failed\n"); - return 1; - } - - // Verify data (would fail if cache corrupted) - if (memcmp(buffer, data, sizeof(data)) != 0) { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] Data corruption detected\n"); - return 1; - } - - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] ✓ Cache functional on reads\n"); - return 0; -} - -/// @brief Test sequential read/write cycles -/// @return 0 on success, 1 on failure -int test_cache_lifecycle(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] [TEST] Cache lifecycle...\n"); - - // Cycle through write-read multiple times - for (int cycle = 0; cycle < 5; cycle++) { - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] Failed to open for write in cycle %d\n", cycle); - return 1; - } - - char write_data[1024]; - memset(write_data, (char)('A' + cycle), sizeof(write_data)); - - write(fd, write_data, sizeof(write_data)); - close(fd); - - // Now read back - fd = open(TEST_FILE, O_RDONLY, 0); - char read_data[1024]; - ssize_t bytes = read(fd, read_data, sizeof(read_data)); - close(fd); - - if (bytes != sizeof(write_data)) { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] Read failed in cycle %d\n", cycle); - return 1; - } - - if (memcmp(write_data, read_data, sizeof(write_data)) != 0) { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] Data mismatch in cycle %d\n", cycle); - return 1; - } - } - - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] ✓ Cache lifecycle stable\n"); - return 0; -} - -int main(void) -{ - openlog("t_ext2_mount_cache", LOG_CONS | LOG_PID, LOG_USER); - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] \n=== EXT2 Mount Cache Test Suite ===\n"); - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] Testing: Issue #4 - Missing NULL check after kmem_cache_create\n"); - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] Location: ext2.c:3772 in ext2_mount()\n"); - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] Bug: kmem_cache_create() result not checked\n"); - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] Note: This test verifies filesystem is fully operational\n"); - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] (which proves cache was initialized)\n\n"); - - int failures = 0; - - failures += test_mount_operational(); - failures += test_cache_under_load(); - failures += test_cache_on_reads(); - failures += test_cache_lifecycle(); - - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] === Results ===\n"); - if (failures == 0) { - syslog(LOG_INFO, "[t_ext2_audit_mount_cache] ✅ ALL TESTS PASSED\n"); - closelog(); - return 0; - } else { - syslog(LOG_ERR, "[t_ext2_audit_mount_cache] ❌ %d TEST(S) FAILED\n", failures); - closelog(); - return 1; - } -} diff --git a/userspace/tests/t_ext2_audit_overflow.c b/userspace/tests/t_ext2_audit_overflow.c deleted file mode 100644 index a7fc36cb..00000000 --- a/userspace/tests/t_ext2_audit_overflow.c +++ /dev/null @@ -1,177 +0,0 @@ -/// @file t_overflow.c -/// @brief Test case for Issue #2: Integer overflow in write operations -/// @details -/// This test verifies that writing with large offsets and sizes doesn't -/// cause integer overflow. The bug: offset + nbyte can overflow if both -/// are large, causing write to wrong location. -/// -/// @copyright (c) 2024 - Audit Fix Test -/// @see EXT2_AUDIT_REPORT.md - Issue #2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TEST_FILE "/tmp/test_overflow.txt" - -/// @brief Test that very large offsets are handled safely -/// @return 0 on success, 1 on failure -int test_large_offset_handling(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_overflow] [TEST] Large offset handling...\n"); - - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_overflow] Failed to create test file: %s\n", strerror(errno)); - return 1; - } - - // Try to write at a very large offset - // This should either succeed with proper file extension, - // or fail gracefully with EOVERFLOW or similar - off_t large_offset = 1024 * 1024 * 100; // 100MB offset - - if (lseek(fd, large_offset, SEEK_SET) < 0) { - syslog(LOG_INFO, "[t_ext2_audit_overflow] - lseek to large offset failed (expected on some systems)\n"); - close(fd); - return 0; // Not a test failure, just system limitation - } - - char test_data[] = "test"; - ssize_t written = write(fd, test_data, strlen(test_data)); - - if (written < 0) { - syslog(LOG_INFO, "[t_ext2_audit_overflow] - Write at large offset failed (may be expected)\n"); - close(fd); - return 0; // Not a failure, system may not support it - } - - if (written != (ssize_t)strlen(test_data)) { - syslog(LOG_ERR, "[t_ext2_audit_overflow] Write partial data at large offset\n"); - close(fd); - return 1; - } - - close(fd); - syslog(LOG_INFO, "[t_ext2_audit_overflow] ✓ Large offset handled safely\n"); - return 0; -} - -/// @brief Test boundary conditions near uint32_t limits -/// @return 0 on success, 1 on failure -int test_near_uint32_boundary(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_overflow] [TEST] Near uint32_t boundary conditions...\n"); - - // This is a structural test - it simulates what the ext2_write_inode_data - // function does without actually creating huge files - - // The vulnerable code is: - // uint32_t end_offset = (inode->size >= offset + nbyte) ? (offset + nbyte) : (inode->size); - - // This can overflow if: - uint32_t offset = 0xFFFFFFF0; // Very large offset - uint32_t nbyte = 0x20; // Small write, but offset + nbyte overflows - - // Simulating the vulnerable check: - // if ((offset + nbyte) > inode->size) - - // In C, this addition would overflow - uint32_t sum = offset + nbyte; // Overflows! - - syslog(LOG_INFO, "[t_ext2_audit_overflow] Offset: 0x%08X (%u)\n", offset, offset); - syslog(LOG_INFO, "[t_ext2_audit_overflow] Nbyte: 0x%08X (%u)\n", nbyte, nbyte); - syslog(LOG_INFO, "[t_ext2_audit_overflow] Sum: 0x%08X (%u) - OVERFLOW OCCURRED\n", sum, sum); - - // A properly fixed version should catch this - if (offset > UINT32_MAX - nbyte) { - syslog(LOG_INFO, "[t_ext2_audit_overflow] ✓ Overflow would be detected by proper bounds check\n"); - } else { - syslog(LOG_INFO, "[t_ext2_audit_overflow] ✗ Overflow not detected - vulnerable!\n"); - } - - return 0; // This is a demonstration test -} - -/// @brief Test mixed boundary conditions -/// @return 0 on success, 1 on failure -int test_mixed_boundary_conditions(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_overflow] [TEST] Mixed boundary conditions...\n"); - - // Create a real file and test realistic but large writes - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_overflow] Failed to create test file: %s\n", strerror(errno)); - return 1; - } - - // Write a known pattern - char pattern[] = "BOUNDARY_TEST"; - - // First write: normal - if (write(fd, pattern, strlen(pattern)) != (ssize_t)strlen(pattern)) { - syslog(LOG_ERR, "[t_ext2_audit_overflow] Initial write failed\n"); - close(fd); - return 1; - } - - // Second write: ensure offset tracking is correct - if (write(fd, pattern, strlen(pattern)) != (ssize_t)strlen(pattern)) { - syslog(LOG_ERR, "[t_ext2_audit_overflow] Second write failed\n"); - close(fd); - return 1; - } - - // Verify file has both patterns - struct stat st; - if (fstat(fd, &st) < 0) { - syslog(LOG_ERR, "[t_ext2_audit_overflow] Failed to fstat file: %s\n", strerror(errno)); - close(fd); - return 1; - } - - close(fd); - - size_t expected_size_t = strlen(pattern) * 2; - if (st.st_size != expected_size_t) { - syslog(LOG_ERR, "[t_ext2_audit_overflow] File size mismatch: expected %zu, got %ld\n", expected_size_t, st.st_size); - return 1; - } - - syslog(LOG_INFO, "[t_ext2_audit_overflow] ✓ Boundary conditions handled correctly\n"); - return 0; -} - -int main(void) -{ - openlog("t_ext2_overflow", LOG_CONS | LOG_PID, LOG_USER); - syslog(LOG_INFO, "[t_ext2_audit_overflow] \n=== EXT2 Overflow Test Suite ===\n"); - syslog(LOG_INFO, "[t_ext2_audit_overflow] Testing: Issue #2 - Integer overflow in write operations\n"); - syslog(LOG_INFO, "[t_ext2_audit_overflow] Location: ext2.c:1876 in ext2_write_inode_data()\n"); - syslog(LOG_INFO, "[t_ext2_audit_overflow] Bug: No check for offset + nbyte overflow\n\n"); - - int failures = 0; - - failures += test_large_offset_handling(); - failures += test_near_uint32_boundary(); - failures += test_mixed_boundary_conditions(); - - syslog(LOG_INFO, "[t_ext2_audit_overflow] === Results ===\n"); - if (failures == 0) { - syslog(LOG_INFO, "[t_ext2_audit_overflow] ✅ ALL TESTS PASSED\n"); - closelog(); - return 0; - } else { - syslog(LOG_ERR, "[t_ext2_audit_overflow] ❌ %d TEST(S) FAILED\n", failures); - closelog(); - return 1; - } -} diff --git a/userspace/tests/t_ext2_audit_read_failure.c b/userspace/tests/t_ext2_audit_read_failure.c deleted file mode 100644 index 747926d0..00000000 --- a/userspace/tests/t_ext2_audit_read_failure.c +++ /dev/null @@ -1,272 +0,0 @@ -/// @file t_read_failure.c -/// @brief Test case for Issue #3: Silent read failures -/// @details -/// This test verifies that read failures are properly reported and don't -/// return stale/corrupted data. The bug: when a block read fails, the code -/// continues with cached data without indicating error. -/// -/// @copyright (c) 2024 - Audit Fix Test -/// @see EXT2_AUDIT_REPORT.md - Issue #3 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TEST_FILE "/tmp/test_read_basic.txt" -#define TEST_DATA_SIZE 8192 - -/// @brief Test basic read from newly written file -/// @return 0 on success, 1 on failure -int test_read_after_write(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_read_failure] [TEST] Read after write...\n"); - - // Create test file with known content - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Failed to create test file: %s\n", strerror(errno)); - return 1; - } - - // Write distinguishable pattern - char *write_data = malloc(TEST_DATA_SIZE); - for (int i = 0; i < TEST_DATA_SIZE; i++) { - write_data[i] = (char)(i & 0xFF); - } - - ssize_t written = write(fd, write_data, TEST_DATA_SIZE); - close(fd); - - if (written != TEST_DATA_SIZE) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Failed to write all data\n"); - free(write_data); - return 1; - } - - // Now read it back - fd = open(TEST_FILE, O_RDONLY, 0); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Failed to open for reading: %s\n", strerror(errno)); - free(write_data); - return 1; - } - - char *read_data = malloc(TEST_DATA_SIZE); - ssize_t read_bytes = read(fd, read_data, TEST_DATA_SIZE); - close(fd); - - if (read_bytes != TEST_DATA_SIZE) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Read failed or incomplete: %ld bytes\n", read_bytes); - free(write_data); - free(read_data); - return 1; - } - - // Verify data integrity - if (memcmp(write_data, read_data, TEST_DATA_SIZE) != 0) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Data mismatch after read\n"); - free(write_data); - free(read_data); - return 1; - } - - syslog(LOG_INFO, "[t_ext2_audit_read_failure] ✓ Read data matches written data\n"); - free(write_data); - free(read_data); - return 0; -} - -/// @brief Test reading across block boundaries -/// @return 0 on success, 1 on failure -int test_read_across_blocks(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_read_failure] [TEST] Read across block boundaries...\n"); - - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Failed to create test file: %s\n", strerror(errno)); - return 1; - } - - // Write 3 blocks worth of data - const int block_size = 4096; - char *write_data = malloc(block_size * 3); - - // Fill with repeating pattern - for (int i = 0; i < block_size * 3; i++) { - write_data[i] = (char)((i / block_size) + 'A'); // Different byte per block - } - - ssize_t written = write(fd, write_data, block_size * 3); - close(fd); - - if (written != block_size * 3) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Failed to write\n"); - free(write_data); - return 1; - } - - // Read back and verify each block - fd = open(TEST_FILE, O_RDONLY, 0); - char *read_data = malloc(block_size * 3); - ssize_t read_bytes = read(fd, read_data, block_size * 3); - close(fd); - - if (read_bytes != block_size * 3) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Failed to read all blocks\n"); - free(write_data); - free(read_data); - return 1; - } - - // Verify block by block - for (int block = 0; block < 3; block++) { - char expected = 'A' + block; - for (int i = 0; i < block_size; i++) { - int offset = block * block_size + i; - if (read_data[offset] != expected) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Block %d byte %d mismatch\n", block, i); - free(write_data); - free(read_data); - return 1; - } - } - } - - syslog(LOG_INFO, "[t_ext2_audit_read_failure] ✓ All blocks read correctly\n"); - free(write_data); - free(read_data); - return 0; -} - -/// @brief Test partial reads from file -/// @return 0 on success, 1 on failure -int test_partial_reads(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_read_failure] [TEST] Partial reads...\n"); - - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Failed to create test file: %s\n", strerror(errno)); - return 1; - } - - // Write known data - char *data = malloc(TEST_DATA_SIZE); - for (int i = 0; i < TEST_DATA_SIZE; i++) { - data[i] = (char)(i & 0xFF); - } - - write(fd, data, TEST_DATA_SIZE); - close(fd); - - // Read in small chunks - fd = open(TEST_FILE, O_RDONLY, 0); - const int chunk_size = 1000; - char chunk[chunk_size]; - int total_read = 0; - - while (1) { - ssize_t bytes = read(fd, chunk, chunk_size); - if (bytes <= 0) - break; - - // Verify this chunk - for (int i = 0; i < bytes; i++) { - char expected = (char)((total_read + i) & 0xFF); - if (chunk[i] != expected) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Chunk read mismatch at offset %d\n", total_read + i); - close(fd); - free(data); - return 1; - } - } - - total_read += bytes; - } - - close(fd); - - if (total_read != TEST_DATA_SIZE) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Did not read all data: got %d of %d\n", total_read, TEST_DATA_SIZE); - free(data); - return 1; - } - - syslog(LOG_INFO, "[t_ext2_audit_read_failure] ✓ All partial reads consistent and correct\n"); - free(data); - return 0; -} - -/// @brief Test read at EOF -/// @return 0 on success, 1 on failure -int test_read_eof_behavior(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_read_failure] [TEST] Read at EOF behavior...\n"); - - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Failed to create test file: %s\n", strerror(errno)); - return 1; - } - - // Write small amount - write(fd, "small", 5); - close(fd); - - // Try to read beyond EOF - fd = open(TEST_FILE, O_RDONLY, 0); - char buffer[1024]; - - ssize_t bytes = read(fd, buffer, 1024); - if (bytes != 5) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Read at small file returned %ld, expected 5\n", bytes); - close(fd); - return 1; - } - - // Try second read (should return 0 for EOF) - bytes = read(fd, buffer, 1024); - if (bytes != 0) { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] Read at EOF returned %ld, expected 0\n", bytes); - close(fd); - return 1; - } - - close(fd); - syslog(LOG_INFO, "[t_ext2_audit_read_failure] ✓ EOF behavior correct\n"); - return 0; -} - -int main(void) -{ - openlog("t_ext2_read_failure", LOG_CONS | LOG_PID, LOG_USER); - syslog(LOG_INFO, "[t_ext2_audit_read_failure] \n=== EXT2 Read Failure Test Suite ===\n"); - syslog(LOG_INFO, "[t_ext2_audit_read_failure] Testing: Issue #3 - Silent read failures\n"); - syslog(LOG_INFO, "[t_ext2_audit_read_failure] Location: ext2.c:1809-1815 in ext2_read_inode_data()\n"); - syslog(LOG_INFO, "[t_ext2_audit_read_failure] Bug: Error on block read is ignored, stale cache returned\n\n"); - - int failures = 0; - - failures += test_read_after_write(); - failures += test_read_across_blocks(); - failures += test_partial_reads(); - failures += test_read_eof_behavior(); - - syslog(LOG_INFO, "[t_ext2_audit_read_failure] === Results ===\n"); - if (failures == 0) { - syslog(LOG_INFO, "[t_ext2_audit_read_failure] ✅ ALL TESTS PASSED\n"); - closelog(); - return 0; - } else { - syslog(LOG_ERR, "[t_ext2_audit_read_failure] ❌ %d TEST(S) FAILED\n", failures); - closelog(); - return 1; - } -} diff --git a/userspace/tests/t_ext2_audit_write_boundary.c b/userspace/tests/t_ext2_audit_write_boundary.c deleted file mode 100644 index ee948b47..00000000 --- a/userspace/tests/t_ext2_audit_write_boundary.c +++ /dev/null @@ -1,230 +0,0 @@ -/// @file t_write_boundary.c -/// @brief Test case for Issue #1: Buffer overflow on write boundary -/// @details -/// This test verifies that writing data to a file at block boundaries -/// does not cause buffer overflow. The bug manifests when writing the -/// last block - the right boundary should be block_size-1, not block_size. -/// -/// @copyright (c) 2024 - Audit Fix Test -/// @see EXT2_AUDIT_REPORT.md - Issue #1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TEST_FILE "/tmp/test_write_boundary.txt" -#define TEST_DATA_SIZE 8192 // 8KB - spans 2x 4KB blocks -#define BLOCK_SIZE 4096 - -/// @brief Test writing data that spans multiple blocks with unaligned offset -/// @return 0 on success, 1 on failure -int test_unaligned_write_spanning_blocks(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] [TEST] Unaligned write spanning multiple blocks\n"); - - // Create and open file for writing - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to create test file: %s\n", strerror(errno)); - return 1; - } - - // Allocate test data - fill with pattern - char *write_data = malloc(TEST_DATA_SIZE); - if (!write_data) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to allocate write buffer: %s\n", strerror(errno)); - close(fd); - return 1; - } - - // Fill with distinguishable pattern - for (int i = 0; i < TEST_DATA_SIZE; i++) { - write_data[i] = (char)(i & 0xFF); - } - - // Write unaligned: offset 2048, then 8192 bytes - // This will: - // - Start in middle of block 0 (offset 2048, write 2048 bytes) - // - Span into block 1 (write 4096 bytes) - // - End at start of block 2 (write 2048 bytes) - // The bug would overflow when setting right=block_size on the last block - - ssize_t written = write(fd, write_data, TEST_DATA_SIZE); - if (written != TEST_DATA_SIZE) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to write all data: wrote %ld of %d\n", written, TEST_DATA_SIZE); - close(fd); - free(write_data); - return 1; - } - - close(fd); - - // Read back and verify data integrity - fd = open(TEST_FILE, O_RDONLY, 0); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to open test file for reading: %s\n", strerror(errno)); - free(write_data); - return 1; - } - - char *read_data = malloc(TEST_DATA_SIZE); - if (!read_data) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to allocate read buffer: %s\n", strerror(errno)); - close(fd); - free(write_data); - return 1; - } - - ssize_t read_bytes = read(fd, read_data, TEST_DATA_SIZE); - close(fd); - - if (read_bytes != TEST_DATA_SIZE) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to read all data: read %ld of %d\n", read_bytes, TEST_DATA_SIZE); - free(write_data); - free(read_data); - return 1; - } - - // Verify data matches - if (memcmp(write_data, read_data, TEST_DATA_SIZE) != 0) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Data mismatch: written data differs from read data\n"); - free(write_data); - free(read_data); - return 1; - } - - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] ✓ Data written and read back correctly\n"); - free(write_data); - free(read_data); - return 0; -} - -/// @brief Test writing to exact block boundary -/// @return 0 on success, 1 on failure -int test_exact_block_boundary_write(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] [TEST] Write at exact block boundary\n"); - - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to create test file: %s\n", strerror(errno)); - return 1; - } - - // Write exactly 2 blocks worth - char *data = malloc(BLOCK_SIZE * 2); - memset(data, 0xAA, BLOCK_SIZE * 2); - - ssize_t written = write(fd, data, BLOCK_SIZE * 2); - close(fd); - - if (written != BLOCK_SIZE * 2) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to write: wrote %ld of %d\n", written, BLOCK_SIZE * 2); - free(data); - return 1; - } - - // Verify file size - struct stat st; - if (stat(TEST_FILE, &st) < 0) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to stat file: %s\n", strerror(errno)); - free(data); - return 1; - } - - if (st.st_size != BLOCK_SIZE * 2) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] File size mismatch: expected %d, got %ld\n", BLOCK_SIZE * 2, st.st_size); - free(data); - return 1; - } - - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] ✓ Boundary write successful, file size correct\n"); - free(data); - return 0; -} - -/// @brief Test multiple sequential writes (stress test) -/// @return 0 on success, 1 on failure -int test_multiple_partial_writes(void) -{ - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] [TEST] Multiple partial writes\n"); - - int fd = open(TEST_FILE, O_CREAT | O_WRONLY | O_TRUNC, 0644); - if (fd < 0) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to create test file: %s\n", strerror(errno)); - return 1; - } - - // Write in chunks that don't align with block boundaries - const int num_writes = 5; - const int chunk_size = 1500; // Odd size to cause boundary issues - - char *data = malloc(chunk_size); - for (int i = 0; i < chunk_size; i++) { - data[i] = (char)i; - } - - for (int i = 0; i < num_writes; i++) { - ssize_t written = write(fd, data, chunk_size); - if (written != chunk_size) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Write %d failed: wrote %ld of %d\n", i, written, chunk_size); - close(fd); - free(data); - return 1; - } - } - - close(fd); - - // Verify final file size - struct stat st; - if (stat(TEST_FILE, &st) < 0) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] Failed to stat file: %s\n", strerror(errno)); - free(data); - return 1; - } - - int expected_size = num_writes * chunk_size; - if (st.st_size != expected_size) { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] File size mismatch: expected %d, got %ld\n", expected_size, st.st_size); - free(data); - return 1; - } - - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] ✓ Multiple writes successful, file size correct\n"); - free(data); - return 0; -} - -int main(void) -{ - openlog("t_ext2_audit_write_boundary", LOG_CONS | LOG_PID, LOG_USER); - - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] === EXT2 Write Boundary Test Suite ===\n"); - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] Testing: Issue #1 - Buffer overflow on write boundary\n"); - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] Location: ext2.c:1901 in ext2_write_inode_data()\n"); - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] Bug: right = fs->block_size (should be block_size - 1)\n"); - - int failures = 0; - - failures += test_unaligned_write_spanning_blocks(); - failures += test_exact_block_boundary_write(); - failures += test_multiple_partial_writes(); - - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] === Results ===\n"); - if (failures == 0) { - syslog(LOG_INFO, "[t_ext2_audit_write_boundary] ✅ ALL TESTS PASSED\n"); - closelog(); - return 0; - } else { - syslog(LOG_ERR, "[t_ext2_audit_write_boundary] ❌ %d TEST(S) FAILED\n", failures); - closelog(); - return 1; - } -} diff --git a/userspace/tests/t_periodic1.c b/userspace/tests/t_periodic1.c index d757e433..9bb144c6 100644 --- a/userspace/tests/t_periodic1.c +++ b/userspace/tests/t_periodic1.c @@ -17,6 +17,10 @@ int main(int argc, char *argv[]) { + // Skip the test if real-time scheduler support is not available. + if (!REALTIME_SCHEDULER_SUPPORT) { + return EXIT_SUCCESS; + } pid_t cpid = getpid(); struct sched_param param; diff --git a/userspace/tests/t_periodic2.c b/userspace/tests/t_periodic2.c index d59e9e20..17cd5f0f 100644 --- a/userspace/tests/t_periodic2.c +++ b/userspace/tests/t_periodic2.c @@ -17,6 +17,10 @@ int main(int argc, char *argv[]) { + // Skip the test if real-time scheduler support is not available. + if (!REALTIME_SCHEDULER_SUPPORT) { + return EXIT_SUCCESS; + } pid_t cpid = getpid(); struct sched_param param; diff --git a/userspace/tests/t_periodic3.c b/userspace/tests/t_periodic3.c index 7a0e523c..3d5f40d4 100644 --- a/userspace/tests/t_periodic3.c +++ b/userspace/tests/t_periodic3.c @@ -20,6 +20,10 @@ int main(int argc, char *argv[]) { + // Skip the test if real-time scheduler support is not available. + if (!REALTIME_SCHEDULER_SUPPORT) { + return EXIT_SUCCESS; + } pid_t cpid = getpid(); // Get the process ID of the current process sched_param_t param; // Define a structure to hold scheduling parameters diff --git a/userspace/tests/t_scanf.c b/userspace/tests/t_scanf.c deleted file mode 100644 index 2bc8c429..00000000 --- a/userspace/tests/t_scanf.c +++ /dev/null @@ -1,29 +0,0 @@ -/// @file t_scanf.c -/// @brief Test the scanf function. -/// @copyright (c) 2024 This file is distributed under the MIT License. -/// See LICENSE.md for details. - -#include -#include -#include - -int main(void) -{ - int number; - char name[100]; - - syslog(LOG_INFO, "[t_scanf] Enter a number: "); - if (scanf("%d", &number) != 1) { - syslog(LOG_INFO, "[t_scanf] Failed to read number.\n"); - return 1; - } - - syslog(LOG_INFO, "[t_scanf] Enter your name: "); - if (scanf("%99s", name) != 1) { // %99s to prevent buffer overflow - syslog(LOG_INFO, "[t_scanf] Failed to read name.\n"); - return 1; - } - - syslog(LOG_INFO, "[t_scanf] Hello, %s! You entered %d.\n", name, number); - return 0; -} diff --git a/userspace/tests/t_time.c b/userspace/tests/t_time.c index 0cb6bd18..ccc98b98 100644 --- a/userspace/tests/t_time.c +++ b/userspace/tests/t_time.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -16,18 +17,18 @@ int main(void) // Check if the time function failed if (current_time == (time_t)-1) { - syslog(LOG_ERR, "[t_time] Error: time() failed: %s", strerror(errno)); + syslog(LOG_ERR, "Error: time() failed: %s", strerror(errno)); return EXIT_FAILURE; } // Convert to local time and print the result char *time_str = ctime(¤t_time); if (time_str == NULL) { - syslog(LOG_ERR, "[t_time] Error: ctime() failed: %s", strerror(errno)); + syslog(LOG_ERR, "Error: ctime() failed: %s", strerror(errno)); return EXIT_FAILURE; } - syslog(LOG_INFO, "[t_time] Current time is: `%s`\n", time_str); + syslog(LOG_INFO, "Current time is: `%s`\n", time_str); return EXIT_SUCCESS; } From 32ddbf8fab23baa6b166d98b2fc6f6b852795199 Mon Sep 17 00:00:00 2001 From: "Enrico Fraccaroli (Galfurian)" Date: Mon, 16 Mar 2026 11:13:14 +0100 Subject: [PATCH 2/3] fix(tests): update big write test to match refactor --- userspace/tests/t_big_write.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/userspace/tests/t_big_write.c b/userspace/tests/t_big_write.c index b54bb108..47ac6269 100644 --- a/userspace/tests/t_big_write.c +++ b/userspace/tests/t_big_write.c @@ -21,7 +21,7 @@ int write_test_data(const char *filename, int iterations) { - int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd < 0) { syslog(LOG_ERR, "Failed to open file %s: %s\n", filename, strerror(errno)); return EXIT_FAILURE; @@ -35,6 +35,8 @@ int write_test_data(const char *filename, int iterations) syslog(LOG_ERR, "Writing to file %s failed: %s\n", filename, strerror(errno)); result = EXIT_FAILURE; goto write_close_and_cleanup; + } else { + syslog(LOG_DEBUG, "Wrote %u bytes of character %c to file %s (progress %u/%u)\n", sizeof(buffer), i, filename, times * ('z' - 'A' + 1) + i - 'A', iterations * ('z' - 'A' + 1)); } } } From 6c76d5d984340c7332916d866722d9456bbfd3c3 Mon Sep 17 00:00:00 2001 From: "Enrico Fraccaroli (Galfurian)" Date: Mon, 16 Mar 2026 13:49:13 +0100 Subject: [PATCH 3/3] chores(clean): Remove txt file. --- qemu_test_output.txt | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 qemu_test_output.txt diff --git a/qemu_test_output.txt b/qemu_test_output.txt deleted file mode 100644 index 32b0bced..00000000 --- a/qemu_test_output.txt +++ /dev/null @@ -1,8 +0,0 @@ -==================================================== -Starting QEMU test run (timeout: 120s)... -==================================================== -QEMU started with PID: 216157 -Monitoring test progress... -Build directory: build - -qemu-system-i386: -cdrom build/cdrom_test.iso: Could not open 'build/cdrom_test.iso': No such file or directory