1 | # Convert poorly structured test data to C arrays. |
2 | |
3 | from sys import argv |
4 | |
5 | def is_lane(s): |
6 | return len(s) == 16 and all(c in '0123456789ABCDEF' for c in s) |
7 | |
8 | test_files = argv[1:] |
9 | |
10 | print '#define NTESTS ' + str(len(test_files)) |
11 | print '#define TEST_STEPS (1 + 24*5)' |
12 | print 'static lane_t tests[NTESTS][TEST_STEPS][25] = {' |
13 | |
14 | for 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 | |
30 | print '};' |