Skip to content

Commit

Permalink
add test implementation for xbmc.player.audiocodec addons
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Jan 20, 2012
1 parent 0e2994d commit 7682192
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Expand Up @@ -16,6 +16,7 @@ Rules
- Your solution must copy the final built dll to then 'addon' folder. You can use the 'Custom Build Step' in project properties, with a command line like that:
- `xcopy $(OutDir)$(TargetName)$(TargetExt) $(SolutionDir)..\addon\`
- don't forget to set 'Outputs' to `'$(SolutionDir)..\addon\$(TargetName)$(TargetExt)'`
- For automatic testing (which is optional) there must be a "test" directory. For more details see the Test section of this document.


Dependencies
Expand Down Expand Up @@ -53,4 +54,16 @@ xcopy "include\curl\*" %INC_DIR% /E /Q /I /Y

If you want to exclude something from being copied, just provide a 'exclude.txt' file in the 'dependencies' folder. (see http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true for the /exclude parameter)

Note: don't store *anything* in the dependencies folder, except the scripts folder. The 'lib', 'bin' and 'include' folders are automatically removed as soon as the build is completed.
Note: don't store *anything* in the dependencies folder, except the scripts folder. The 'lib', 'bin' and 'include' folders are automatically removed as soon as the build is completed.

Tests
=====
For automatic testing of the addon there must be a "test" directory in the root directory of the addon. Depending on the type of the addon (i.e. which extension point it provides) there are different tests applied.

- xbmc.player.audiocodec:
The "test" directory must contain at least a "test.reg" file which must contain two lines where the first line describes the parameters passed to the test application and the second line contains the path to the file to be checked and the MD5 checksum it should have. An example "test.reg" file could look like this:

<pre>
test.flac -ss 0030:0040 -o test.wav
test.wav abcdef12352123abcde
</pre>
Binary file added tests/xbmc.player.audiocodec/bin/libsndfile-1.dll
Binary file not shown.
Binary file added tests/xbmc.player.audiocodec/bin/md5.exe
Binary file not shown.
Binary file added tests/xbmc.player.audiocodec/bin/wavwriter.exe
Binary file not shown.
98 changes: 98 additions & 0 deletions tests/xbmc.player.audiocodec/test.bat
@@ -0,0 +1,98 @@
@echo OFF

set errorcode=0

rem get the addon path
set base_dir=%CD%
set addon_dir=%base_dir%\%1

set test_dir=%addon_dir%\test
set test_file=test.reg

set output_dir=%addon_dir%\addon
set output_xml=%output_dir%\addon.xml
set audio_dll=

rem store the paths
set exec_dir=%~dp0
set bin_dir=%exec_dir%bin
set wavwriter=%bin_dir%\wavwriter.exe
set md5=%bin_dir%\md5.exe

rem check if the path provided as a parameter actually exists
if not exist %test_dir% (
set errorcode=2
goto failed
)

rem check if the addon.xml exists
if not exist %output_xml% (
set errorcode=3
goto failed
)

rem Get the output_file from the path to the addon we got
set audio_dll="%output_dir%\%~nx1.dll"

rem enter the provided path
cd %test_dir%

rem check if the test.reg file exists
if not exist %test_file% (
set errorcode=4
goto failed
)

rem unset the %generated% variable
set generated=
for /F "tokens=* delims=" %%t in (%test_file%) do (
rem we didn't run the test application yet
if not defined generated (
rem run the test application and set the %generated% variable
%wavwriter% %audio_dll% %%t 2>NUL

rem check if the test application returned an error
if errorlevel 1 (
set errorcode=5
goto failed
)

set generated=1
) else (
rem time to check if the test worked
for /F "tokens=1,2" %%i in ("%%t") do (
rem the expected output file doesn't exist
if not exist %%i (
set errorcode=6
goto failed
)

rem get the MD5 checksum of the output file
for /F %%m in ('%md5% -n %%i') do (
rem we don't need the generated output file anymore
del %%i

rem compare the generated MD5 checksum with the reference checksum
if %%m == %%j goto success

set errorcode=1
goto failed
)
set generated=
)
)
)

:failed
echo 0
rem echo errorcode: %errorcode%
goto end

:success
echo 1
goto end

:end
rem go back to the base directory
cd %base_dir%
exit /B %errorcode%

0 comments on commit 7682192

Please sign in to comment.