Projects : keksum : genesis

munge-testvecs.py

Dir - Raw

1# Convert poorly structured test data to C arrays.
2
3from sys import argv
4
5def is_lane(s):
6 return len(s) == 16 and all(c in '0123456789ABCDEF' for c in s)
7
8test_files = argv[1:]
9
10print '#define NTESTS ' + str(len(test_files))
11print '#define TEST_STEPS (1 + 24*5)'
12print 'static lane_t tests[NTESTS][TEST_STEPS][25] = {'
13
14for path in test_files:
15 with open(path) as f:
16 tokens = f.read().split()
17 lane = 0
18 print '\t{'
19 for t in tokens:
20 if is_lane(t):
21 if lane == 0:
22 print '\t\t{'
23 print '\t\t\t0x' + t + ','
24 lane += 1
25 if lane == 25:
26 lane = 0
27 print '\t\t},'
28 print '\t},'
29
30print '};'