3 # Expects either "prepare" or "clean" argument
10 print('Please specify "prepare <SIZE>" or "clean <SIZE>" as first argument.')
13 if (len(sys
.argv
) <= 1):
16 if (len(sys
.argv
) <= 2):
18 array_len
= int(sys
.argv
[2])
20 tracedir_name
= './trace-' + str(array_len
) + '/'
21 output_metadata
= tracedir_name
+ 'metadata'
22 output_stream
= tracedir_name
+ 'stream'
25 def write_binary(f
, arr
):
28 def generate_metadata(array_len
):
33 'typealias integer {{ size = 8; align = 8; signed = false; base = hex; }} := uint8_t;\n'
34 'typealias integer {{ size = 32; align = 8; signed = false; base = hex; }} := uint32_t;\n'
35 'typealias integer {{ size = 64; align = 8; signed = false; base = hex; }} := uint64_t;\n'
40 ' uuid = "2a6422d0-6cee-11e0-8c08-cb07d7b3a564";\n'
42 ' packet.header := struct {{\n'
44 ' uint8_t uuid[16];\n'
50 ' fields := struct {{\n'
55 metadata_f
= open(output_metadata
, 'w')
56 metadata_f
.write(metadata_str
)
59 def generate_stream(stream_nr
):
61 stream_packet_header
= [
62 0xC1, 0x1F, 0xFC, 0xC1, # magic
63 0x2A, 0x64, 0x22, 0xD0, 0x6C, 0xEE, 0x11, 0xE0,
64 0x8C, 0x08, 0xCB, 0x07, 0xD7, 0xB3, 0xA5, 0x64, # uuid
69 stream_f
= open(output_stream
+ str(stream_nr
), 'wb')
70 write_binary(stream_f
, stream_packet_header
)
71 # generate 8-bit per event
72 write_binary(stream_f
, event_payload
)
75 def generate_streams(array_len
):
76 for i
in range(array_len
):
80 print('Preparing test for ' + str(array_len
) + ' streams')
81 os
.mkdir(tracedir_name
)
82 generate_metadata(array_len
)
83 generate_streams(array_len
)
86 print('Cleaning up test for ' + str(array_len
) + ' streams')
88 os
.remove(output_metadata
)
91 for i
in range(array_len
):
93 os
.remove(output_stream
+ str(i
))
97 os
.rmdir(tracedir_name
)
101 if (mode
== "prepare"):
104 elif (mode
== "clean"):
This page took 0.032242 seconds and 5 git commands to generate.