[vlc-commits] lua: automatic test for some lua functions.

Rémi Duraffort git at videolan.org
Sun Jul 17 21:16:43 CEST 2011


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Jul 15 10:06:59 2011 +0200| [a97ded4dcf13eafd8d5aa1aedf14eeebd3ac0414] | committer: Rémi Duraffort

lua: automatic test for some lua functions.

This is really basic for the moment but already allows to find (and fix) one bug.
The test is not activated by default. VLC quits if the test succeed or wait forever
if the test fails so run it with the following command:
"timeout 5 ./vlc -I luaintf --lua-intf=test"

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a97ded4dcf13eafd8d5aa1aedf14eeebd3ac0414
---

 share/lua/intf/test.lua |   52 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/share/lua/intf/test.lua b/share/lua/intf/test.lua
new file mode 100644
index 0000000..20259e0
--- /dev/null
+++ b/share/lua/intf/test.lua
@@ -0,0 +1,52 @@
+function assert_url(result, protocol, username, password, host, port, path)
+    assert(result.protocol == protocol)
+    assert(result.username == username)
+    assert(result.password == password)
+    assert(result.host     == host)
+    assert(result.port     == port)
+    assert(result.path     == path)
+end
+
+local timer_count = 0
+function timer_callback()
+  timer_count = timer_count + 1
+end
+
+vlc.msg.info('---- Testing misc functions ----')
+vlc.msg.info('version: ' .. vlc.misc.version())
+vlc.msg.info('copyright: ' .. vlc.misc.copyright())
+vlc.msg.info('license: ' .. vlc.misc.license())
+vlc.msg.info('datadir: ' .. vlc.misc.datadir())
+vlc.msg.info('userdatadir: ' .. vlc.misc.userdatadir())
+vlc.msg.info('homedir: ' .. vlc.misc.homedir())
+vlc.msg.info('configdir: ' .. vlc.misc.configdir())
+vlc.msg.info('cachedir: ' .. vlc.misc.cachedir())
+vlc.msg.info('mdate: ' .. vlc.misc.mdate())
+
+vlc.msg.info(' * Testing the timer')
+local timer = vlc.misc.timer('timer_callback')
+timer:schedule(true, 100, 0)
+vlc.misc.mwait(vlc.misc.mdate()+1000000)
+assert(timer_count == 1)
+vlc.msg.info('   [done]')
+
+vlc.msg.info('---- Testing net functions ----')
+vlc.msg.info(' * testing vlc.net.url_parse')
+vlc.msg.info('    "filename.ext"')
+assert_url(vlc.net.url_parse('file:///filename.ext'), 'file', nil, nil,
+           nil, 0, '/filename.ext')
+vlc.msg.info('    "http://server.org/path/file.ext"')
+assert_url(vlc.net.url_parse('http://server.org/path/file.ext'),
+           'http', nil, nil, 'server.org', 0, '/path/file.ext')
+vlc.msg.info('    "rtmp://server.org:4212/bla.ext"')
+assert_url(vlc.net.url_parse('rtmp://server.org:4212/bla.ext'),
+           'rtmp', nil, nil, 'server.org', 4212, '/bla.ext')
+vlc.msg.info('    "ftp://userbla@server.org:4567/bla.ext"')
+assert_url(vlc.net.url_parse('rtmp://userbla@server.org:4567/bla.ext'),
+           'rtmp', 'userbla', nil, 'server.org', 4567, '/bla.ext')
+vlc.msg.info('    "sftp://userbla:Passw0rd@server.org/bla.ext"')
+assert_url(vlc.net.url_parse('sftp://userbla:Passw0rd@server.org/bla.ext'),
+           'sftp', 'userbla', 'Passw0rd', 'server.org', 0, '/bla.ext')
+vlc.msg.info("")
+
+vlc.misc.quit()



More information about the vlc-commits mailing list