From 06d4b31d438c69dd47164c3661f3497fb5e869cb Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 24 Jul 2019 17:04:47 +0200 Subject: add simple AnalyticModel test --- test/onboardtimingharness-to-analytic-model.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 test/onboardtimingharness-to-analytic-model.py (limited to 'test/onboardtimingharness-to-analytic-model.py') diff --git a/test/onboardtimingharness-to-analytic-model.py b/test/onboardtimingharness-to-analytic-model.py new file mode 100755 index 0000000..ed908c5 --- /dev/null +++ b/test/onboardtimingharness-to-analytic-model.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +from dfatool import AnalyticModel, TimingData, pta_trace_to_aggregate +import unittest + +class TestModels(unittest.TestCase): + def test_model_singlefile_rf24(self): + raw_data = TimingData(['../data/20190724_161440_nRF24_no-rx.json']) + preprocessed_data = raw_data.get_preprocessed_data(verbose = False) + by_name, parameters, arg_count = pta_trace_to_aggregate(preprocessed_data) + model = AnalyticModel(by_name, parameters, verbose = False) + self.assertEqual(model.names, 'setAutoAck setPALevel setRetries setup startListening stopListening write'.split(' ')) + static_model = model.get_static() + self.assertAlmostEqual(static_model('setAutoAck', 'duration'), 72, places=0) + self.assertAlmostEqual(static_model('setPALevel', 'duration'), 145, places=0) + self.assertAlmostEqual(static_model('setRetries', 'duration'), 72, places=0) + self.assertAlmostEqual(static_model('setup', 'duration'), 6464, places=0) + self.assertAlmostEqual(static_model('startListening', 'duration'), 455, places=0) + self.assertAlmostEqual(static_model('stopListening', 'duration'), 487, places=0) + self.assertAlmostEqual(static_model('write', 'duration'), 5877, places=0) + + for transition in 'setAutoAck setPALevel setRetries setup startListening stopListening'.split(' '): + self.assertAlmostEqual(model.stats.param_dependence_ratio(transition, 'duration', 'channel'), 0, places=2) + + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3