OSDN Git Service

more fix for test.sh
[android-x86/external-s2tc.git] / tests / test.sh
index cbe15ab..fe33174 100644 (file)
@@ -2,10 +2,17 @@
 
 set -e
 
-CXX="g++ -Wall -Wextra -O3"
-make clean all
-
-mkdir -p html
+cd ..
+make clean || true
+sh autogen.sh
+./configure --prefix="`pwd`/tests" CXXFLAGS="-O3"
+make
+make install
+cd tests
+
+rm -rf html
+rm *.dds
+mkdir html
 exec 3>html/index.html
 
 html_start()
@@ -78,9 +85,22 @@ html_rowstart()
        deltatime_raw=0
        col=0
 }
+
+decompress()
+{
+       case "$1" in
+               *.dds)
+                       convert "$1" TGA:-
+                       ;;
+               *)
+                       cat "$1"
+                       ;;
+       esac
+}
+
 html()
 {
-       convert "$1" -crop 256x256+192+128 "html/$1.png"
+       decompress "$1" | convert TGA:- -crop 256x256+192+128 "html/$1.png"
        echo >&3 "<td><img src=\"$1.png\" alt=\"$1\" title=\"$1$deltatime\"></td>"
        eval "prevdeltatime=\$deltatime_$col"
        prevdeltatime=`echo "($prevdeltatime-0)+$deltatime_raw" | bc`
@@ -89,7 +109,7 @@ html()
 }
 html2()
 {
-       ./s2tc_decompress < "$1" | convert TGA:- -crop 256x256+192+128 "html/$1-s2tc.png"
+       bin/s2tc_decompress < "$1" | convert TGA:- -crop 256x256+192+128 "html/$1-s2tc.png"
        echo >&3 "<td><img src=\"$1-s2tc.png\" alt=\"$1\" title=\"$1$deltatime\"></td>"
        eval "prevdeltatime=\$deltatime_$col"
        prevdeltatime=`echo "($prevdeltatime-0)+$deltatime_raw" | bc`
@@ -149,30 +169,82 @@ else
 fi
 
 html_start
-for i in dxtfail fract001 base_concrete1a disabled floor_tile3a lift02 panel_ceil1a sunset amelia rms noise noise_solid supernova ishihara augenkrebs; do
+
+# TODO download test pictures that are not under the same license as this package
+xon()
+{
+       # downloads a texture from Xonotic
+       if ! [ -f "$2" ]; then
+               wget -O- "http://git.xonotic.org/?p=xonotic/xonotic-maps.pk3dir.git;a=blob_plain;f=$1" | convert "${1##*.}":- -geometry 512x512 "$2"
+       fi
+}
+# floor_tread01: GPLv2+
+xon textures/exx/floor/floor_tread01.tga floor_tread01.tga
+# floor_tread01_norm: GPLv2+
+xon textures/exx/floor/floor_tread01_norm.tga floor_tread01_norm_dxt3.tga
+xon textures/exx/floor/floor_tread01_norm.tga floor_tread01_norm_dxt5.tga
+# base_concrete1a: GPLv2+
+xon textures/trak4x/base/base_concrete1a.tga base_concrete1a.tga
+# disabled: GPLv2+
+xon textures/screens/screen_toggle0.tga disabled.tga
+# floor_tile3a: GPLv2+
+xon textures/trak4x/floor/floor_tile3a.tga floor_tile3a.tga
+# lift02: GPLv2+
+xon textures/facility114x/misc/lift02.tga lift02.tga
+# sunset: GPLv2+
+xon env/distant_sunset/distant_sunset_rt.jpg sunset.tga
+# amelia: no license
+if ! [ -f "amelia.tga" ]; then
+       wget -O- "http://www.godoon.com/gallery/media/slayers/amelia-wil-tesla-saillune/49212997-d81e-11df-8228-a8bfc396a36f.jpg" | convert JPG:- amelia.tga
+fi
+
+for i in dxtfail floor_tread01 floor_tread01_norm_dxt5 floor_tread01_norm_dxt3 fract001 base_concrete1a disabled floor_tile3a lift02 sunset amelia noise noise_solid supernova; do
        html_rowstart "$i"
 
        html "$i".tga
 
+       case "$i" in
+               *_norm*)
+                       goodmetric=NORMALMAP
+                       ;;
+               *)
+                       goodmetric=SRGB_MIXED
+                       ;;
+       esac
+       case "$i" in
+               *_dxt5)
+                       fourcc=DXT5
+                       nvopts="-bc3 -alpha"
+                       ;;
+               *_dxt3)
+                       fourcc=DXT3
+                       nvopts="-bc2 -alpha"
+                       ;;
+               *)
+                       fourcc=DXT1
+                       nvopts="-bc1"
+                       ;;
+       esac
+
        if $use_compressonator; then
-               timing wine "c:/Program Files (x86)/AMD/The Compressonator 1.50/TheCompressonator.exe" -convert -overwrite -mipmaps "$i".tga "$i"-amdcompress.dds -codec DXTC.dll +fourCC DXT1 -mipper BoxFilter.dll
+               timing wine "c:/Program Files (x86)/AMD/The Compressonator 1.50/TheCompressonator.exe" -convert -overwrite -mipmaps "$i".tga "$i"-amdcompress.dds -codec DXTC.dll +fourCC $fourcc -mipper BoxFilter.dll
                html "$i"-amdcompress.dds
        fi
 
        if $use_nvcompress; then
-               timing nvcompress "$i".tga "$i"-nvcompress.dds
+               timing nvcompress $nvopts "$i".tga "$i"-nvcompress.dds
                html "$i"-nvcompress.dds
        fi
 
-       S2TC_COLORDIST_MODE=SRGB_MIXED S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-mrgb-r.dds ./s2tc
-       S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-wavg-r.dds ./s2tc
-       S2TC_COLORDIST_MODE=AVG        S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-avg-r.dds  ./s2tc
+       S2TC_COLORDIST_MODE=$goodmetric S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-mrgb-r.dds bin/s2tc -t $fourcc
+       S2TC_COLORDIST_MODE=WAVG        S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-wavg-r.dds bin/s2tc -t $fourcc
+       S2TC_COLORDIST_MODE=AVG         S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-avg-r.dds  bin/s2tc -t $fourcc
        if $use_libtxc_dxtn; then
-               LD_PRELOAD=/usr/lib/libtxc_dxtn.so                                     t "$i".tga "$i"-libtxc_dxtn.dds ./s2tc
+               LD_PRELOAD=/usr/lib/libtxc_dxtn.so                                      t "$i".tga "$i"-libtxc_dxtn.dds   bin/s2tc -t $fourcc
                unset LD_PRELOAD
        fi
-       S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=0  S2TC_REFINE_COLORS=ALWAYS t "$i".tga "$i"-norand-wavg-r.dds ./s2tc
-       S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=-1 S2TC_REFINE_COLORS=ALWAYS t "$i".tga "$i"-faster-wavg-r.dds ./s2tc
+       S2TC_COLORDIST_MODE=WAVG        S2TC_RANDOM_COLORS=0  S2TC_REFINE_COLORS=ALWAYS t "$i".tga "$i"-norand-wavg-r.dds bin/s2tc -t $fourcc
+       S2TC_COLORDIST_MODE=WAVG        S2TC_RANDOM_COLORS=-1 S2TC_REFINE_COLORS=ALWAYS t "$i".tga "$i"-faster-wavg-r.dds bin/s2tc -t $fourcc
 
        html_rowend
 done