diff --git a/firmware/test/tc/backlog_read.h b/firmware/test/tc/backlog_read.h new file mode 100644 index 0000000..9c9adf9 --- /dev/null +++ b/firmware/test/tc/backlog_read.h @@ -0,0 +1,50 @@ +#ifndef __verification__ +#define __verification__ +#endif + +/****************************//* backlog_read_tc *//****************************/ +/** + * Write a description of your test case here + */ +#include + +#include "backlog.h" +#include "data.h" + +/* Parameters in */ +struct backlog_read_tc_params { + + uint32_t dummy; + +} backlog_read_tc_params; +/* Results out */ +struct backlog_read_tc_results { + + /* Result values should be populated here */ + char aprs_backlog_str[256]; + uint8_t returned_null; + +} backlog_read_tc_results; +/* Function */ +extern uint16_t backlog_index; +__verification__ void backlog_read_tc(void) { + + struct tracker_datapoint* dp_ptr; + + /** + * 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 + */ + + /* Read and format backlog */ + dp_ptr = get_backlog(); + + if (dp_ptr != NULL) { + encode_backlog(backlog_read_tc_results.aprs_backlog_str, dp_ptr); + backlog_read_tc_results.returned_null = 0; + } else { + backlog_read_tc_results.returned_null = 1; + } +} diff --git a/firmware/test/tc/backlog_read.py b/firmware/test/tc/backlog_read.py new file mode 100644 index 0000000..5008fee --- /dev/null +++ b/firmware/test/tc/backlog_read.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +# ------------------------------------------------------------------------------ +# Imports +# ------------------------------------------------------------------------------ + +import sys +sys.path.append("./test") +import main + +from random import randint + +# ------------------------------------------------------------------------------ +# Test Script +# ------------------------------------------------------------------------------ + +class backlog_read_tc: + def __init__(self): + self.name = self.__class__.__name__ + + self.iterations = 256 + self.index = 0 + self.backlog = [] + + def get_test(self): + """Returns some suitable test parameters""" + params = main.struct_backlog_read_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 + """ + + if int(result['returned_null']): + print_info("get_backlog returned null"); + return False + + # Print backlog string + aprs_backlog_str = result['aprs_backlog_str'] + self.backlog.append(aprs_backlog_str) + + self.index = self.index + 1 + print_info("{}".format(self.index)) + + if (self.index >= self.iterations): # Last iteration + for r in range(self.iterations): + # Playback order + index = r + # Physical order + #index = sum(1<<(7-i) for i in range(8) if r>>i&1) + + # Print at index + print_info("{:03d}: {}".format(index, self.backlog[index])) + + return True diff --git a/firmware/test/tmain.c b/firmware/test/tmain.c index 8d52cb0..507de7c 100644 --- a/firmware/test/tmain.c +++ b/firmware/test/tmain.c @@ -44,6 +44,7 @@ #include "mem_write_all.h" #include "location_aprs_file.h" #include "backlog_write_read.h" +#include "backlog_read.h" #include "mem_erase_all.h" #include "adc_battery_solar_read.h" #include "gps_baud_error.h"