Skip to content

Commit

Permalink
add unit test for codecs self test
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@9249 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 4, 2015
1 parent 4c48203 commit 70916c2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/tests/unit/codecs/codecs_selftest_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python
# This file is part of Xpra.
# Copyright (C) 2015 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import unittest


class TestDecoders(unittest.TestCase):

def test_all_codecs_found(self):
from xpra.codecs import loader
#the self tests would swallow the exceptions and produce a warning:
loader.RUN_SELF_TESTS = False
loader.load_codecs()
#test them all:
for codec_name in loader.ALL_CODECS:
codec = loader.get_codec(codec_name)
if not codec:
continue
#print("found %s: %s" % (codec_name, codec))
selftest = getattr(codec, "selftest", None)
#print("selftest=%s" % selftest)
if selftest:
selftest()



def main():
unittest.main()

if __name__ == '__main__':
main()
4 changes: 3 additions & 1 deletion src/xpra/codecs/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#do not require the libraries to be installed
NOWARN = ["nvenc3", "nvenc4", "nvenc5", "opencl"]

RUN_SELF_TESTS = True

codec_errors = {}
codecs = {}
def codec_import_check(name, description, top_module, class_module, *classnames):
Expand All @@ -36,7 +38,7 @@ def codec_import_check(name, description, top_module, class_module, *classnames)
ic = __import__(class_module, {}, {}, classname)
selftest = getattr(ic, "selftest", None)
log("%s.selftest=%s", name, selftest)
if selftest:
if RUN_SELF_TESTS and selftest:
selftest()
#log.warn("codec_import_check(%s, ..)=%s" % (name, ic))
log(" found %s : %s", name, ic)
Expand Down

0 comments on commit 70916c2

Please sign in to comment.