Added basic testcase for aprs geofence

ubseds12
Richard Meadows 2015-06-07 22:22:24 +01:00
rodzic 4098fc7e9f
commit fcef15b7c6
3 zmienionych plików z 23 dodań i 10 usunięć

Wyświetl plik

@ -38,6 +38,7 @@
#include "times_two.h"
#include "osc8m_calib.h"
#include "location_aprs.h"
/******************************* tc_main ********************************/

Wyświetl plik

@ -2,19 +2,27 @@
#define __verification__
#endif
/****************************//* location_aprs_tc *//****************************/
/* Checks the location is returning the right things etc. etc */
#include "location.h"
/* Parameters in */
struct location_aprs_tc_params {
int input;
float lat;
float lon;
} location_aprs_tc_params;
/* Results out */
struct location_aprs_tc_results {
int result;
bool tx_allow;
float frequency;
} location_aprs_tc_results;
/* Function */
__verification__ void location_aprs_tc(void) {
location_aprs_tc_results.result = 2 * location_aprs_tc_params.input;
aprs_location_update(location_aprs_tc_params.lon, location_aprs_tc_params.lat);
location_aprs_tc_results.tx_allow = aprs_location_tx_allow();
location_aprs_tc_results.frequency = aprs_location_frequency();
}

Wyświetl plik

@ -17,22 +17,26 @@ from random import randint
class location_aprs_tc:
def __init__(self):
self.name = self.__class__.__name__
self.iterations = 20
self.iterations = 30
def get_test(self):
"""Returns some suitable test parameters"""
params = main.struct_location_aprs_tc_params()
params.input = randint(0, 10000)
params.lon = -5 + randint(0, 120)*0.1;
params.lat = 52;
return params
def is_correct(self, params, result, print_info):
"""Returns if a result is correct for the given parameters"""
print_info("%d * 2 = %d"%(params.input, result['result']))
freq = result['frequency'] / (1000*1000)
status_str = "NO"
if result['tx_allow']:
status_str = "Tx"
if (params.input * 2 == result['result']):
return True
else:
return False
print_info("%f, %f = %s, %f"%(params.lon, params.lat, status_str, freq))
return True