1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/test_bloom/generate_sets.py
René Kijewski 20163e1452 tests: test_bloom: fix PROJDEPS concurrency
Our buildtests build one project concurrently for multiple boards.
The current creation of the `PROJDEPS` for `test_bloom` might fail if

* board `A` notices that the dependency is missing and gets preempted,
* board `B` creates the dependency and gets preempted,
* board `A` starts the creation but gets preempted in the middle of the process,
* board `B` works with a half complete created file.

This PR creates the dependency in the individual `BINDIR`.
2014-06-21 17:51:24 +02:00

37 lines
899 B
Python
Executable File

#!/usr/bin/env python2
import gzip
import random
import sys
sizeOfA = 10 * 1000
sizeOfB = 20
print sys.argv
if len(sys.argv) == 5:
sizeOfA = int(sys.argv[3])
sizeOfB = int(sys.argv[4])
# read all words
lines = [line.strip() for line in gzip.open(sys.argv[1])]
# get A lines
A = random.sample(lines, sizeOfA + sizeOfB)
# get B from the first sieOfB element
B = A[:sizeOfB]
A = A[sizeOfB:]
SetsFile = open(sys.argv[2], 'w')
SetsFile.write('const int lenA = ' + str(sizeOfA) + ';\n')
SetsFile.write('const char* A[' + str(sizeOfA) + '] = {')
SetsFile.writelines(",".join('"' + x + '"\n' for x in A))
SetsFile.write('};\n')
SetsFile.write('const int lenB = ' + str(sizeOfB) + ';\n')
SetsFile.write('const char* B[' + str(sizeOfB) + '] = {')
SetsFile.writelines(",".join('"' + x + '"\n' for x in B))
SetsFile.write('};\n')
print("sets.h: sizeOfA = " + str(len(A) + len(B)) + " generated...")