-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBruteTest.py
65 lines (60 loc) · 2.29 KB
/
BruteTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from math import *
import test
import config
import subprocess
# import threading
import getopt, sys
class BruteTest: #27
def testpossible(self,varsize):
for op in ["+", "-", "*", "cat"]:
for i in range(0,varsize):
for j in range(0, varsize):
self.calc_variables(op, i, j)
for op in ["==", "!=", "/", "%", "&", "|", "^", "<", "<=", ">", ">="]:
for i in range(0,varsize):
for j in range(0, varsize):
self.calc_variables(op, i, j)
for op in ["pad", "shl", "shr", "dshl", "dshr"]:
for i in range(0,varsize):
for j in range(i):
self.calc_variables(op, i, j)
for op in ["tail", "head"]:
for i in range(0,varsize):
isize = config.getbitsize(i)
for j in range(0,isize):
self.calc_variables(op, i, j)
for op in ["andr", "orr", "xorr"]:
for i in range(0,varsize):
self.calc_variables(op, i)
for op in ["~"]:
for i in range(0, varsize):
self.calc_variables(op, i)
for i in range(2,varsize):
isize = config.getbitsize(i)
for h in range(0, isize):
for l in range(0, h+1):#change to hize+1
self.calc_variables("bits", i,h,l)
# def testthreeparm(self, maxbitsize):
if __name__=="__main__":
t = test.runtests()
arglist = sys.argv[1:]
options = "t:m:ch"
long_options = ["type=", "maxbit=", "clear", "help"]
maxbit = 1
try:
arguments, values = getopt.getopt(arglist, options, long_options)
for currentArgument, currentValue in arguments:
if currentArgument in ("-m", "--maxbit"):
maxbit = 1<<int(currentValue) -1
elif currentArgument in ("-t", "--type"):
t.type = currentValue
elif currentArgument in ("-c", "--clear"):
t.clear = True
elif currentArgument in ("-h", "--help"):
print("usage: BruteTest.py -t [uint/sint] -s <max value>")
sys.exit()
except getopt.error as err:
print (str(err))
BruteTest.testpossible(t, maxbit)
print("====================")
t.printresult()