[vlc-commits] commit: test: add an automatic test for the telnet interface ( Rémi Duraffort )

git at videolan.org git at videolan.org
Mon Nov 1 11:12:17 CET 2010


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Mon Nov  1 11:09:24 2010 +0100| [7b814718518673692a4db2472e3569162e056097] | committer: Rémi Duraffort 

test: add an automatic test for the telnet interface

Some important things:
 * the test is deactivated by default as it needed netcat. To activate it you
just need to add check_SCRIPTS to the TESTS variable (I won't do it unless we
think that netcat is present on every hosts that run the make check?)
 * the test is really simple for the moment (that's more a POC)
 * we can write a small netcat-like tool to activate this test by default...

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

 test/Makefile.am                |    3 ++
 test/modules/misc/lua/telnet.sh |   50 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/test/Makefile.am b/test/Makefile.am
index e88f78c..c15dfff 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -22,6 +22,9 @@ check_PROGRAMS = \
 	test_src_misc_variables \
         $(NULL)
 
+check_SCRIPTS = \
+    modules/misc/lua/telnet.sh
+
 # Disabled test:
 # meta: No suitable test file
 EXTRA_PROGRAMS = \
diff --git a/test/modules/misc/lua/telnet.sh b/test/modules/misc/lua/telnet.sh
new file mode 100755
index 0000000..6dea4c6
--- /dev/null
+++ b/test/modules/misc/lua/telnet.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+killer()
+{
+  sleep 2 && ps $1 > /dev/null && touch "telnet_fail" && kill -9 $1
+}
+
+wait_or_quit()
+{
+  wait $1
+  if [ `ls telnet_fail 2> /dev/null | wc -l` = 1 ]
+  then
+    rm -f telnet_fail
+    exit 1
+  fi
+}
+
+# Remove the fail file if needed
+rm -f telnet_fail
+
+# Test that VLC handle options correctly
+../vlc -I luatelnet &
+VLC1=$!
+sleep 1
+killer $VLC1 &
+echo "admin\nshutdown\n" | nc localhost 4212
+wait_or_quit $VLC1
+
+../vlc -I luatelnet --telnet-port 4312 &
+VLC2=$!
+sleep 1
+killer $VLC2 &
+echo "admin\nshutdown\n" | nc localhost 4312
+wait_or_quit $VLC2
+
+../vlc -I luatelnet --telnet-port 1234 --telnet-password bla &
+VLC3=$!
+sleep 1
+killer $VLC3 &
+echo "bla\nshutdown\n" | nc localhost 1234
+wait_or_quit $VLC3
+
+../vlc -I luatelnet --telnet-port 1234 --telnet-password one_long_password &
+VLC4=$!
+sleep 1
+killer $VLC4 &
+echo "one_long_password\nshutdown\n" | nc localhost 1234
+wait_or_quit $VLC4
+
+exit 0



More information about the vlc-commits mailing list