test generator fix

This commit is contained in:
hladu357 2024-06-08 18:22:26 +02:00
parent 071e384920
commit a94f373c4b
1 changed files with 3 additions and 1 deletions

View File

@ -14,6 +14,7 @@ def generate_random_test_cases(rules, n):
rule_network = rule[0]
rule_next_hop = rule[1]
network = rule_network
for _ in range(n):
next_hop = rule_next_hop
address = rule_network.network_address + random.randint(0, rule_network.num_addresses - 1)
@ -23,9 +24,10 @@ def generate_random_test_cases(rules, n):
continue
oth_network = oth_rule[0]
oth_next_hop = oth_rule[1]
if address in oth_network and oth_network.subnet_of( rule_network ):
if address in oth_network and oth_network.subnet_of( network ):
print(f"address {address} is closer to {oth_network} {rule_next_hop} than {rule_network} {oth_next_hop}")
next_hop = oth_next_hop
network = oth_network
f.write(f"{address} {next_hop}\n")
print(f"Generated test case: {address} {next_hop}")
print("tests for rule ", rule_network, " with next hop ", rule_next_hop, " generated")