Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
DdtrTester.h
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef SKA_CHEETAH_DDTR_TEST_DDTRTESTER_H
25 #define SKA_CHEETAH_DDTR_TEST_DDTRTESTER_H
26 
27 #include "cheetah/generators/pulse_profile/ProfileManager.h"
28 #include "cheetah/ddtr/Ddtr.h"
29 #include "cheetah/utils/test_utils/AlgorithmTester.h"
30 #include "panda/ResourcePool.h"
31 #include "panda/test/TestResourcePool.h"
32 #include <gtest/gtest.h>
33 #include <vector>
34 
35 namespace ska {
36 namespace cheetah {
37 namespace ddtr {
38 namespace test {
39 
70 template<typename ArchitectureTag, typename NumericalT=uint8_t, typename TimeFrequencyT = data::TimeFrequency<cheetah::Cpu, NumericalT>>
71 struct DdtrTesterTraits : public utils::test::PoolAlgorithmTesterTraits<ArchitectureTag> {
72  public:
74  typedef ArchitectureTag Arch;
75  typedef typename BaseT::PoolType PoolType;
76  typedef NumericalT NumericalRep;
77  typedef TimeFrequencyT TimeFrequencyType;
78 
79  protected:
80  struct TestConfig : public ddtr::Config
81  {
82  typedef typename DdtrTesterTraits<ArchitectureTag>::PoolType PoolType;
83 
84  public:
85  TestConfig() : _pool(nullptr) {}
86  PoolType& pool() const { assert(_pool); return *_pool; }
87  void set_pool(PoolType& pool) { _pool = &pool; }
88 
89  protected:
90  PoolType* _pool;
91  };
92 
93  public:
95  typedef typename Api::DmTrialsType DmType;
96  typedef typename std::vector<std::shared_ptr<DmType>> DmDataContainerType;
97 
98  public:
100  DdtrTesterTraits(DdtrTesterTraits const&) = delete;
101  Api& api(PoolType& pool);
102  ddtr::Config& config();
103 
104  //return true if the dm_handler has been called
105  bool dm_handler_called() const;
106 
108  std::size_t dm_handler_call_count() const;
109  generators::ProfileManager const& profile_manager() const { return _manager; }
110  DmDataContainerType const& dm_data() const;
111 
112  protected:
113  virtual void configure(ddtr::Config&) {}
114 
115  private:
116  bool _dm_called;
117 
118  protected:
119  TestConfig _config;
120 
121  DmDataContainerType _dm_data;
122  std::size_t _dm_call_count;
123 
124  std::unique_ptr<Api> _api; // must be last member
126 };
127 
128 
129 template <typename TestTraits>
131 {
132  protected:
133  void SetUp();
134  void TearDown();
135 
136  public:
137  DdtrTester();
138  ~DdtrTester();
139 
140 
141 };
142 
143 TYPED_TEST_CASE_P(DdtrTester);
144 
145 } // namespace test
146 } // namespace ddtr
147 } // namespace cheetah
148 } // namespace ska
149 #include "cheetah/ddtr/test_utils/detail/DdtrTester.cpp"
150 
151 
152 #endif // SKA_CHEETAH_DDTR_TEST_DDTRTESTER_H
An API for accessing pulsar pulse profiles.
Some limits and constants for FLDO.
Definition: Brdz.h:35
DDTR module top level API.
Definition: Ddtr.h:68
std::size_t dm_handler_call_count() const
return true if the dm_handler has been called
Definition: DdtrTester.cpp:122
Base class for generic algortihm tests that require an accelerator device.
A continuous memory container for dispersion measure trials of varying downsamplings.
Definition: DmTrials.h:62