Added makefile for making new tcs

master
Richard Meadows 2015-06-28 19:13:15 +01:00
rodzic 68aca94548
commit ed27b1c0b2
5 zmienionych plików z 100 dodań i 0 usunięć

1
.gitignore vendored
Wyświetl plik

@ -1,6 +1,7 @@
datasheets
firmware/test/ctypesgen/.svn
firmware/test/main.py*
firmware/test/.testcommand
*.s#*
*.b#*

Wyświetl plik

@ -0,0 +1,21 @@
#
# Makes new test cases
#
ECHO := echo
SED := sed
#
#
#
.PHONY: new
new:
ifdef name
@$(ECHO)
@$(ECHO) "Creating $(name)_tc..."
@$(SED) "s/\[template\]/$(name)/g" template/template.h > tc/$(name).h
@$(SED) "s/\[template\]/$(name)/g" template/template.py > tc/$(name).py
@$(ECHO) "Done"
else
@$(ECHO) "Please specify a name for the test case!! Like 'make name=my_tc'"
endif

Wyświetl plik

@ -47,6 +47,10 @@ program is then run, and one loop of `tc_main` runs the test case.
#### Writing a new test case
```
From this directory you can just run 'make name=<new_name>'
```
* Choose a testcase name `[tc-name]`
* Create `tc/[tc-name].py` and `tc/[tc_name].h`. Use a pre-existing test case as a template.
* Add `#include [tc-name].h` to the section at the top of `main.c`

Wyświetl plik

@ -0,0 +1,33 @@
#ifndef __verification__
#define __verification__
#endif
/****************************//* [template]_tc *//****************************/
/**
* Write a description of your test case here
*/
/* Parameters in */
struct [template]_tc_params {
/* Input paramters to your test case go here */
} [template]_tc_params;
/* Results out */
struct [template]_tc_results {
/* Result values should be populated here */
} [template]_tc_results;
/* Function */
__verification__ void [template]_tc(void) {
/**
* The main body of the test case goes here.
*
* Use the input parameters to run the test case. Populate the
* results structure at the end
*/
[template]_tc_results.result = 2 * [template]_tc_params.input;
}

Wyświetl plik

@ -0,0 +1,41 @@
#!/usr/bin/env python
# ------------------------------------------------------------------------------
# Imports
# ------------------------------------------------------------------------------
import sys
sys.path.append("./test")
import main
from random import randint
# ------------------------------------------------------------------------------
# Test Script
# ------------------------------------------------------------------------------
class [template]_tc:
def __init__(self):
self.name = self.__class__.__name__
self.iterations = 20
def get_test(self):
"""Returns some suitable test parameters"""
params = main.struct_[template]_tc_params()
"""
Assign input parameters here
"""
return params
def is_correct(self, params, result, print_info):
"""Returns if a result is correct for the given parameters"""
"""
Compare result and params here, decide sth.
Can use print_info
"""
return True