From b7d51b7f62b62f3b7d51a376d24dc1aa13e1495e Mon Sep 17 00:00:00 2001 From: Richard Meadows Date: Sun, 28 Jun 2015 18:46:04 +0100 Subject: [PATCH] Can now run individual test cases on hw --- firmware/Makefile | 1 + firmware/test/README.md | 16 ++++++++++++++++ firmware/test/tests.py | 23 ++++++++++++++++++++--- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/firmware/Makefile b/firmware/Makefile index 314563b..673be8c 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -250,6 +250,7 @@ TESTCASES := $(shell $(FIND) test/tc -name '*.[h]') .PHONY: test test: test/main.py all @echo "Running tests..." + @echo $(tc) > test/.testcommand $(DB) -q -x test/tests.py # Ctypesgen for test diff --git a/firmware/test/README.md b/firmware/test/README.md index b4e3e8a..e8ab50d 100644 --- a/firmware/test/README.md +++ b/firmware/test/README.md @@ -17,6 +17,22 @@ You need to have your debugger configured in config.mk and possibly also have gdbscript-custom. The test driver just issues an `attach 1` command after gdb startup and expects that to work. +##### From the makefile + +From the main firmware makefile you can just run + +``` +make test +``` + +to run all tests, or + +``` +make test tc= +``` + +to run a specific test case + #### Operation Initially `tests.py` loads the latest binary, and runs `Reset_Handler` diff --git a/firmware/test/tests.py b/firmware/test/tests.py index c675e34..3e19d07 100644 --- a/firmware/test/tests.py +++ b/firmware/test/tests.py @@ -147,6 +147,10 @@ class Tests(): fail = False ttime = 0 if hasattr(test_case, 'iterations'): + """This is for test cases that need to be run multiple time to check + the result is always correct + + """ for i in range(test_case.iterations): params = test_case.get_test() result = self.hw_run_tc(tc_name, params) @@ -158,6 +162,10 @@ class Tests(): else: # No result, Failure fail = True else: + """This is for test cases that only run once or that use a pre-set + list of cases + + """ params = test_case.get_test() while (params): result = self.hw_run_tc(tc_name, params) @@ -195,8 +203,17 @@ class Tests(): if __name__ == '__main__': t = Tests() - # Run all testcases - for tc_name in tc.__all__: - t.run_test_case(t.get_testcase_from_name(tc_name)()) + # Read in our command file + with open("./test/.testcommand") as f: + tc_name = f.readline().strip('\n') + + if tc_name in tc.__all__: + # If we've been commanded to run a test + t.run_test_case(t.get_testcase_from_name(tc_name)()) + + else: + # Run all testcases + for tc_name in tc.__all__: + t.run_test_case(t.get_testcase_from_name(tc_name)()) del t