Commit 5f10e451 authored by Reto Da Forno's avatar Reto Da Forno
Browse files

script updated, and column width for test ID increased

parent 7bfe4529
#! /usr/bin/env python3 #! /usr/bin/env python3
""" """
Copyright (c) 2010 - 2020, ETH Zurich, Computer Engineering Group Copyright (c) 2010 - 2022, ETH Zurich, Computer Engineering Group
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -38,50 +38,73 @@ import sys ...@@ -38,50 +38,73 @@ import sys
import os import os
if len(sys.argv) < 4: # extract data from test results directory
print("no enough arguments provided") def extract_data(results_dir, start, end, output_dir):
print("usage: %s [results_dir] [start_time] [end_time]" % (__file__)) filenames = [ 'gpiotracing.csv', 'powerprofiling.csv' ] # first file must be GPIO tracing
sys.exit(1) output = []
teststart = None
gpiotracing = True
line_cnt = 0
results_dir = sys.argv[1] for filename in filenames:
start_time = float(sys.argv[2]) line_cnt = 0
end_time = float(sys.argv[3]) filepath = "%s/%s" % (results_dir, filename)
if not os.path.isfile(filepath):
if not os.path.isdir(results_dir):
print("directory %s not found" % results_dir)
sys.exit(1)
if (start_time < 0) or (end_time <= start_time) or (end_time > 86400):
print("invalid start and/or end time")
sys.exit(1)
# check if output directory exists
outdir = results_dir.rstrip("/") + "_part"
if not os.path.isdir(outdir):
os.mkdir(outdir)
processed_lines = 0
output_lines = 0
output = []
with open("%s/gpiotracing.csv" % results_dir, 'r') as f_in:
lines = f_in.readlines()
teststart_time = 0
for line in lines:
(timestamp, obsid, node_id, pin, state) = line.split(",", 5)
if "timestamp" in timestamp: # first line?
output.append(line)
continue continue
if teststart_time == 0: print("extracting data from %s..." % filepath)
teststart_time = float(timestamp)
relative_time = float(timestamp) - teststart_time with open(filepath, 'r') as f:
if (relative_time >= start_time) and (relative_time <= end_time) or ("nRST" in pin): for line in f.readlines():
output.append(line) parts = line.split(",")
output_lines += 1 timestamp = parts[0]
processed_lines += 1 if gpiotracing:
pin = parts[3]
if len(output) > 0: if "timestamp" in timestamp: # first line?
with open("%s/gpiotracing.csv" % outdir, 'w') as f_out: output.append(line)
f_out.write("".join(output)) continue
if not teststart:
print("%d lines processed, %d lines written to %s" % (processed_lines, output_lines, outdir)) teststart = float(timestamp)
ofs = float(timestamp) - teststart
if (ofs >= start) and (ofs <= end) or (gpiotracing and "nRST" in pin):
output.append(line)
if len(output) > 0:
line_cnt += len(output)
with open("%s/%s" % (output_dir, filename), 'w') as f:
f.write("".join(output))
gpiotracing = False
output.clear()
return line_cnt
if __name__ == "__main__":
# check arguments
if len(sys.argv) < 4:
print("no enough arguments provided")
print("usage: %s [results_dir] [start_time] [end_time]" % (__file__))
sys.exit(1)
results_dir = sys.argv[1].rstrip("/")
start_time = float(sys.argv[2])
end_time = float(sys.argv[3])
if not os.path.isdir(results_dir):
print("directory %s not found" % results_dir)
sys.exit(1)
if (start_time < 0) or (end_time <= start_time) or (end_time > 86400):
print("invalid start and/or end time")
sys.exit(1)
# check if output directory exists
out_dir = results_dir + "_part"
if not os.path.isdir(out_dir):
os.mkdir(out_dir)
# GPIO tracing
line_cnt = extract_data(results_dir, start_time, end_time, out_dir)
print("%d lines written to %s" % (line_cnt, out_dir))
...@@ -253,7 +253,7 @@ echo '<h1>Manage Tests for '.$_SESSION['firstname'] . ' ' . $_SESSION['lastname' ...@@ -253,7 +253,7 @@ echo '<h1>Manage Tests for '.$_SESSION['firstname'] . ' ' . $_SESSION['lastname'
<table id="test_overview" class="tablesorter" style="display:none"> <table id="test_overview" class="tablesorter" style="display:none">
<thead> <thead>
<tr> <tr>
<th width="35px">ID</th> <th width="40px">ID</th>
<th width="100px">Title</th> <th width="100px">Title</th>
<th width="150px">Description</th> <th width="150px">Description</th>
<th width="35px">IMG</th> <th width="35px">IMG</th>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment