Commit a97ded4d authored by Rémi Duraffort's avatar 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"
parent e8281725
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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment