-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathrunSRSRANUnittest.m
184 lines (177 loc) · 7.65 KB
/
runSRSRANUnittest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
%runSRSRANUnittest Main srsRAN test interface.
% runSRSRANUnittest(BLOCKNAME, 'testvector') generates test vectors for the
% srsRAN block BLOCKNAME. The resulting test vectores are stored in the folder
% 'testvector_outputs' in the current directory. Example:
% runSRSRANUnittest('modulation_mapper', 'testvector')
%
% runSRSRANUnittest(BLOCKNAME, 'testmex') tests the srsRAN block
% BLOCKNAME by running a MEX version of it.
%
% runSRSRANUnittest(..., RandomShuffle=true) runs the tests using the 'shuffle'
% random generator initialization instead of 'default'.
%
% runSRSRANUnittest('all', ...) runs all the tests of the specified type.
%
% TEST = runSRSRANUnittest(...) returns a Test object TEST withouth running it.
% The test can be later executed with the command TEST.run.
% Copyright 2021-2024 Software Radio Systems Limited
%
% This file is part of srsRAN-matlab.
%
% srsRAN-matlab is free software: you can redistribute it and/or
% modify it under the terms of the BSD 2-Clause License.
%
% srsRAN-matlab is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% BSD 2-Clause License for more details.
%
% A copy of the BSD 2-Clause License can be found in the LICENSE
% file in the top-level directory of this distribution.
function test = runSRSRANUnittest(blockName, testType, opt)
arguments
blockName char {mustBeSRSBlock}
testType char {mustBeMember(testType, {'testvector', 'testmex'})}
opt.RandomShuffle logical {mustBeNumericOrLogical} = false
end
import matlab.unittest.TestSuite
import matlab.unittest.parameters.Parameter
% define the absolute output paths
outputPath = [pwd '/testvector_outputs'];
extParams = Parameter.fromData('outputPath', {outputPath}, 'RandomDefault', {~opt.RandomShuffle});
if ~strcmp(blockName, 'all')
unittestClass = name2Class(blockName);
nrPHYtestvectorTests = TestSuite.fromClass(unittestClass, ...
'Tag', testType, 'ExternalParameters', extParams);
if isempty(nrPHYtestvectorTests)
warning('No ''%s'' tests for the ''%s'' block.', testType, blockName);
end
else
nrPHYtestvectorTests = TestSuite.fromFolder('.', 'Tag', testType, ...
'ExternalParameters', extParams);
end
if nargout == 1
test = nrPHYtestvectorTests;
else
nrPHYtestvectorTests.run;
end % of if nargout == 1
end % of runSRSRANUnittest
function mustBeSRSBlock(a)
validBlocks = union({'all'}, srsTest.listSRSblocks);
mustBeMember(a, validBlocks);
end
function unittestClass = name2Class(name)
switch name
case 'channel_equalizer'
unittestClass = ?srsChEqualizerUnittest;
case 'demodulation_mapper'
unittestClass = ?srsDemodulationMapperUnittest;
case 'dft_processor'
unittestClass = ?srsDFTProcessorUnittest;
case 'dmrs_pbch_processor'
unittestClass = ?srsPBCHdmrsUnittest;
case 'dmrs_pdcch_processor'
unittestClass = ?srsPDCCHdmrsUnittest;
case 'dmrs_pdsch_processor'
unittestClass = ?srsPDSCHdmrsUnittest;
case 'dmrs_pucch_estimator'
unittestClass = ?srsPUCCHdmrsUnittest;
case 'dmrs_pusch_estimator'
unittestClass = ?srsPUSCHdmrsUnittest;
case 'ldpc_encoder'
unittestClass = ?srsLDPCEncoderUnittest;
case 'ldpc_rate_matcher'
unittestClass = ?srsLDPCRateMatcherUnittest;
case 'ldpc_segmenter'
unittestClass = ?srsLDPCSegmenterUnittest;
case 'low_papr_sequence_generator'
unittestClass = ?srsLowPAPRSequenceUnittest;
case 'modulation_mapper'
unittestClass = ?srsModulationMapperUnittest;
case 'nzp_csi_rs_generator'
unittestClass = ?srsNZPCSIRSGeneratorUnittest;
case 'ofdm_demodulator'
unittestClass = ?srsOFDMDemodulatorUnittest;
case 'ofdm_modulator'
unittestClass = ?srsOFDMModulatorUnittest;
case 'ofdm_prach_demodulator'
unittestClass = ? srsPRACHDemodulatorUnittest;
case 'ofh_compression'
unittestClass = ?srsOFHCompressionUnittest;
case 'pbch_encoder'
unittestClass = ?srsPBCHEncoderUnittest;
case 'pbch_modulator'
unittestClass = ?srsPBCHModulatorUnittest;
case 'pdcch_candidates_common'
unittestClass = ?srsPDCCHCandidatesCommonUnittest;
case 'pdcch_candidates_ue'
unittestClass = ?srsPDCCHCandidatesUeUnittest;
case 'pdcch_encoder'
unittestClass = ?srsPDCCHEncoderUnittest;
case 'pdcch_modulator'
unittestClass = ?srsPDCCHModulatorUnittest;
case 'pdcch_processor'
unittestClass = ?srsPDCCHProcessorUnittest;
case 'pdsch_encoder'
unittestClass = ?srsPDSCHEncoderUnittest;
case 'pdsch_modulator'
unittestClass = ?srsPDSCHModulatorUnittest;
case 'pdsch_processor'
unittestClass = ?srsPDSCHProcessorUnittest;
case 'port_channel_estimator'
unittestClass = ?srsChEstimatorUnittest;
case 'prach_detector'
unittestClass = ?srsPRACHDetectorUnittest;
case 'prach_generator'
unittestClass = ?srsPRACHGeneratorUnittest;
case 'ptrs_pdsch_generator'
unittestClass = ?srsPDSCHPTRSGeneratorUnittest;
case 'pucch_demodulator_format2'
unittestClass = ?srsPUCCHDemodulatorFormat2Unittest;
case 'pucch_demodulator_format3'
unittestClass = ?srsPUCCHDemodulatorFormat3Unittest;
case 'pucch_demodulator_format4'
unittestClass = ?srsPUCCHDemodulatorFormat4Unittest;
case 'pucch_detector'
unittestClass = ?srsPUCCHDetectorFormat1Unittest;
case 'pucch_processor_format0'
unittestClass = ?srsPUCCHProcessorFormat0Unittest;
case 'pucch_processor_format1'
unittestClass = ?srsPUCCHProcessorFormat1Unittest;
case 'pucch_processor_format2'
unittestClass = ?srsPUCCHProcessorFormat2Unittest;
case 'pucch_processor_format3'
unittestClass = ?srsPUCCHProcessorFormat3Unittest;
case 'pucch_processor_format4'
unittestClass = ?srsPUCCHProcessorFormat4Unittest;
case 'pusch_decoder'
unittestClass = ?srsPUSCHDecoderUnittest;
case 'pusch_demodulator'
unittestClass = ?srsPUSCHDemodulatorUnittest;
case 'pusch_processor'
unittestClass = ?srsPUSCHProcessorUnittest;
case 'pusch_tpmi_select'
unittestClass = ?srsTPMISelectUnittest;
case 'short_block_detector'
unittestClass = ?srsShortBlockDetectorUnittest;
case 'short_block_encoder'
unittestClass = ?srsShortBlockEncoderUnittest;
case 'srs_estimator'
unittestClass = ?srsSRSEstimatorUnittest;
case 'ssb_processor'
unittestClass = ?srsSSBProcessorUnittest;
case 'tbs_calculator'
unittestClass = ?srsTBSCalculatorUnittest;
case 'transform_precoder'
unittestClass = ?srsTransformPrecoderUnittest;
case 'uci_decoder'
unittestClass = ?srsUCIDecoderUnittest;
case 'ulsch_demultiplex'
unittestClass = ?srsULSCHDemultiplexUnittest;
case 'ulsch_info'
unittestClass = ?srsULSCHInfoUnittest;
otherwise
error('srsran_matlab:runSRSRANUnittest:unknownBlock', ...
'No unit test for block %s.\n', name);
end
end