forked from newaetech/chipwhisperer
-
Notifications
You must be signed in to change notification settings - Fork 3
/
TestVictimFirmware.py
60 lines (44 loc) · 1.59 KB
/
TestVictimFirmware.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
#
#ChipWhisperer Release Test Script
#
import subprocess, os
def testRV(rv):
if rv[0]:
print "[OK]"
else:
print "[FAILED]"
print "stdout: %s"%rv[1][0]
print "stderr: %s"%rv[1][1]
raise ValueError("Test Failed")
class TestVictimFirmware(object):
def __init__(self):
self.env = os.environ.copy()
# For Windows
self.env["PATH"] = self.env["PATH"] + r";C:\WinAVR-20100110\bin;C:\WinAVR-20100110\utils\bin"
self.basePath = "../../hardware/victims/firmware/"
def test(self):
print "--Victim Firmware Build Test--"
tests = 5
print " avr-serial-nocrypto ",
testRV(self.runMake('avr-serial-nocrypto', 'MCU=atmega328p'))
print " avr-serial with crypto ",
testRV(self.runMake('avr-serial', 'MCU=atmega328p'))
print " xmega-serial with crypto ",
#todo: fix this script so don't need this bogus argument
testRV(self.runMake('xmega-serial', 'IGNORETHIS=22'))
def runMake(self, path, args):
self.runMakeLL(path, [args, "clean"])
rv = self.runMakeLL(path, args)
self.runMakeLL(path, [args, "clean"])
return rv
def runMakeLL(self, path, args):
path = os.path.join(self.basePath, r'%s' % path)
# print path
vl = subprocess.Popen(["make", args], env=self.env, cwd=path, shell=True)
data = vl.communicate()
if (vl.returncode == 0):
return (True, data)
return (False, data)
if __name__ == '__main__':
tvf = TestVictimFirmware()
tvf.test()