Skip to content

Commit

Permalink
firpfbchr: adding initial test harness
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaeddert committed Apr 16, 2024
1 parent 9e018d9 commit 4ae1006
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 6 deletions.
3 changes: 2 additions & 1 deletion makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -938,10 +938,11 @@ src/multichannel/src/firpfbch_cccf.o : %.o : %.c $(include_headers) $(multichann

# autotests
multichannel_autotests := \
src/multichannel/tests/firpfbch2_crcf_autotest.c \
src/multichannel/tests/firpfbch_crcf_synthesizer_autotest.c \
src/multichannel/tests/firpfbch_crcf_analyzer_autotest.c \
src/multichannel/tests/firpfbch_crcf_autotest.c \
src/multichannel/tests/firpfbch2_crcf_autotest.c \
src/multichannel/tests/firpfbchr_crcf_autotest.c \
src/multichannel/tests/ofdmframe_autotest.c \

# benchmarks
Expand Down
10 changes: 5 additions & 5 deletions src/multichannel/src/firpfbchr.proto.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007 - 2022 Joseph Gaeddert
* Copyright (c) 2007 - 2024 Joseph Gaeddert
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,12 +20,8 @@
* THE SOFTWARE.
*/

//
// firpfbchr.c
//
// finite impulse response polyphase filterbank channelizer with output
// rate Fs / P
//

#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -71,8 +67,12 @@ FIRPFBCHR() FIRPFBCHR(_create)(unsigned int _chans,
// validate input
if (_chans < 2)
return liquid_error_config("firpfbchr_%s_create(), number of channels must be at least 2", EXTENSION_FULL);
if (_decim < 1)
return liquid_error_config("firpfbchr_%s_create(), decimation rate must be at least 1", EXTENSION_FULL);
if (_m < 1)
return liquid_error_config("firpfbchr_%s_create(), filter semi-length must be at least 1", EXTENSION_FULL);
if (_h == NULL)
return liquid_error_config("firpfbchr_%s_create(), filter coefficients cannot be null", EXTENSION_FULL);

// create object
FIRPFBCHR() q = (FIRPFBCHR()) malloc(sizeof(struct FIRPFBCHR(_s)));
Expand Down
56 changes: 56 additions & 0 deletions src/multichannel/tests/firpfbchr_crcf_autotest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2007 - 2024 Joseph Gaeddert
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include <assert.h>
#include "autotest/autotest.h"
#include "liquid.h"

void autotest_firpfbchr_crcf_config()
{
#if LIQUID_STRICT_EXIT
AUTOTEST_WARN("skipping firpfbchr_crcf config test with strict exit enabled\n");
return;
#endif
#if !LIQUID_SUPPRESS_ERROR_OUTPUT
fprintf(stderr,"warning: ignore potential errors here; checking for invalid configurations\n");
#endif
// design prototype filter
unsigned int h_len = 2*64*12+1;
float h[2*64*12+1];
liquid_firdes_kaiser(h_len, 0.1f, 60.0f, 0.0f, h);

// check invalid function calls
CONTEND_ISNULL(firpfbchr_crcf_create( 0, 76, 12, h)) // too few channels
CONTEND_ISNULL(firpfbchr_crcf_create(64, 0, 12, h)) // decimation rate too small
CONTEND_ISNULL(firpfbchr_crcf_create(64, 76, 0, h)) // filter delay too small
CONTEND_ISNULL(firpfbchr_crcf_create(64, 76, 12, NULL)) // coefficients pointer set to NULL

//CONTEND_ISNULL(firpfbchr_crcf_copy(NULL))

// create proper object and test configurations
firpfbchr_crcf q = firpfbchr_crcf_create_kaiser(64, 76, 12, 60.0f);

CONTEND_EQUALITY(LIQUID_OK, firpfbchr_crcf_print(q))

firpfbchr_crcf_destroy(q);
}

0 comments on commit 4ae1006

Please sign in to comment.