2 # Copyright (C) 2010 Toni Gundogdu <legatvs@gmail.com>
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 use POSIX
":sys_wait_h";
26 use File
::Basename
qw(basename);
29 use vars
qw(@ISA @EXPORT @EXPORT_OK);
31 our @ISA = qw(Exporter);
33 our @EXPORT_OK = qw(run run_t pod_checks check_codeset);
35 my $QUVI_PATH = "@top_builddir@/src/quvi";
36 $ENV{QUVI_BASEDIR
} = "@top_srcdir@/share";
38 # Exit test if NO_INTERNET is set.
40 if ( $ENV{NO_INTERNET
} ) {
42 "SKIP: No internet. Unset NO_INTERNET to enable.\n";
47 # Remove these from the args: we use them for
48 # default "flv" runs only.
53 qw(--page-title --video-id --file-length --file-suffix);
58 foreach my $arg (@args) {
65 push @tmp, $arg if !$skip;
72 # Wraps "-t -f $fmt", parses quvi --support output, and
73 # tests all host supported formats.
77 my @args = ( "--no-shortened", "-t", @_ );
78 my @formats = parse_formats
( $_[0] );
82 $rc = run
( ( "-f", $_, @args ) );
84 @args = remove_checks
(@args);
90 # Runs quvi with the given options. Checks and
91 # parses the supported environment variables.
93 my @args = ( $QUVI_PATH, @_ );
94 my $extra = $ENV{QUVI_TEST_OPTIONS
};
96 @args = ( @args, split( /\s+/, $extra ) )
106 printf "\nTEST: %s\nEXEC: ", basename
($0);
107 print qq/"$_"/ . " " foreach @args;
114 elsif ( $child == 0 ) {
115 exit( system(@args) >> 8 );
122 my $result = waitpid( $child, 0 );
124 if ( $result == -1 ) {
125 die "no more processes to wait: pid $child not found";
127 elsif ( $result == 0 ) {
129 # $child is still running.
132 elsif ( $result != $child ) {
133 die "got invalid pid $result (expected $child)";
139 if ( WIFEXITED
($status) ) {
140 $rc = WEXITSTATUS
($status);
141 print STDERR
"-> child: normal termination ($rc)\n";
144 elsif ( WIFSIGNALED
($status) ) {
145 $rc = WTERMSIG
($status);
146 print STDERR
"-> child: abnormal termination ($rc)\n";
149 elsif ( WIFSTOPPED
($status) ) {
150 $rc = WSTOPSIG
($status);
151 print STDERR
"-> child: stopped ($rc)\n";
159 # Parses quvi --support output. First argument is
160 # expected to be the host id, e.g. "youtube".
162 my $output = `$QUVI_PATH --support`;
165 if ( $output =~ /$host\.(?:\w+\s+|\s+)(.*)/i ) {
166 @r = split( /\|/, $1 );
171 # Check the pod markup.
173 require Pod
::Checker
;
174 my $rc = Pod
::Checker
::podchecker
("@top_srcdir@/man1/quvi.1.pod");
178 # Returns current locale codeset. Terminates if codeset
179 # is not matched to UTF-8/16/32.
183 require I18N
::Langinfo
;
184 I18N
::Langinfo
->import(qw(langinfo CODESET));
185 $cs = langinfo
( CODESET
() );
188 if ($@
) { $skip = 1; }
190 if ( $cs !~ /^utf/i ) { $skip = 1; }
194 "SKIP: No utf-8 (or utf-16, utf-32) locale codeset.\n";