host: test_ctrl: typedef failure_count as an alias for size_t
This commit is contained in:
parent
3a9f1ceaa8
commit
dc72e2cc64
13 changed files with 117 additions and 113 deletions
|
|
@ -56,15 +56,15 @@ static int set_and_check(struct bladerf *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static size_t sweep_bandwidths(struct bladerf *dev,
|
||||
bladerf_module m,
|
||||
bladerf_bandwidth min,
|
||||
bladerf_bandwidth max)
|
||||
static failure_count sweep_bandwidths(struct bladerf *dev,
|
||||
bladerf_module m,
|
||||
bladerf_bandwidth min,
|
||||
bladerf_bandwidth max)
|
||||
{
|
||||
size_t const inc = 250000;
|
||||
|
||||
bladerf_bandwidth b;
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
for (b = min; b < max; b += inc) {
|
||||
|
|
@ -77,17 +77,17 @@ static size_t sweep_bandwidths(struct bladerf *dev,
|
|||
return failures;
|
||||
}
|
||||
|
||||
static size_t random_bandwidths(struct bladerf *dev,
|
||||
bladerf_module m,
|
||||
struct app_params *p,
|
||||
bladerf_bandwidth min,
|
||||
bladerf_bandwidth max)
|
||||
static failure_count random_bandwidths(struct bladerf *dev,
|
||||
bladerf_module m,
|
||||
struct app_params *p,
|
||||
bladerf_bandwidth min,
|
||||
bladerf_bandwidth max)
|
||||
{
|
||||
size_t const iterations = 1500;
|
||||
|
||||
bladerf_bandwidth bw;
|
||||
size_t i;
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
for (i = 0; i < iterations; i++) {
|
||||
|
|
@ -107,11 +107,11 @@ static size_t random_bandwidths(struct bladerf *dev,
|
|||
return failures;
|
||||
}
|
||||
|
||||
unsigned int test_bandwidth(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
failure_count test_bandwidth(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
{
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
ITERATE_DIRECTIONS({
|
||||
|
|
|
|||
|
|
@ -117,12 +117,14 @@ static int set_and_check(struct bladerf *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int sweep_vals(struct bladerf *dev, bladerf_channel ch, bool quiet)
|
||||
static failure_count sweep_vals(struct bladerf *dev,
|
||||
bladerf_channel ch,
|
||||
bool quiet)
|
||||
{
|
||||
int status;
|
||||
int val;
|
||||
size_t i;
|
||||
unsigned int failures = 0;
|
||||
failure_count failures = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(corrections); i++) {
|
||||
PRINT(" %s\n", corrections[i].name);
|
||||
|
|
@ -138,16 +140,16 @@ static int sweep_vals(struct bladerf *dev, bladerf_channel ch, bool quiet)
|
|||
return failures;
|
||||
}
|
||||
|
||||
static unsigned random_vals(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bladerf_channel ch,
|
||||
bool quiet)
|
||||
static failure_count random_vals(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bladerf_channel ch,
|
||||
bool quiet)
|
||||
{
|
||||
int status;
|
||||
int val, j;
|
||||
size_t i;
|
||||
const int iterations = 2500;
|
||||
unsigned int failures = 0;
|
||||
failure_count failures = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(corrections); i++) {
|
||||
PRINT(" %s\n", corrections[i].name);
|
||||
|
|
@ -173,11 +175,11 @@ static unsigned random_vals(struct bladerf *dev,
|
|||
}
|
||||
|
||||
|
||||
unsigned int test_correction(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
failure_count test_correction(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
{
|
||||
unsigned int failures = 0;
|
||||
failure_count failures = 0;
|
||||
|
||||
if (0 != strcmp(bladerf_get_board_name(dev), "bladerf1")) {
|
||||
PRINT("%s: board is not a bladerf1, skipping\n", __FUNCTION__);
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define DECLARE_TEST(name_) \
|
||||
extern unsigned int test_##name_(struct bladerf *, struct app_params *p, \
|
||||
bool quiet); \
|
||||
typedef size_t failure_count;
|
||||
|
||||
#define DECLARE_TEST(name_) \
|
||||
extern failure_count test_##name_(struct bladerf *, struct app_params *p, \
|
||||
bool quiet); \
|
||||
extern const struct test_case test_case_##name_;
|
||||
#endif
|
||||
|
||||
|
|
@ -73,7 +75,7 @@ struct app_params {
|
|||
|
||||
struct test_case {
|
||||
const char *name;
|
||||
unsigned int (*fn)(struct bladerf *dev, struct app_params *p, bool quiet);
|
||||
failure_count (*fn)(struct bladerf *dev, struct app_params *p, bool quiet);
|
||||
};
|
||||
|
||||
// _thing should expect a 'DIRECTION' parameter
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ static int enable_module(struct bladerf *dev, bladerf_channel ch, bool enable)
|
|||
return status;
|
||||
}
|
||||
|
||||
unsigned int test_enable_module(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
failure_count test_enable_module(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
{
|
||||
size_t const rx_ch = bladerf_get_channel_count(dev, BLADERF_RX);
|
||||
size_t const tx_ch = bladerf_get_channel_count(dev, BLADERF_TX);
|
||||
|
|
@ -55,10 +55,10 @@ unsigned int test_enable_module(struct bladerf *dev,
|
|||
bladerf_direction dir;
|
||||
int pass;
|
||||
size_t idx;
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
PRINT("%s: Enabling and disabling channels (%lu RX, %lu TX)...\n",
|
||||
PRINT("%s: Enabling and disabling channels (%zu RX, %zu TX)...\n",
|
||||
__FUNCTION__, rx_ch, tx_ch);
|
||||
|
||||
// do off, then on, then off
|
||||
|
|
|
|||
|
|
@ -70,11 +70,11 @@ static int set_and_check(struct bladerf *dev,
|
|||
return status;
|
||||
}
|
||||
|
||||
static int freq_sweep(struct bladerf *dev,
|
||||
bladerf_module m,
|
||||
bladerf_frequency min,
|
||||
bladerf_frequency max,
|
||||
bool quiet)
|
||||
static failure_count freq_sweep(struct bladerf *dev,
|
||||
bladerf_module m,
|
||||
bladerf_frequency min,
|
||||
bladerf_frequency max,
|
||||
bool quiet)
|
||||
{
|
||||
size_t const repetitions = 3;
|
||||
size_t const inc = 1000000;
|
||||
|
|
@ -82,7 +82,7 @@ static int freq_sweep(struct bladerf *dev,
|
|||
bladerf_frequency freq = 0;
|
||||
bladerf_frequency prev_freq = 0;
|
||||
size_t n, r;
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
for (r = 0; r < repetitions; r++) {
|
||||
|
|
@ -105,19 +105,19 @@ static int freq_sweep(struct bladerf *dev,
|
|||
return failures;
|
||||
}
|
||||
|
||||
static int random_tuning(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bladerf_module m,
|
||||
bladerf_frequency min,
|
||||
bladerf_frequency max,
|
||||
bool quiet)
|
||||
static failure_count random_tuning(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bladerf_module m,
|
||||
bladerf_frequency min,
|
||||
bladerf_frequency max,
|
||||
bool quiet)
|
||||
{
|
||||
size_t const num_iterations = 10000;
|
||||
|
||||
bladerf_frequency freq = 0;
|
||||
bladerf_frequency prev_freq = 0;
|
||||
size_t i, n;
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
for (i = n = 0; i < num_iterations; i++, n++) {
|
||||
|
|
@ -147,11 +147,11 @@ static int random_tuning(struct bladerf *dev,
|
|||
return failures;
|
||||
}
|
||||
|
||||
unsigned int test_frequency(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
failure_count test_frequency(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
{
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
ITERATE_DIRECTIONS({
|
||||
|
|
|
|||
|
|
@ -82,12 +82,12 @@ static inline int set_and_check(struct bladerf *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int gain_sweep(struct bladerf *dev,
|
||||
bladerf_channel ch,
|
||||
bool quiet)
|
||||
static failure_count gain_sweep(struct bladerf *dev,
|
||||
bladerf_channel ch,
|
||||
bool quiet)
|
||||
{
|
||||
char const **stages = NULL;
|
||||
size_t failures = 0;
|
||||
char const **stages = NULL;
|
||||
failure_count failures = 0;
|
||||
size_t i;
|
||||
int status;
|
||||
|
||||
|
|
@ -156,15 +156,15 @@ out:
|
|||
return failures;
|
||||
}
|
||||
|
||||
static int random_gains(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bladerf_channel ch,
|
||||
bool quiet)
|
||||
static failure_count random_gains(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bladerf_channel ch,
|
||||
bool quiet)
|
||||
{
|
||||
size_t const iterations = 250;
|
||||
|
||||
char const **stages = NULL;
|
||||
size_t failures = 0;
|
||||
char const **stages = NULL;
|
||||
failure_count failures = 0;
|
||||
size_t i, j;
|
||||
int status;
|
||||
|
||||
|
|
@ -243,9 +243,9 @@ out:
|
|||
return failures;
|
||||
}
|
||||
|
||||
unsigned int test_gain(struct bladerf *dev, struct app_params *p, bool quiet)
|
||||
failure_count test_gain(struct bladerf *dev, struct app_params *p, bool quiet)
|
||||
{
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
|
||||
ITERATE_DIRECTIONS({
|
||||
ITERATE_CHANNELS(
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ static int set_and_check(struct bladerf *dev, bladerf_loopback l)
|
|||
return 0;
|
||||
}
|
||||
|
||||
unsigned int test_loopback(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
failure_count test_loopback(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
{
|
||||
size_t count, i;
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
PRINT("%s: Setting and checking loopback modes...\n", __FUNCTION__);
|
||||
|
|
|
|||
|
|
@ -57,10 +57,10 @@ static int set_and_check(struct bladerf *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int test_module(struct bladerf *dev, bladerf_channel ch)
|
||||
static failure_count test_module(struct bladerf *dev, bladerf_channel ch)
|
||||
{
|
||||
int status;
|
||||
unsigned int failures = 0;
|
||||
failure_count failures = 0;
|
||||
|
||||
status = set_and_check(dev, ch, BLADERF_LPF_NORMAL);
|
||||
if (status != 0) {
|
||||
|
|
@ -85,11 +85,11 @@ static inline int test_module(struct bladerf *dev, bladerf_channel ch)
|
|||
return failures;
|
||||
}
|
||||
|
||||
unsigned int test_lpf_mode(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
failure_count test_lpf_mode(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
{
|
||||
unsigned int failures = 0;
|
||||
failure_count failures = 0;
|
||||
|
||||
if (0 != strcmp(bladerf_get_board_name(dev), "bladerf1")) {
|
||||
PRINT("%s: board is not a bladerf1, skipping\n", __FUNCTION__);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ static int set_and_check(struct bladerf *dev, bladerf_rx_mux mux)
|
|||
return 0;
|
||||
}
|
||||
|
||||
unsigned int test_rx_mux(struct bladerf *dev, struct app_params *p, bool quiet)
|
||||
failure_count test_rx_mux(struct bladerf *dev, struct app_params *p, bool quiet)
|
||||
{
|
||||
bladerf_rx_mux const muxes[] = {
|
||||
// clang-format off
|
||||
|
|
@ -73,7 +73,7 @@ unsigned int test_rx_mux(struct bladerf *dev, struct app_params *p, bool quiet)
|
|||
};
|
||||
|
||||
size_t i;
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
PRINT("%s: Setting and checking rx muxes...\n", __FUNCTION__);
|
||||
|
|
|
|||
|
|
@ -88,17 +88,17 @@ static int set_and_check_rational(struct bladerf *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int sweep_samplerate(struct bladerf *dev,
|
||||
bladerf_channel ch,
|
||||
bool quiet,
|
||||
bladerf_sample_rate min,
|
||||
bladerf_sample_rate max)
|
||||
static failure_count sweep_samplerate(struct bladerf *dev,
|
||||
bladerf_channel ch,
|
||||
bool quiet,
|
||||
bladerf_sample_rate min,
|
||||
bladerf_sample_rate max)
|
||||
{
|
||||
size_t const inc = 10000;
|
||||
|
||||
bladerf_sample_rate rate;
|
||||
size_t n;
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
for (rate = min, n = 0; rate <= max; rate += inc, n++) {
|
||||
|
|
@ -116,18 +116,18 @@ static int sweep_samplerate(struct bladerf *dev,
|
|||
return failures;
|
||||
}
|
||||
|
||||
static int random_samplerates(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bladerf_channel ch,
|
||||
bool quiet,
|
||||
bladerf_sample_rate min,
|
||||
bladerf_sample_rate max)
|
||||
static failure_count random_samplerates(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bladerf_channel ch,
|
||||
bool quiet,
|
||||
bladerf_sample_rate min,
|
||||
bladerf_sample_rate max)
|
||||
{
|
||||
size_t const interations = 2500;
|
||||
|
||||
bladerf_sample_rate rate;
|
||||
size_t i, n;
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
for (i = n = 0; i < interations; i++, n++) {
|
||||
|
|
@ -152,12 +152,12 @@ static int random_samplerates(struct bladerf *dev,
|
|||
return failures;
|
||||
}
|
||||
|
||||
static int random_rational_samplerates(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bladerf_channel ch,
|
||||
bool quiet,
|
||||
bladerf_sample_rate min,
|
||||
bladerf_sample_rate max)
|
||||
static failure_count random_rational_samplerates(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bladerf_channel ch,
|
||||
bool quiet,
|
||||
bladerf_sample_rate min,
|
||||
bladerf_sample_rate max)
|
||||
{
|
||||
size_t const iterations = 2500;
|
||||
|
||||
|
|
@ -218,11 +218,11 @@ static int random_rational_samplerates(struct bladerf *dev,
|
|||
return failures;
|
||||
}
|
||||
|
||||
unsigned int test_samplerate(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
failure_count test_samplerate(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
{
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
ITERATE_DIRECTIONS({
|
||||
|
|
|
|||
|
|
@ -71,12 +71,12 @@ static int set_and_check(struct bladerf *dev, bladerf_sampling s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
unsigned int test_sampling(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
failure_count test_sampling(struct bladerf *dev,
|
||||
struct app_params *p,
|
||||
bool quiet)
|
||||
{
|
||||
int status;
|
||||
unsigned int failures = 0;
|
||||
failure_count failures = 0;
|
||||
|
||||
if (0 != strcmp(bladerf_get_board_name(dev), "bladerf1")) {
|
||||
PRINT("%s: board is not a bladerf1, skipping\n", __FUNCTION__);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ struct thread_state {
|
|||
bool launched;
|
||||
struct bladerf *dev;
|
||||
struct app_params *p;
|
||||
size_t failures;
|
||||
failure_count failures;
|
||||
struct thread_test_case const *tc;
|
||||
pthread_t thread;
|
||||
};
|
||||
|
|
@ -185,14 +185,14 @@ void *run_test_fn(void *arg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int test_threads(struct bladerf *dev, struct app_params *p, bool quiet)
|
||||
failure_count test_threads(struct bladerf *dev, struct app_params *p, bool quiet)
|
||||
{
|
||||
size_t const num_threads = ARRAY_SIZE(tc);
|
||||
|
||||
struct sync_task rx, tx;
|
||||
struct thread_state *threads = NULL;
|
||||
size_t i;
|
||||
size_t failures = 0;
|
||||
failure_count failures = 0;
|
||||
int status;
|
||||
|
||||
// Workaround for https://github.com/Nuand/bladeRF/issues/705
|
||||
|
|
|
|||
|
|
@ -83,10 +83,10 @@ static int set_and_check_filterbank(struct bladerf *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int test_paths(struct bladerf *dev)
|
||||
static failure_count test_paths(struct bladerf *dev)
|
||||
{
|
||||
int status;
|
||||
unsigned int failures = 0;
|
||||
failure_count failures = 0;
|
||||
|
||||
status =
|
||||
set_and_check_paths(dev, BLADERF_CHANNEL_RX(0), BLADERF_XB200_BYPASS);
|
||||
|
|
@ -113,10 +113,10 @@ static int test_paths(struct bladerf *dev)
|
|||
return failures;
|
||||
}
|
||||
|
||||
static int test_filterbanks(struct bladerf *dev)
|
||||
static failure_count test_filterbanks(struct bladerf *dev)
|
||||
{
|
||||
int status;
|
||||
unsigned int failures = 0;
|
||||
failure_count failures = 0;
|
||||
|
||||
status = set_and_check_filterbank(dev, BLADERF_CHANNEL_RX(0),
|
||||
BLADERF_XB200_50M); //
|
||||
|
|
@ -169,9 +169,9 @@ static int test_filterbanks(struct bladerf *dev)
|
|||
return failures;
|
||||
}
|
||||
|
||||
unsigned int test_xb200(struct bladerf *dev, struct app_params *p, bool quiet)
|
||||
failure_count test_xb200(struct bladerf *dev, struct app_params *p, bool quiet)
|
||||
{
|
||||
unsigned int failures = 0;
|
||||
failure_count failures = 0;
|
||||
|
||||
if (!p->use_xb200) {
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue