Skip to content

Commit

Permalink
feat: add more complex test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh0g0-1758 committed Feb 16, 2025
1 parent 3acb8ad commit d98a37d
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 9 deletions.
4 changes: 2 additions & 2 deletions stress/check_memory_leaks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ check_leak() {
fi
}

for test in $TEST_DIR/test{1..6}.c; do
for test in $TEST_DIR/test{1..7}.c; do
check_leak "$test"
done

for exe in test{1..6}; do
for exe in test{1..7}; do
rm $exe
done
12 changes: 5 additions & 7 deletions stress/stress_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fi


CC=$1
CC_FLAGS="-Wno-unsequenced -Werror -fwrapv"

# We only build and test scarlet against gcc and clang
if ! [[ "$CC" =~ ^(gcc|clang)$ ]]; then
Expand All @@ -27,10 +28,10 @@ run_test() {
local test_file=$1
local test_name=$(basename "$test_file" .c)

echo "Testing $test_name... "
echo -n "Testing $test_name... "

# Compile and execute the test using CC (gcc/clang)
$CC -o "$test_name" "$test_file"
$CC $CC_FLAGS -o "$test_name" "$test_file"
./"$test_name"
local CC_return_code=$?
rm "$test_name"
Expand All @@ -41,12 +42,9 @@ run_test() {
local SCARLET_return_code=$?
rm "$test_name"

echo "$CC return code: $CC_return_code"
echo "SCARLET return code: $SCARLET_return_code"

if [ "$CC_return_code" != "$SCARLET_return_code" ]; then
echo -e "${RED}ERROR: Return codes do not match${NC}"
echo "CC return code: $CC_return_code"
echo "$CC return code: $CC_return_code"
echo "SCARLET return code: $SCARLET_return_code"
echo "Test file: $test_file"
return 1
Expand All @@ -56,6 +54,6 @@ run_test() {
fi
}

for test in $TEST_DIR/test{1..6}.c; do
for test in $TEST_DIR/test{1..7}.c; do
run_test "$test"
done
92 changes: 92 additions & 0 deletions stress/tests/test7.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
int main(void) {
int packet_size;
int header_length;
int payload_size;
int checksum;
int error_bits;
int packet_id;
int buffer_space;
int queue_length;
int timeout;
int retry_count;
int max_retries;
int delay;
int fragment_size;
int total_fragments;
int processed_count;
int dropped_count;
int bandwidth;
int latency;

singularity_start:
if (((packet_size = 123456) >> 3) + ((header_length = 654321) << 4) >
((payload_size = 987654) ^ (checksum = 456789))) {
if ((((error_bits = packet_size % 31) + 1000) +
((packet_id = header_length >> 5) * 23)) <
((buffer_space = payload_size ^ checksum) + 100000)) {
queue_length = ((timeout = 50000) & (retry_count = 40000)) |
((max_retries = 30000) ^ (delay = 20000));
goto quantum_path;
} else {
if ((((fragment_size = error_bits + 29) % 59) *
((total_fragments = packet_id % 23) + 53)) >
((processed_count = buffer_space % 19) + 47)) {
goto final_collapse; // Changed from entropy_path
}
goto chaos_path;
}
} else {
goto void_path; // Simplified this branch
}

quantum_path:
if ((((packet_size = header_length ^ payload_size) &
(checksum = error_bits | packet_id)) +
((buffer_space = queue_length % timeout) + 37)) >
((retry_count = max_retries >> 3) + (delay = fragment_size >> 2))) {
if ((((total_fragments = processed_count % 31) + 67) *
((dropped_count = bandwidth + 71) >> 2)) <
((latency = packet_size ^ 13) + 10000)) {
goto final_collapse; // Changed from entropy_path
}
goto void_path; // Changed from chaos_path
}
goto final_collapse; // Changed from void_path

chaos_path:
if ((((packet_size = header_length % 47) + 73) +
((payload_size = checksum + 89) << 3)) <
((error_bits = packet_id ^ buffer_space) - 40000)) {
if ((((queue_length = timeout % 53) >> 2) *
((retry_count = max_retries + 79) % 67)) >
((delay = fragment_size & total_fragments) + 50000)) {
goto final_collapse;
}
goto void_path;
}
goto final_collapse; // Changed from entropy_path

void_path:
if ((((processed_count = dropped_count % 59) + 79) +
((bandwidth = latency + 101) << 3)) !=
((packet_size = header_length ^ payload_size) - 60000)) {
if ((((checksum = error_bits % 61) >> 2) *
((packet_id = buffer_space + 103) % 83)) <
((queue_length = timeout & retry_count) + 70000)) {
goto final_collapse;
}
goto final_collapse; // Changed from singularity_start
}
goto final_collapse; // Changed from chaos_path

final_collapse:
return ((((packet_size % 1000) * (header_length % 1000)) << 4) +
((payload_size ^ checksum) >> 3)) *
((error_bits & packet_id) | ((buffer_space + queue_length) % 97)) +
((timeout % 1000) * (retry_count % 1000) -
((max_retries ^ delay) << 3)) *
((fragment_size & total_fragments) |
((processed_count + dropped_count) % 89)) +
((bandwidth % 1000) * (latency % 1000) ^
((packet_size - header_length) << 2));
}

0 comments on commit d98a37d

Please sign in to comment.