Commit Graph
15 Commits
Author SHA1 Message Date
Claude 4b97b176bd Add branch coverage measurement for random simulation
This commit adds tooling to measure how many branches the random simulation
reaches during execution, which helps understand code coverage and identify
untested code paths.

Changes:
- Add coverage build target to Makefile with --coverage flags
- Create measure_coverage.sh script to build, run, and report branch coverage
- Add signal handlers (SIGINT/SIGTERM) to main_test.c for clean shutdown
- Update clean target to remove coverage files (*.gcda, *.gcno)

The script runs the simulation for a specified duration (default 5 seconds),
then uses gcov to analyze which branches were executed. In a 3-second run,
the simulation reaches approximately 32% of all branches (781/2431).

Usage:
  ./measure_coverage.sh [duration_in_seconds]

Example output shows per-file and total branch coverage statistics.
2025-11-13 19:35:06 +00:00
cozis 9ea4ee5223 Remove solved TODO from TODO.txt and fix a bug in file_tree_read 2025-11-10 12:51:12 +01:00
cozis 36925309da Bug fix 2025-11-10 12:26:25 +01:00
cozis bab8558511 Progress 2025-11-09 20:36:08 +01:00
cozis d13ad3ae6c Progress 2025-11-09 19:43:24 +01:00
cozis 8d56a32bd1 Progress 2025-11-09 14:32:02 +01:00
cozis c2cb833e50 Progress 2025-11-08 22:16:55 +01:00
cozis d7cf946431 Progress 2025-11-07 20:26:15 +01:00
cozis e124952fe2 Progress 2025-11-05 14:26:57 +01:00
cozis e135d871c1 Progress 2025-11-03 15:52:25 +01:00
Claude 38fdab24d3 Implement simulation client for deterministic testing
Added a simulation client that can run inside the TinyDFS simulation
framework, enabling fully deterministic end-to-end testing of the
distributed file system.

**New Files:**
- src/simulation_client.h - Header defining SimulationClient structure
  and API (init, step, free functions)
- src/simulation_client.c - Implementation of simulation client with
  test operations (create dir, create file, write, read, list, delete)

**Key Changes:**

**System Framework (src/system.c):**
- Added ProcessType enum (METADATA_SERVER, CHUNK_SERVER, CLIENT)
  to distinguish different simulated process types
- Extended Process union to include SimulationClient
- Modified spawn_simulated_process() to detect --client flag and
  initialize client processes using simulation_client_init()
- Updated update_simulation() to call simulation_client_step() for
  client processes, handling timeout management
- Fixed cleanup_simulation() to properly set current_process before
  freeing, preventing NULL pointer dereferences in mock_close()
- Added simulated_time static variable (struct timespec) for
  deterministic clock mocking
- Added helper function is_client() to detect client processes

**API Updates (src/system.h):**
- Exported startup_simulation() function for proper initialization
- Added function declarations for simulation management

**Test Updates (src/main_test.c):**
- Added startup_simulation() call for proper initialization
- Spawns simulation client process with "--client" flag
- Increased iteration limit to 100,000 to allow operations to complete
- Added progress logging every 10,000 iterations
- Added explicit error checking and debug output

**Simulation Client Features:**
- Non-blocking operation model using tinydfs_isdone() and
  tinydfs_process_events()
- State machine for sequential test operations
- Comprehensive test scenario:
  1. Create directory (/test_dir)
  2. Create file (/test_dir/test_file.txt)
  3. Write data to file
  4. Read data back
  5. List directory contents
  6. Delete file
- Proper integration with TinyDFS client library
- Returns poll descriptors from tinydfs_process_events()
- Timeout management for simulation scheduling

**Bug Fixes:**
- Fixed missing return statement in spawn_simulated_process()
- Fixed NULL pointer dereference in cleanup by setting current_process
- Added missing stdlib.h include for atoi()

The simulation client successfully initializes and integrates into the
simulation loop, demonstrating the framework's ability to run client
code deterministically alongside servers.
2025-11-02 12:05:53 +00:00
cozis 8b284f5752 Progress 2025-11-02 04:37:20 +01:00
cozis eb93541c84 Test framework cleanup 2025-11-01 22:44:04 +01:00
cozis 7525a93035 Progress 2025-10-29 23:48:45 +01:00
cozis 174f37c6c0 Continue work on DST framework 2025-10-29 21:46:17 +01:00