1
0
mirror of https://github.com/luanti-org/minetestmapper.git synced 2025-10-06 13:55:22 +02:00

Add test for invalid block too

This commit is contained in:
sfan5
2025-10-05 13:50:19 +02:00
parent 02d81f25e0
commit e3dfc5ef82

View File

@@ -13,7 +13,7 @@ encodepos () {
echo "$(($1 + 0x1000 * $2 + 0x1000000 * $3))" echo "$(($1 + 0x1000 * $2 + 0x1000000 * $3))"
} }
# create map file with sql statements # create map file using SQL statements
writemap () { writemap () {
rm -rf $mapdir rm -rf $mapdir
mkdir $mapdir mkdir $mapdir
@@ -42,6 +42,17 @@ checkmap () {
echo "Passed." echo "Passed."
} }
# check that invocation returned an error
checkerr () {
local r=0
./minetestmapper --noemptyimage -v -i ./testmap -o map.png "$@" || r=1
if [ $r -eq 0 ]; then
echo "Did not return error!"
exit 1
fi
echo "Passed."
}
# this is missing the indices and primary keys but that doesn't matter # this is missing the indices and primary keys but that doesn't matter
schema_old="CREATE TABLE blocks(pos INT, data BLOB);" schema_old="CREATE TABLE blocks(pos INT, data BLOB);"
schema_new="CREATE TABLE blocks(x INT, y INT, z INT, data BLOB);" schema_new="CREATE TABLE blocks(x INT, y INT, z INT, data BLOB);"
@@ -114,3 +125,17 @@ mkdir $mapdir/players
printf '%s\n' "name = cat" "position = (80,0,80)" >$mapdir/players/cat printf '%s\n' "name = cat" "position = (80,0,80)" >$mapdir/players/cat
# we can't check that it actually worked, however # we can't check that it actually worked, however
checkmap 1 --drawplayers --zoom 4 checkmap 1 --drawplayers --zoom 4
msg "block error (wrong version)"
writemap "
$schema_new
INSERT INTO blocks VALUES (0, 0, 0, x'150000');
"
checkerr
msg "block error (invalid zstd)"
writemap "
$schema_new
INSERT INTO blocks VALUES (0, 0, 0, x'1d28b52ffd2001090000');
"
checkerr