Update test script and test workflow
This commit is contained in:
parent
5ed74afa0c
commit
33f496efbe
3 changed files with 113 additions and 13 deletions
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
|
@ -15,10 +15,15 @@ jobs:
|
|||
- uses: actions/checkout@v3
|
||||
- name: Install dependencies
|
||||
run: sudo apt update -y && sudo apt install meson build-essential libmagick++-dev -y
|
||||
- name: Download executable
|
||||
uses: actions/download-artifact@v2.1.1
|
||||
with:
|
||||
name: linux
|
||||
path: b16convert
|
||||
- name: Set up build directory
|
||||
run: meson setup builddir
|
||||
- name: Run test script
|
||||
run: ./test.sh
|
||||
run: ./test.sh -p b16convert
|
||||
- name: Upload test artifacts
|
||||
uses: actions/upload-artifact@v3.1.3
|
||||
with:
|
||||
|
|
3
main.cpp
3
main.cpp
|
@ -20,7 +20,7 @@ void usage() {
|
|||
printf("-out <output>\n");
|
||||
printf("\tSets the output file");
|
||||
printf("-bpp <bpp>\n");
|
||||
printf("\tSets the desired bits per pixel. May be 0 (default), 2, 4, or 8. 0: automatic.\n");
|
||||
printf("\tSets the desired bits per pixel. May be 0 (default), 1, 2, 4, or 8. 0: automatic.\n");
|
||||
printf("-significant <color count>\n");
|
||||
printf("\tSets the desired number of significant palette entries. Must be at least 0 and at most 256. 0 means automatic. Default: 0\n");
|
||||
printf("-resize <width> <height>\n");
|
||||
|
@ -80,6 +80,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
switch (tbpp) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
|
|
116
test.sh
116
test.sh
|
@ -1,22 +1,116 @@
|
|||
#!/bin/bash
|
||||
usage() {
|
||||
cat << EOF
|
||||
$0 usage:
|
||||
-p|--use-program <program path>
|
||||
Uses the specified already-compiled binary rather than compiling manually
|
||||
-i|--input-image <image path>
|
||||
Adds an image input at the specified path to the image list.
|
||||
-b|--output-bpp <bpp>
|
||||
Adds a bitdepth to the list to test with
|
||||
-r|--resize <width> <height>
|
||||
Adds a resize to the list to test with
|
||||
--no-reverse
|
||||
Disables reverse operation testing
|
||||
--no-dither
|
||||
Disables dithering testing
|
||||
-n|--no-defaults
|
||||
Disables default settings
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
oldpwd="$(pwd)"
|
||||
cd "$(dirname "$0")"
|
||||
meson setup builddir
|
||||
meson compile -C builddir || exit $?
|
||||
images=("TEST.png" "PACK.png")
|
||||
converter="./builddir/b16converter"
|
||||
prebuilt=0
|
||||
images=()
|
||||
bpp=()
|
||||
resize=()
|
||||
enable_defaults=1
|
||||
dither=1
|
||||
reverse=1
|
||||
enable_reverse=1
|
||||
enable_dither=1
|
||||
outdir="testout"
|
||||
mkdir "$outdir"
|
||||
OPTIONS=$(getopt -o "hp:i:r::no:" --long "help,use-program:,input-image:,output-bpp:,resize::,no-defaults,output-dir:,no-reverse,no-dither" -- "$@")
|
||||
if [ $? != 0 ]; then
|
||||
usage
|
||||
fi
|
||||
eval set -- "$OPTIONS"
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
-o|--output-dir)
|
||||
outdir="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
;;
|
||||
-p|--use-program)
|
||||
converter="$2"
|
||||
prebuilt=1
|
||||
shift 2
|
||||
;;
|
||||
-i|--input-image)
|
||||
images+="$2"
|
||||
shift 2
|
||||
;;
|
||||
-b|--output-bpp)
|
||||
bpp+="$2"
|
||||
shift 2
|
||||
;;
|
||||
-r|--resize)
|
||||
resize+="$2x$3"
|
||||
shift 2
|
||||
;;
|
||||
-n|--no-defaults)
|
||||
enable_defaults=0
|
||||
shift
|
||||
;;
|
||||
--no-reverse)
|
||||
enable_reverse=0
|
||||
shift
|
||||
;;
|
||||
--no-dither)
|
||||
enable_dither=0
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ $enable_defaults -ne 0 ]; then
|
||||
images+=("TEST.png" "PACK.png")
|
||||
bpp+=(1 2 4 8)
|
||||
resize+=("8x8" "16x16" "32x32" "64x64" "320x240" "640x480")
|
||||
fi
|
||||
if [ $prebuilt -eq 0 ]; then
|
||||
meson setup builddir
|
||||
meson compile -C builddir || exit $?
|
||||
fi
|
||||
mkdir -p "$outdir"
|
||||
for img in "${images[@]}"; do
|
||||
for bpp in 2 4 8; do
|
||||
for size in "8x8" "16x16" "32x32" "64x64" "320x240" "640x480"; do
|
||||
for bpp in "${bpp[@]}"; do
|
||||
for size in "${resize[@]}"; do
|
||||
width="$(echo -n "$size" | cut -dx -f1)"
|
||||
height="$(echo -n "$size" | cut -dx -f2)"
|
||||
name="$(echo -n "$img" | sed 's/\.png$//')"
|
||||
name="$(basename "$img" | sed 's/\.png$//')"
|
||||
name="$(printf "%s.%sP.%sB" "$name" "$width" "$bpp")"
|
||||
./builddir/graphicsconverter -in "$img" -out "$outdir/$name.B16" -bpp "$bpp" -resize "$width" "$height" -border 15 0 15
|
||||
./builddir/graphicsconverter -in "$img" -out "$outdir/$name.D.B16" -bpp "$bpp" -resize "$width" "$height" -dither -border 15 0 15
|
||||
./builddir/graphicsconverter -reverse -in "$outdir/$name.B16" -out "$outdir/$name.PNG" -resize "$width" "$height"
|
||||
./builddir/graphicsconverter -reverse -in "$outdir/$name.D.B16" -out "$outdir/$name.D.PNG" -resize "$width" "$height" -dither
|
||||
./builddir/b16converter -in "$img" -out "$outdir/$name.B16" -bpp "$bpp" -resize "$width" "$height" -border 15 0 15
|
||||
if [ $enable_dither -ne 0 ]; then
|
||||
./builddir/b16converter -in "$img" -out "$outdir/$name.D.B16" -bpp "$bpp" -resize "$width" "$height" -dither -border 15 0 15
|
||||
fi
|
||||
if [ $enable_reverse -ne 0 ]; then
|
||||
./builddir/b16converter -reverse -in "$outdir/$name.B16" -out "$outdir/$name.PNG" -resize "$width" "$height"
|
||||
if [ $enable_dither -ne 0 ]; then
|
||||
./builddir/b16converter -reverse -in "$outdir/$name.D.B16" -out "$outdir/$name.D.PNG" -resize "$width" "$height" -dither
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue