Push Swap Tester is a Bash script designed to test the reliability, performance, and memory management of the Push Swap program. It includes validity checks, performance benchmarking, and memory leak detection using valgrind.
This script evaluates:
- Result Validity: Verifies if the
push_swapprogram produces correct solutions for various sets of random numbers. - Performance: Measures the number of moves generated by
push_swapto solve permutations. - Memory Management: Detects memory leaks or other issues using
valgrind.
bashvalgrindcurl(for automatic downloading of thecheckerfile, if needed)
Run with curl:
curl -sSL https://raw.githubusercontent.com/Zak4b/push_swap_tester/refs/heads/main/tester | bashor clone the repo:
git clone https://github.com/Zak4b/push_swap_tester.git
cd push_swap_tester
./push_swap_tester.sh PUSH_SWAP- PUSH_SWAP: Path to your
push_swapexecutable (default:./push_swap).
-
Memory Tests (
push_swap_memtest)- Verifies that your program:
- Has no memory leaks.
- Properly handles invalid inputs, duplicate arguments, etc.
- Verifies that your program:
-
No Output Test (
push_swap_nooutput)- Ensures that
push_swapproduces no output when no actions are required.
- Ensures that
-
Correctness Tests (
push_swap_test)- Tests various input cases to ensure the solution is valid when validated with the
checkerprogram.
- Tests various input cases to ensure the solution is valid when validated with the
-
Performance Benchmarking (
push_swap_bench)- Measures the number of moves generated by
push_swapfor solving lists of size 5, 100, or 500. - Outputs the minimum, average, and maximum number of moves during the benchmark.
- Measures the number of moves generated by
Push Swap tester
Memory test
OK KO OK
==14952== Memcheck, a memory error detector
==14952== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==14952== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==14952== Command: ./push_swap ''
==14952==
==14952==
==14952== HEAP SUMMARY:
==14952== in use at exit: 1 bytes in 1 blocks
==14952== total heap usage: 2 allocs, 1 frees, 1 bytes allocated
==14952==
==14952== LEAK SUMMARY:
==14952== definitely lost: 0 bytes in 0 blocks
==14952== indirectly lost: 0 bytes in 0 blocks
==14952== possibly lost: 0 bytes in 0 blocks
==14952== still reachable: 1 bytes in 1 blocks
==14952== suppressed: 0 bytes in 0 blocks
==14952== Reachable blocks (those to which a pointer was found) are not shown.
==14952== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==14952==
==14952== For lists of detected and suppressed errors, rerun with: -s
==14952== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Testing 5 values
OK OK OK KO OK OK OK OK OK
KO with "2 1 3 4 5"
Testing 100 values
OK OK OK OK OK OK OK OK OK
Testing 500 values
OK OK OK OK OK OK OK OK OK
Performance on 5 values
Minimum: 5
Average: 7
Maximum: 10
Performance on 100 values
Minimum: 587
Average: 628
Maximum: 666
Performance on 500 values
Minimum: 5004
Average: 5199
Maximum: 5376