From 2bb7eb2dec219d05edb53002e10811fa214325b8 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Fri, 10 Nov 2017 13:47:01 -0500 Subject: Add tests. * Add simple INSTALL document. * Add Makefile.PL for make support. * Moved sample files to t/fixtures. * Add version to xmpt executable.xmpt * Add tests for sample CLI run. --- .gitignore | 7 ++++++- INSTALL | 4 ++++ Makefile.PL | 5 +++++ input | 29 ----------------------------- localhost.conf | 3 --- t/fixtures/input | 29 +++++++++++++++++++++++++++++ t/fixtures/localhost.conf | 3 +++ t/fixtures/testplan | 6 ++++++ t/samplerun.t | 39 +++++++++++++++++++++++++++++++++++++++ testplan | 6 ------ xmpt | 2 ++ 11 files changed, 94 insertions(+), 39 deletions(-) create mode 100644 INSTALL create mode 100644 Makefile.PL delete mode 100644 input delete mode 100644 localhost.conf create mode 100644 t/fixtures/input create mode 100644 t/fixtures/localhost.conf create mode 100644 t/fixtures/testplan create mode 100644 t/samplerun.t delete mode 100644 testplan diff --git a/.gitignore b/.gitignore index 0595a33..7006112 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ -reuasmb.conf \ No newline at end of file +Makefile +MYMETA.json +MYMETA.yml +blib +pm_to_blib +reuasmb.conf diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..afe6a74 --- /dev/null +++ b/INSTALL @@ -0,0 +1,4 @@ +% perl Makefile.PL +% make +% make test +% make install diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..7e0076c --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,5 @@ +use ExtUtils::MakeMaker; + +WriteMakefile(NAME => 'xmpt', + VERSION_FROM => 'xmpt', + EXE_FILES => ['xmpt']); diff --git a/input b/input deleted file mode 100644 index 2d508fe..0000000 --- a/input +++ /dev/null @@ -1,29 +0,0 @@ - - - - SCRAM-SHA-1 - PLAIN - - - - - - - - - - - - test0@localhost/xmpt - - - - diff --git a/localhost.conf b/localhost.conf deleted file mode 100644 index bc462d7..0000000 --- a/localhost.conf +++ /dev/null @@ -1,3 +0,0 @@ -# Domain and bare JID are calculated from full. -full_jid=test0@localhost/xmpt -password=test diff --git a/t/fixtures/input b/t/fixtures/input new file mode 100644 index 0000000..2d508fe --- /dev/null +++ b/t/fixtures/input @@ -0,0 +1,29 @@ + + + + SCRAM-SHA-1 + PLAIN + + + + + + + + + + + + test0@localhost/xmpt + + + + diff --git a/t/fixtures/localhost.conf b/t/fixtures/localhost.conf new file mode 100644 index 0000000..bc462d7 --- /dev/null +++ b/t/fixtures/localhost.conf @@ -0,0 +1,3 @@ +# Domain and bare JID are calculated from full. +full_jid=test0@localhost/xmpt +password=test diff --git a/t/fixtures/testplan b/t/fixtures/testplan new file mode 100644 index 0000000..ba7fcaa --- /dev/null +++ b/t/fixtures/testplan @@ -0,0 +1,6 @@ +signin +auth +bind-reneg +bind +session +signout diff --git a/t/samplerun.t b/t/samplerun.t new file mode 100644 index 0000000..c3930ed --- /dev/null +++ b/t/samplerun.t @@ -0,0 +1,39 @@ +# -*- mode: perl -*- + +use Test::More tests => 3; + +use strict; +use warnings; + +my $config = 't/fixtures/localhost.conf'; +my $testplan = 't/fixtures/testplan'; +my $input = 't/fixtures/input'; + +subtest 'standard input', sub { + my $cmd = "./xmpt -c $config -p $testplan"; + my $xmptfh = new IO::File("|$cmd") or BAIL_OUT "Can't run '$cmd': $!.\n"; + my $inputfh = new IO::File($input) or + BAIL_OUT "Couldn't open $input for reading: $!.\n"; + while (<$inputfh>) { + print $xmptfh $_; + } + $inputfh->close; + $xmptfh->close; + ok($? == 0, 'Standard input redirect'); +}; + +subtest 'timeout', sub { + my $cmd = "./xmpt -t 1 -c $config -p $testplan cat 2>/dev/null"; + local $SIG{ALRM} = sub { fail("Timed out running $cmd.") }; + alarm 5; + system $cmd; + ok(($? >> 8) != 0, 'Timeout test'); +}; + +subtest 'I/O redirected to cat', sub { + my $cmd = "./xmpt -c $config -p $testplan cat $input 2>/dev/null"; + local $SIG{ALRM} = sub { fail("Timed out running $cmd.") }; + alarm 10; + ok((system($cmd) >> 8) == 0, 'I/O redirected to cat'); + alarm 0; +}; diff --git a/testplan b/testplan deleted file mode 100644 index ba7fcaa..0000000 --- a/testplan +++ /dev/null @@ -1,6 +0,0 @@ -signin -auth -bind-reneg -bind -session -signout diff --git a/xmpt b/xmpt index 9ab7f7d..5e79d7d 100755 --- a/xmpt +++ b/xmpt @@ -9,6 +9,8 @@ use v5.10; use strict; use warnings; +our $VERSION = '0'; + my $configpath = 'localhost.conf'; my $testplanpath = 'testplan'; my $templatepath = 'xml'; -- cgit v1.2.3