|
| 1 | +//Test of the external CICADA model emulation model loading and model unloading |
| 2 | +//Developed by Andrew Loeliger, Princeton University, Feb 23, 2023 |
| 3 | + |
| 4 | +//We can't test a load of a bad model here, since that is a segfault, not an exception, which is |
| 5 | +//OS level and cppunit cannot test against that in any way that qualifies as a success |
| 6 | + |
| 7 | +//TODO: However, it would be good in the future to assure that loading multiple CICADA models at the |
| 8 | +//same time have the correct function symbols assigned to each simultaneously |
| 9 | +//i.e. CICADA_v1's predict is not overwritten by CICADA_v2's predict if it is loaded later with a |
| 10 | +//CICADA_v1 still around |
| 11 | + |
| 12 | +//TODO: might also be nice to have a test for model integrity? Known test cases producing known outputs? |
| 13 | +//This may not be appropriate for unit testing however. |
| 14 | + |
| 15 | +#include "ap_fixed.h" |
| 16 | +#include "hls4ml/emulator.h" |
| 17 | + |
| 18 | +#include "cppunit/extensions/HelperMacros.h" |
| 19 | +#include <memory> |
| 20 | +#include "Utilities/Testing/interface/CppUnit_testdriver.icpp" |
| 21 | + |
| 22 | +class test_CICADA: public CppUnit::TestFixture{ |
| 23 | + CPPUNIT_TEST_SUITE(test_CICADA); |
| 24 | + CPPUNIT_TEST(doModelV1Load); |
| 25 | + CPPUNIT_TEST(doModelV2Load); |
| 26 | + CPPUNIT_TEST(doMultiModelLoad); |
| 27 | + CPPUNIT_TEST_SUITE_END(); |
| 28 | + |
| 29 | + public: |
| 30 | + void doModelV1Load(); |
| 31 | + void doModelV2Load(); |
| 32 | + void doMultiModelLoad(); |
| 33 | + |
| 34 | + |
| 35 | +}; |
| 36 | + |
| 37 | +CPPUNIT_TEST_SUITE_REGISTRATION(test_CICADA); |
| 38 | + |
| 39 | +void test_CICADA::doModelV1Load(){ |
| 40 | + auto loader = hls4mlEmulator::ModelLoader("CICADAModel_v1"); |
| 41 | + auto model = loader.load_model(); |
| 42 | +} |
| 43 | + |
| 44 | +void test_CICADA::doModelV2Load(){ |
| 45 | + auto loader = hls4mlEmulator::ModelLoader("CICADAModel_v2"); |
| 46 | + auto model = loader.load_model(); |
| 47 | +} |
| 48 | + |
| 49 | +void test_CICADA::doMultiModelLoad(){ |
| 50 | + auto loader_v1 = hls4mlEmulator::ModelLoader("CICADAModel_v1"); |
| 51 | + auto loader_v2 = hls4mlEmulator::ModelLoader("CICADAModel_v2"); |
| 52 | + auto model_v1 = loader_v1.load_model(); |
| 53 | + auto model_v2 = loader_v2.load_model(); |
| 54 | +} |
| 55 | + |
| 56 | + |
| 57 | + |
0 commit comments