test_mavlogdump.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env python
  2. """
  3. regression tests for mavlogdump.py
  4. """
  5. from __future__ import absolute_import, print_function
  6. import unittest
  7. import os
  8. import pkg_resources
  9. import sys
  10. class MAVLogDumpTest(unittest.TestCase):
  11. """
  12. Class to test mavlogdump
  13. """
  14. def __init__(self, *args, **kwargs):
  15. """Constructor, set up some data that is reused in many tests"""
  16. super(MAVLogDumpTest, self).__init__(*args, **kwargs)
  17. def test_dump_same(self):
  18. """Test dump of file is what we expect"""
  19. test_filename = "test.BIN"
  20. test_filepath = pkg_resources.resource_filename(__name__,
  21. test_filename)
  22. dump_filename = "tmp.dump"
  23. os.system("mavlogdump.py %s >%s" % (test_filepath, dump_filename))
  24. with open(dump_filename) as f:
  25. got = f.read()
  26. possibles = ["test.BIN.py3.dumped",
  27. "test.BIN.dumped"]
  28. success = False
  29. for expected in possibles:
  30. expected_filepath = pkg_resources.resource_filename(__name__,
  31. expected)
  32. with open(expected_filepath) as e:
  33. expected = e.read()
  34. if expected == got:
  35. success = True
  36. assert True
  37. if __name__ == '__main__':
  38. unittest.main()