kopia lustrzana https://github.com/bristol-seds/pico-tracker
Added tests for memory, new test make now adds #inlcude to tmain.c
rodzic
ed27b1c0b2
commit
fc9713cb08
|
@ -15,6 +15,7 @@ ifdef name
|
|||
@$(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
|
||||
@$(SED) -i "s/\/\* \[new_tc\] \*\//\#include \"$(name).h\"\n\/\* \[new_tc\] \*\//" tmain.c
|
||||
@$(ECHO) "Done"
|
||||
else
|
||||
@$(ECHO) "Please specify a name for the test case!! Like 'make name=my_tc'"
|
||||
|
|
|
@ -53,7 +53,7 @@ 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`
|
||||
* Add `#include [tc-name].h` to the section at the top of `tmain.c`
|
||||
|
||||
You'll need to fill in the `/* Parameters In */` and `/* Results Out
|
||||
*/` structures in `tc/[tc-name].h`
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef __verification__
|
||||
#define __verification__
|
||||
#endif
|
||||
|
||||
/****************************//* mem_write_page_tc *//****************************/
|
||||
/**
|
||||
* Erases sector, Writes a page in memory and reads it back
|
||||
*/
|
||||
#include "memory.h"
|
||||
|
||||
/* Parameters in */
|
||||
struct mem_write_page_tc_params {
|
||||
|
||||
/* Input paramters to your test case go here */
|
||||
uint32_t address;
|
||||
uint8_t page[256];
|
||||
|
||||
} mem_write_page_tc_params;
|
||||
/* Results out */
|
||||
struct mem_write_page_tc_results {
|
||||
|
||||
/* Result values should be populated here */
|
||||
uint8_t page_read[256];
|
||||
|
||||
} mem_write_page_tc_results;
|
||||
/* Function */
|
||||
__verification__ void mem_write_page_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
|
||||
*/
|
||||
|
||||
init_memory();
|
||||
|
||||
mem_erase_sector(mem_write_page_tc_params.address);
|
||||
|
||||
mem_write_page(mem_write_page_tc_params.address,
|
||||
mem_write_page_tc_params.page, 0x100);
|
||||
|
||||
mem_read_memory(mem_write_page_tc_params.address,
|
||||
mem_write_page_tc_results.page_read, 0x100);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Imports
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
import sys
|
||||
sys.path.append("./test")
|
||||
import main
|
||||
|
||||
from random import randint
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Test Script
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
class mem_write_page_tc:
|
||||
def __init__(self):
|
||||
self.name = self.__class__.__name__
|
||||
self.iterations = 5
|
||||
|
||||
|
||||
def get_test(self):
|
||||
"""Returns some suitable test parameters"""
|
||||
params = main.struct_mem_write_page_tc_params()
|
||||
|
||||
"""
|
||||
Assign input parameters here
|
||||
"""
|
||||
# There are 0x800 pages
|
||||
params.address = randint(0, 0x7ff) * 0x100
|
||||
|
||||
for i in range(0x100):
|
||||
params.page[i] = randint(0, 0xff)
|
||||
|
||||
return params
|
||||
|
||||
def is_correct(self, params, result, print_info):
|
||||
"""Returns if a result is correct for the given parameters"""
|
||||
|
||||
page_read = result['page_read']
|
||||
"""
|
||||
Compare result and params here, decide sth.
|
||||
Can use print_info
|
||||
"""
|
||||
print_info("Address {:#06x}".format(params.address))
|
||||
|
||||
for i in range(0x100):
|
||||
if not page_read[i] == params.page[i]:
|
||||
print_info("Error at index {:#x}: {:#x} != {:#x}"
|
||||
.format(i, int(page_read[i]), int(params.page[i])))
|
||||
return False
|
||||
|
||||
print_info("All correct!")
|
||||
|
||||
return True
|
|
@ -39,6 +39,9 @@
|
|||
#include "times_two.h"
|
||||
#include "osc8m_calib.h"
|
||||
#include "location_aprs.h"
|
||||
#include "mem_write_page.h"
|
||||
/* [new_tc] */
|
||||
|
||||
|
||||
/******************************* tc_main ********************************/
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue