kopia lustrzana https://github.com/bristol-seds/pico-tracker
Added lists of tets and summary section
rodzic
42fb155291
commit
c70fb7abb5
|
@ -0,0 +1,27 @@
|
|||
## Verification
|
||||
|
||||
#### Usage
|
||||
|
||||
Something like this.
|
||||
|
||||
`> /dev/null arm-none-eabi-gdb -q -x tools/verification/list/protocol.py `
|
||||
|
||||
You need to have your debugger configured in config.mk or I imagine
|
||||
things won't work to well
|
||||
|
||||
#### Operation
|
||||
|
||||
Initially the `verification.py` loads the latest binary, and runs
|
||||
`Reset_Handler` until the top of `main`. It then jumps to `tc_main` instead.
|
||||
|
||||
While stopped in `tc_main` a pointer to the test case is set. The
|
||||
program is then run, and one loop of `tc_main` runs the test case.
|
||||
|
||||
#### Writing a new test case
|
||||
|
||||
Several naming conventions need to the followed for `verification.py`
|
||||
to find everything
|
||||
|
||||
.
|
||||
.
|
||||
.
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Imports
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append("./tools/verification")
|
||||
from verification import *
|
||||
import verification_tc
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Test Script
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
class times_two_tc:
|
||||
def __init__(self):
|
||||
self.name = self.__class__.__name__
|
||||
self.iterations = 20
|
||||
|
||||
|
||||
def get_test(self):
|
||||
"""Returns some suitable test parameters"""
|
||||
params = verification_tc.struct_times_two_tc_params()
|
||||
params.input = randint(0, 10000)
|
||||
|
||||
return params
|
||||
|
||||
def is_correct(self, params, result):
|
||||
"""Returns if a result is correct for the given parameters"""
|
||||
|
||||
print_info("%d * 2 = %d"%(params.input, result['result']))
|
||||
|
||||
if (params.input * 2 == result['result']):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Run test
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
sys.path.append("./tools/verification/tc")
|
||||
|
||||
tester = samd20_test()
|
||||
results = []
|
||||
|
||||
|
||||
# Times Two
|
||||
import times_two
|
||||
results.append(tester.run_test_case(times_two.times_two_tc()))
|
||||
|
||||
|
||||
# Summary
|
||||
tester.print_summary(results)
|
||||
# Clean Up
|
||||
del tester
|
|
@ -44,6 +44,7 @@ class times_two_tc:
|
|||
# Run test
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
tester = samd20_test()
|
||||
tester.run_test_case(times_two_tc())
|
||||
del tester
|
||||
if __name__ == "__main__":
|
||||
tester = samd20_test()
|
||||
tester.run_test_case(times_two_tc())
|
||||
del tester
|
||||
|
|
|
@ -76,6 +76,24 @@ class samd20_test:
|
|||
printf(Fore.RED + " " + tc_name + "- FAIL" \
|
||||
+ str(time) + Fore.RESET)
|
||||
|
||||
def print_summary(self, results):
|
||||
passes = 0
|
||||
for result in results:
|
||||
(passed) = result
|
||||
if passed:
|
||||
passes += 1
|
||||
|
||||
|
||||
self.print_header("SUMMARY - %d%% PASS"%(100*passes/len(results)))
|
||||
|
||||
for result in results:
|
||||
(passed, name, time) = result
|
||||
if passed:
|
||||
self.print_pass(name, time)
|
||||
else:
|
||||
self.print_fail(name, time)
|
||||
|
||||
self.print_header("")
|
||||
#### GDB
|
||||
|
||||
def __init__(self):
|
||||
|
@ -141,3 +159,6 @@ class samd20_test:
|
|||
self.print_pass(tc_name, 0)
|
||||
else:
|
||||
self.print_fail(tc_name, 0)
|
||||
|
||||
# Return data tuple
|
||||
return (not fail, tc_name, 0)
|
||||
|
|
Ładowanie…
Reference in New Issue