-
Notifications
You must be signed in to change notification settings - Fork 14
/
srsPDCCHCandidatesUeUnittest.m
162 lines (135 loc) · 6.09 KB
/
srsPDCCHCandidatesUeUnittest.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
%srsPDCCHCandidatesUeUnittest Unit tests for PDCCH Candidates generation in UE-Specific SS.
% This class implements unit tests for the PDCCH Candidates in
% UE-Specific SS generation functions using the matlab.unittest
% framework. The simplest use consists in creating an object with
% testCase = srsPDCCHCandidatesUeUnittest
% and then running all the tests with
% testResults = testCase.run
%
% srsPDCCHCandidatesUeUnittest Properties (Constant):
%
% srsBlock - The tested block (i.e., 'pdcch_candidates_ue').
% srsBlockType - The type of the tested block, including layer
% (i.e., 'ran/pdcch').
%
% srsPDCCHCandidatesUeUnittest Properties (ClassSetupParameter):
%
% outputPath - Path to the folder where the test results are stored.
%
% srsPDCCHCandidatesUeUnittest Properties (TestParameter):
%
% numCCEs - Number of CCE available in the CORESET.
% numCandidates - Number of candidates given by the SS configuration.
% aggregationLevel - Number of CCE taken by a PDCCH transmission.
%
% srsPDCCHCandidatesUeUnittest Methods (TestTags = {'testvector'}):
%
% testvectorGenerationCases - Generates a test vector according to the provided
% parameters.
%
% srsPDCCHCandidatesUeUnittest Methods (Access = protected):
%
% addTestIncludesToHeaderFile - Adds include directives to the test header file.
% addTestDefinitionToHeaderFile - Adds details (e.g., type/variable declarations)
% to the test header file.
%
% See also matlab.unittest.
% 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.
classdef srsPDCCHCandidatesUeUnittest < srsTest.srsBlockUnittest
properties (Constant)
%Name of the tested block.
srsBlock = 'pdcch_candidates_ue'
%Type of the tested block.
srsBlockType = 'ran/pdcch'
end
properties (ClassSetupParameter)
%Path to results folder (old 'pdcch_candidates_ue' tests will be erased).
outputPath = {['testPDCCHCandidatesUe', char(datetime('now', 'Format', 'yyyyMMdd''T''HHmmss'))]}
end
properties (TestParameter)
%CORESET number of CCEs.
numCCEs = {24, 48, 72, 96, 120, 144};
%Number of candidates.
numCandidates = {0, 1, 2, 3, 4, 5, 6, 7, 8};
%PDCCH aggregation level (1, 2, 4, 8, 16).
aggregationLevel= {1, 2, 4, 8, 16};
end
methods (Access = protected)
function addTestIncludesToHeaderFile(~, fileID)
%addTestIncludesToHeaderFile Adds include directives to the test header file.
fprintf(fileID, '#include "srsran/ran/pdcch/pdcch_candidates.h"\n');
end
function addTestDefinitionToHeaderFile(~, fileID)
%addTestDetailsToHeaderFile Adds details (e.g., type/variable declarations) to the test header file.
fprintf(fileID, [...
'\n'...
'struct test_case_t {\n'...
' pdcch_candidates_ue_ss_configuration config;\n'...
' pdcch_candidate_list candidates;\n'...
'};\n'
]);
end
end % of methods (Access = protected)
methods (Test, TestTags = {'testvector'})
function testvectorGenerationCases(testCase, numCCEs, numCandidates, aggregationLevel)
%testvectorGenerationCases Generates a test vector for the given
% number of CCE, number of candidates and AggregationLevel. It
% randomly selects the CoresetId, the rnti and the slotNum.
% Skip test case if the number of CCEs for the CORESET cannot
% fit all the candidates.
if aggregationLevel * numCandidates > numCCEs
return;
end
% Allow zero candidates only if the aggregation level is one.
if (numCandidates == 0) && (aggregationLevel ~= 1)
return;
end
% Select random parameters.
CoresetId = randi([1, 11]);
rnti = randi([1, 65519]);
slotNum = randi([0, 159]);
import srsTest.helpers.cellarray2str
import srsLib.ran.pdcch.srsPDCCHCandidatesUE
candidates = srsPDCCHCandidatesUE(numCCEs, numCandidates, aggregationLevel, CoresetId, rnti, slotNum);
% Generate a unique test ID.
testID = testCase.generateTestID;
aggregationLevelString = sprintf('aggregation_level::n%d', aggregationLevel);
CoresetIdString = sprintf('to_coreset_id(%d)', CoresetId);
rntiString = sprintf('to_rnti(%d)', rnti);
configCell = {...
aggregationLevelString, ... % L
numCandidates, ... % nof_candidates
numCCEs, ... % nof_cce_coreset
CoresetIdString, ... % coreset_id
rntiString, ... % rnti
slotNum, ... % slot_index
};
configStr = cellarray2str(configCell, true);
if isempty(candidates)
candidatesCell = {};
else
candidatesCell = {candidates};
end
candidatesStr = cellarray2str(candidatesCell, length(candidates) <= 1);
testCaseData = {configStr, candidatesStr};
% Generate the test case entry.
testCaseString = testCase.testCaseToString(testID, testCaseData,...
false);
% Add the test to the file header.
testCase.addTestToHeaderFile(testCase.headerFileID, testCaseString);
end % of function testvectorGenerationCases
end % of methods (Test, TestTags = {'testvector'})
end % of classdef srsPDCCHCandidatesUeUnittest< srsTest.srsBlockUnittest