Skip to content

Commit dbc193e

Browse files
committed
Implements edge case testing
1 parent 37c1965 commit dbc193e

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

test/simple.test.sh

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
#!/bin/bash
22

3-
# simple.test.sh - Simple test that compiles and runs eatmemory with 100M -t 0
4-
# Assumes POSIX system with make and gcc available
3+
# simple.test.sh - Simple test that compiles and runs eatmemory with edge cases around MIN_VERIFICATION_THRESHOLD_BYTES
4+
# Tests memory allocations below, at, and above the 1MB verification threshold
55

66
set -e # Exit on any error
77

8-
echo "Simple eatmemory test - Build and run with 100M -t 0"
9-
echo "===================================================="
8+
# Constants for edge case testing around MIN_VERIFICATION_THRESHOLD_BYTES
9+
readonly THRESHOLD_BYTES=1048576 # 1MB in bytes
10+
readonly THRESHOLD_KB=$((THRESHOLD_BYTES / 1024)) # 1024KB
11+
readonly THRESHOLD_MINUS_1_KB=$((THRESHOLD_KB - 1)) # 1023KB
12+
readonly THRESHOLD_MINUS_1_BYTES=$((THRESHOLD_BYTES - 1)) # 1048575 bytes
13+
readonly THRESHOLD_PLUS_1_BYTES=$((THRESHOLD_BYTES + 1)) # 1048577 bytes
14+
readonly LARGE_TEST_SIZE="100M" # Well above threshold
15+
16+
echo "Enhanced eatmemory test - Testing edge cases around MIN_VERIFICATION_THRESHOLD_BYTES (${THRESHOLD_KB}KB)"
17+
echo "========================================================================================="
1018

1119
# Get the script directory and navigate to project root
1220
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -28,12 +36,33 @@ if [[ ! -f "output/eatmemory" ]]; then
2836
exit 1
2937
fi
3038

31-
echo "Running eatmemory with 100M -t 0..."
32-
echo "Command: ./output/eatmemory 100M -t 0"
33-
echo "--------------------------------------"
39+
# Helper function to run a test case
40+
run_test() {
41+
local test_num="$1"
42+
local description="$2"
43+
local args="$3"
44+
local expected_behavior="$4"
45+
46+
echo ""
47+
echo "Test $test_num: $description - $expected_behavior"
48+
echo "Command: ./output/eatmemory $args"
49+
echo "----------------------------------------------------------------------"
50+
./output/eatmemory $args
51+
echo "✓ Test $test_num completed"
52+
}
53+
54+
echo ""
55+
echo "Testing edge cases around MIN_VERIFICATION_THRESHOLD_BYTES (${THRESHOLD_KB}KB = ${THRESHOLD_BYTES} bytes):"
56+
echo "=================================================================================================="
3457

35-
# Run eatmemory with the specified arguments
36-
./output/eatmemory 100M -t 0
58+
# Test cases around the verification threshold
59+
run_test "1" "Below threshold (${THRESHOLD_MINUS_1_KB}KB)" "${THRESHOLD_MINUS_1_KB}K -t 0" "Memory verification should be disabled"
60+
run_test "2" "Just below threshold (${THRESHOLD_MINUS_1_BYTES} bytes)" "${THRESHOLD_MINUS_1_BYTES} -t 0" "Memory verification should be disabled"
61+
run_test "3" "Exactly at threshold (${THRESHOLD_KB}KB)" "${THRESHOLD_KB}K -t 0" "Memory verification should be enabled"
62+
run_test "4" "Just above threshold (${THRESHOLD_PLUS_1_BYTES} bytes)" "${THRESHOLD_PLUS_1_BYTES} -t 0" "Memory verification should be enabled"
63+
run_test "5" "Well above threshold (${LARGE_TEST_SIZE})" "${LARGE_TEST_SIZE} -t 0" "Memory verification should be enabled"
3764

38-
echo "--------------------------------------"
39-
echo "✓ Test completed successfully!"
65+
echo ""
66+
echo "=================================================================================================="
67+
echo "✓ All edge case tests around MIN_VERIFICATION_THRESHOLD_BYTES completed successfully!"
68+
echo "✓ Verified behavior below, at, and above the ${THRESHOLD_KB}KB verification threshold"

0 commit comments

Comments
 (0)