Skip to content

Commit

Permalink
test: fix broken stress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh0g0-1758 committed Feb 17, 2025
1 parent feee508 commit ed4d077
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 75 deletions.
1 change: 0 additions & 1 deletion githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ echo "Running pre-commit formatting hook"

files=$(git diff --cached --name-only --diff-filter=ACM | \
grep -E "\.(c|cpp|h|hpp|cc|hh)$" | \
grep -v "^tests/" | \
grep -v "^test_framework/")

for file in $files; do
Expand Down
7 changes: 7 additions & 0 deletions stress/tests/bro.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
int main(void) {
return ((((0 * 123456789) << 11) + ((999999999 ^ -656452749) >> 7)) *
((552512879 & 33777832) | ((33777729 + 129270400) % 97)) +
((666666666 * 1337320320) - ((444444444 ^ 0) << 5)) *
((0 & 0) | ((1933253 + 32767) % 89)) +
((32868 * 32767) ^ ((0 - 123456789) << 3)));
}
7 changes: 7 additions & 0 deletions stress/tests/test1.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ int main(void) {
return -1;

final:
#ifdef __clang__
// clang gives undefined behavior for unsequenced modification and access to
// the same variable. gcc seems to respect the precedence of C operators (like
// scarlet) and thus gives a defined result.
return 245;
#else
return (o = 9999999) + (((((((((((((((((((((((((((((((((((((((((((((((((((((((((a = 123456789) * (b = 987654321)) /
((c = 555555555) + 1)) %
((d = 777777777) * (e = 888888888))) *
Expand Down Expand Up @@ -147,4 +153,5 @@ return (o = 9999999) + (((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((m = 222222212) ^ (n = 111111101)) &
((o = 999999989) | (p = 888888877))) +
(((a = 777777766) >> 10) * ((b = 666666655) << 13)))))))))))))))))))))))))))))))))))))));
#endif
}
51 changes: 29 additions & 22 deletions stress/tests/test2.c
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
int main(void) {
int current_temp;
int target_temp;
int heat_power;
int fan_speed;
int humidity;
int pressure;
int safety_threshold;
int emergency_limit;
int system_status;
int error_code;
int valve_position;
int flow_rate;
int sensor1;
int sensor2;
int sensor3;
int alert_level;
int warning_code;
int backup_power;
int efficiency;
int delta_t;
int time_remaining;
int current_temp = 0;
int target_temp = 0;
int heat_power = 0;
int fan_speed = 0;
int humidity = 0;
int pressure = 0;
int safety_threshold = 0;
int emergency_limit = 0;
int system_status = 0;
int error_code = 0;
int valve_position = 0;
int flow_rate = 0;
int sensor1 = 0;
int sensor2 = 0;
int sensor3 = 0;
int alert_level = 0;
int warning_code = 0;
int backup_power = 0;
int efficiency = 0;
int delta_t = 0;
int time_remaining = 0;

start:
if ((current_temp = 72) < 100) {
Expand Down Expand Up @@ -100,6 +100,12 @@ int main(void) {
return -1;

final:
#ifdef __clang__
// clang gives undefined behavior for unsequenced modification and access to
// the same variable. gcc seems to respect the precedence of C operators (like
// scarlet) and thus gives a defined result.
return 104;
#else
return (pressure = 243) +
((((((((((((((((((((current_temp = 180) * (heat_power = 450)) /
((target_temp = 200) + 1)) %
Expand Down Expand Up @@ -137,4 +143,5 @@ int main(void) {
((valve_position = 85) ^ (flow_rate = 170))) +
(((sensor3 = 295) - (sensor2 = 275)) *
((sensor1 = 350) + (sensor2 = 278))));
}
#endif
}
Binary file added stress/tests/test4
Binary file not shown.
67 changes: 33 additions & 34 deletions stress/tests/test4.c
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
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;

int packet_size = 0;
int header_length = 0;
int payload_size = 0;
int checksum = 0;
int error_bits = 0;
int packet_id = 0;
int buffer_space = 0;
int queue_length = 0;
int timeout = 0;
int retry_count = 0;
int max_retries = 0;
int delay = 0;
int fragment_size = 0;
int total_fragments = 0;
int processed_count = 0;
int dropped_count = 0;
int bandwidth = 0;
int latency = 0;
singularity_start:
if (((packet_size = 987654321) >> 3) + ((header_length = 123456789) << 4) >
((payload_size = 999999999) ^ (checksum = 888888888))) {
if (((packet_size = 981) >> 3) + ((header_length = 129) << 4) >
((payload_size = 9) ^ (checksum = 8))) {
if ((((error_bits = packet_size * 31) % 61) +
((packet_id = header_length >> 5) * 23)) <
((buffer_space = payload_size ^ checksum) + 777777777)) {
queue_length = ((timeout = 666666666) & (retry_count = 555555555)) |
((max_retries = 444444444) ^ (delay = 333333333));
((buffer_space = payload_size ^ checksum) + 7)) {
queue_length = ((timeout = 6) & (retry_count = 5)) |
((max_retries = 4) ^ (delay = 3));
goto quantum_path;
} else {
if ((((fragment_size = error_bits + 29) % 59) *
Expand All @@ -51,7 +50,7 @@ int main(void) {
((retry_count = max_retries << 5) + (delay = fragment_size >> 3))) {
if ((((total_fragments = processed_count * 31) % 67) *
((dropped_count = bandwidth + 71) << 4)) <
((latency = packet_size ^ 13) + 111111111)) {
((latency = packet_size ^ 13) + 1)) {
goto entropy_path;
}
goto chaos_path;
Expand All @@ -61,43 +60,43 @@ int main(void) {
entropy_path:
if ((((error_bits = packet_id * 41) >> 7) +
((buffer_space = queue_length + 97) << 3)) >
((timeout = retry_count ^ max_retries) - 222222222)) {
((timeout = retry_count ^ max_retries) - 2)) {
if ((((delay = fragment_size * 43) % 71) *
((total_fragments = processed_count + 83) >> 5)) !=
((dropped_count = bandwidth & latency) + 333333333)) {
((dropped_count = bandwidth & latency) + 3)) {
goto chaos_path;
}
goto final_collapse;
}
goto quantum_path;

chaos_path:
if ((((packet_size = header_length * 47) % 73) +
if ((((packet_size = header_length * 4) % 789) +
((payload_size = checksum + 89) << 6)) <
((error_bits = packet_id ^ buffer_space) - 444444444)) {
((error_bits = packet_id ^ buffer_space) - 3454)) {
if ((((queue_length = timeout * 53) >> 4) *
((retry_count = max_retries + 79) % 67)) >
((delay = fragment_size & total_fragments) + 555555555)) {
((delay = fragment_size & total_fragments) + 5)) {
goto void_path;
}
goto final_collapse;
}
goto entropy_path;
goto final_collapse;

void_path:
if ((((processed_count = dropped_count * 59) % 79) +
((bandwidth = latency + 101) << 5)) !=
((packet_size = header_length ^ payload_size) - 666666666)) {
((packet_size = header_length ^ payload_size) - 6)) {
if ((((checksum = error_bits * 61) >> 6) *
((packet_id = buffer_space + 103) % 83)) <
((queue_length = timeout & retry_count) + 777777777)) {
((queue_length = timeout & retry_count) + 7)) {
goto final_collapse;
}
goto singularity_start;
}
goto chaos_path;

final_collapse:
packet_size = 0;
return (
(((packet_size * header_length) << 11) +
((payload_size ^ checksum) >> 7)) *
Expand Down
36 changes: 18 additions & 18 deletions stress/tests/test7.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
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;
int packet_size = 0;
int header_length = 0;
int payload_size = 0;
int checksum = 0;
int error_bits = 0;
int packet_id = 0;
int buffer_space = 0;
int queue_length = 0;
int timeout = 0;
int retry_count = 0;
int max_retries = 0;
int delay = 0;
int fragment_size = 0;
int total_fragments = 0;
int processed_count = 0;
int dropped_count = 0;
int bandwidth = 0;
int latency = 0;

singularity_start:
if (((packet_size = 123456) >> 3) + ((header_length = 654321) << 4) >
Expand Down

0 comments on commit ed4d077

Please sign in to comment.