From: Kartik Thakore Date: Tue, 10 Nov 2009 02:09:44 +0000 (-0500) Subject: Check for alsa fail on Audio tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=54652b7fe338933394092c3783ae7f8bd2d24e2e;p=sdlgit%2FSDL_perl.git Check for alsa fail on Audio tests --- diff --git a/Build.PL b/Build.PL index 5d6b092..2f8c29a 100644 --- a/Build.PL +++ b/Build.PL @@ -250,7 +250,7 @@ my $build = SDL::Build->new( build_requires => { 'Test::Simple' => '0.47', - 'Test::Trap' => '0', + 'File::Spec' => '0', 'Test::Most' => '0.21', }, build_recommends => diff --git a/t/core_mixchunk.t b/t/core_mixchunk.t index 9d36725..0e4285f 100644 --- a/t/core_mixchunk.t +++ b/t/core_mixchunk.t @@ -4,14 +4,26 @@ use warnings; use SDL; use SDL::Mixer::MixChunk; use Test::More; +use File::Spec; -if ( SDL::init(SDL_INIT_AUDIO) < 0 ) { - plan( skip_all => 'No sound card?' ); +sub test_audio +{ + my $devnull = File::Spec->devnull(); + `perl -e "use lib '../'; use SDL; SDL::init(SDL_INIT_AUDIO)" 2>$devnull`; + return ($? >> 8 ); +} -} else { - plan( tests => 6 ); +if ( test_audio != 1) +{ + plan ( skip_all => 'Failed to init sound' ); +} +else { + SDL::init(SDL_INIT_AUDIO); + plan( tests => 3 ); } + + is( SDL::MixOpenAudio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ), 0, 'MixOpenAudio passed' ); diff --git a/t/core_mixmusic.t b/t/core_mixmusic.t index 0583bc4..a4817bf 100644 --- a/t/core_mixmusic.t +++ b/t/core_mixmusic.t @@ -4,11 +4,21 @@ use warnings; use SDL; use SDL::Mixer::MixMusic; use Test::More; +use File::Spec; -if ( SDL::init(SDL_INIT_AUDIO) < 0 ) { - plan( skip_all => 'No sound card?' ); +sub test_audio +{ + my $devnull = File::Spec->devnull(); + `perl -e "use lib '../'; use SDL; SDL::init(SDL_INIT_AUDIO)" 2>$devnull`; + return ($? >> 8 ); +} -} else { +if ( test_audio != 1) +{ + plan ( skip_all => 'Failed to init sound' ); +} +else { + SDL::init(SDL_INIT_AUDIO); plan( tests => 3 ); }