test2.py 712 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python3
  2. from rfc1982_serial_number import Serial
  3. from random import randint
  4. from subprocess import run
  5. def test(n, cmd):
  6. print(f"\nTest: {test}: {cmd[0]} {cmd[1]} {cmd[2]}")
  7. run(cmd)
  8. for n in range(100):
  9. i1 = randint(0, Serial.modulus - 1)
  10. i2 = randint(0, Serial.modulus - 1)
  11. test(n, ("./rfc1982_serial_number.py", str(i1), str(i2)))
  12. for n in range(10):
  13. i1 = randint(0, Serial.modulus - 1)
  14. i2 = i1 ^ (Serial.modulus >> 1)
  15. test(n, ("./rfc1982_serial_number.py", str(i1), str(i2)))
  16. for n in range(10):
  17. i1 = randint(0, Serial.modulus - 1)
  18. i2 = (i1 + Serial.modulus - 1) & (Serial.modulus - 1)
  19. test(n, ("./rfc1982_serial_number.py", str(i1), str(i2)))