38fdab24d330d139da65d60a82c0e25795944975
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.
Languages
C
98.4%
Shell
1%
Zig
0.4%
Batchfile
0.2%