A robust, fully-automated Python test suite for the Rank 06 Exam project mini_serv (42 School Cursus).
It uses Python's socket, subprocess, and select libraries to simulate multiple concurrent clients, validating your server against all standard project constraints.
- Basic Connections & Messages: Tests client arrivals, messages spanning multiple lines, partial messages (missing newline), and client departures.
- Stress & Load Testing: Spawns 250 dummy clients to test server file descriptors and stability under load.
- Large Payloads: Transmits continuous message structures larger than typical buffer sizes (8KB+) to ensure chunks are assembled and fragmented efficiently without data corruption.
- Broadcasting Speed Test: Benchmarks latency by sending a single broadcast and monitoring propagation to 200 clients under strict timeouts (simulating the exam requirement: "Warning our tester is expecting that you send the messages as fast as you can").
- Python 3.x
- Standard Python libraries (no
pip installrequired) - Your compiled
mini_servexecutable located in the same directory running the script.
- Compile your server and ensure the executable
mini_servis present. - Run the tester:
python3 exam06-tester.pyThe script will automatically detect a free port and launch mini_serv, connecting multiple simulated clients to run all checks and validations.
To test your server for memory leaks and open file descriptors, you can use the --valgrind flag:
python3 exam06-tester.py --valgrindWhen you use this flag, the tester switches to Manual Mode. It will find a free port and pause, giving you the exact Valgrind command to run in a separate terminal.
Why is this needed?
During stress tests, when many clients disconnect simultaneously, writing to a closed socket throws a fatal SIGPIPE signal that kills your server instantly. Because the strict exam rules forbid you from using signal() in your C code to ignore it, your server would artificially crash during testing before Valgrind can generate a memory report.
We solve this by having you run the server manually wrapped in a subshell that traps and ignores SIGPIPE. The tester will provide you with a command exactly like this to copy and paste into a new terminal:
(trap '' SIGPIPE; valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --track-fds=yes -s ./mini_serv <port>)Once your server is running via this command, press ENTER in the tester to begin the suite. Once finished, you can safely Ctrl+C your Valgrind terminal to read a clean, perfectly un-interrupted leak report!
- Test 1: Basic connection & arrival notification
- Test 2: Basic message routing
- Test 3: Partial message buffering (simulating multiple
recv()calls logic) - Test 4: Multiple lines concatenated sequentially
- Test 5: Client leaving notification
- Test 6: Stress connections (250 clients without crashing)
- Test 7: Mass messaging & large texts routing to target group
- Test 8: Large payload processing (> 8KB)
- Test 9: Speed / Latency Broadcast Benchmark (ensuring fast message propagation to avoid "too slow" errors during exam grading)