diff --git a/ansi-screenshots/ansi_screenshot.sh b/ansi-screenshots/ansi_screenshot.sh new file mode 100755 index 0000000..018d7ac --- /dev/null +++ b/ansi-screenshots/ansi_screenshot.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +screenshot="$(tempfile --suffix=".png")" + +scrot "$screenshot" +"$(dirname "$0")/to_ansi.sh" "$screenshot" 131 \ No newline at end of file diff --git a/ansi-screenshots/to_ansi.sh b/ansi-screenshots/to_ansi.sh new file mode 100755 index 0000000..39e6401 --- /dev/null +++ b/ansi-screenshots/to_ansi.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +file="$1" +width="$2" + +mini_png="$(tempfile --suffix=".png")" +colors_gif="$(tempfile --suffix=".gif")" +indexed_gif="$(tempfile --suffix=".gif")" +indexed_pgm="$(tempfile --suffix=".pgm")" + +colors=(78,78,78 255,108,96 0,170,0 288,288,182 150,203,254 255,115,253 85,255,255 238,238,238 124,124,124 255,155,147 177,253,121 255,255,145 181,220,254 255,156,254 85,255,255 255,255,255) +args=() +for i in `seq 0 15`; do + if test $i -ge 8; then + color=$((i+8)) + else + color=$((i)) + fi + args+=(-fuzz 0% -fill "gray(${color})" -opaque "rgb(${colors[$i]})") +done + + convert "$file" -resize "${width}x" "${mini_png}" \ +&& convert +dither -remap "$(dirname "$0")/travis-palette.gif" "${mini_png}" "${colors_gif}" \ +&& convert "${colors_gif}" "${args[@]}" "${indexed_gif}" \ +&& convert "${indexed_gif}" "${indexed_pgm}" \ +&& tail -n +4 "${indexed_pgm}" \ + | hexdump -Cv \ + | sed -n -r -e 's/^[0-9a-f]* (([0-9a-f]{2} ){8}) (([0-9a-f]{2} ){7}[0-9a-f]{2}).*$/\1\3/p' \ + | tr '\n' ' ' \ + | fold -w $((width*3)) \ + | sed -r -e 's/([01])([0-7]) /[\1;3\2m██/g' \ + | sed -e 's/ //g' + +echo diff --git a/ansi-screenshots/travis-palette.gif b/ansi-screenshots/travis-palette.gif new file mode 100644 index 0000000..9360a17 Binary files /dev/null and b/ansi-screenshots/travis-palette.gif differ diff --git a/test/bochs.sh b/test/bochs.sh index 9d8213e..f116a7b 100755 --- a/test/bochs.sh +++ b/test/bochs.sh @@ -16,4 +16,7 @@ echo "continue" > "$bochscontinue" bochs -qf "$bochsrc" < "$bochscontinue" & pid=$! runsikulix -r test/check-gradient.sikuli + +ansi-screenshots/ansi_screenshot.sh + kill $pid diff --git a/test/qemu-system-i386.sh b/test/qemu-system-i386.sh index 1cbaa50..42ab7b3 100755 --- a/test/qemu-system-i386.sh +++ b/test/qemu-system-i386.sh @@ -6,4 +6,7 @@ os_file="example-os/os.sh" qemu-system-i386 -drive format=raw,file=${os_file},index=0,if=floppy & pid=$! runsikulix -r test/check-gradient.sikuli + +ansi-screenshots/ansi_screenshot.sh + kill $pid \ No newline at end of file diff --git a/test/virtualbox.sh b/test/virtualbox.sh index dc8b51e..3b881b0 100755 --- a/test/virtualbox.sh +++ b/test/virtualbox.sh @@ -17,6 +17,9 @@ VBoxManage modifyvm "$vmname" --boot1 floppy VBoxManage startvm "$vmname" --type sdl & pid=$! runsikulix -r test/check-gradient.sikuli + +ansi-screenshots/ansi_screenshot.sh + VBoxManage controlvm "$vmname" poweroff wait $pid # TODO: should ensure that the cleanup phase is always done even if the test fails.