diff --git a/minetest-worldtest-check-and-set.sh b/minetest-worldtest-check-and-set.sh index ab864d3..12a33b7 100755 --- a/minetest-worldtest-check-and-set.sh +++ b/minetest-worldtest-check-and-set.sh @@ -1,8 +1,13 @@ #!/bin/bash dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" if [ $# -ne 2 ]; then - echo "Usage: $0 " - exit 1 + if [ $# -ne 3 ]; then + echo "Usage: $0 []" + exit 1 + fi + resultfile_dst=$3 +else + resultfile_dst="" fi gamedir=$1 worlddir=$2 @@ -14,14 +19,21 @@ pushd "$gamedir" &>/dev/null # Configuration file is the common runtime configuration method echo -e "map-dir = $worlddir\nenable_mapgen_debug_info = true\n" > worldtest_config mkdir -p "$worlddir" -echo -e 'gameid = minimal' > "$worlddir/world.mt" +if ! [ -a "$worlddir/world.mt" ]; then + echo -e 'gameid = minimal' > "$worlddir/world.mt" +fi "$gamedir/bin/minetestserver" --config worldtest_config popd &>/dev/null resultfile=$gamedir/worldtest_result.txt +# Copy result to wanted location +if [ "$resultfile_dst" != "" ]; then + cp "$resultfile" "$resultfile_dst" +fi +# Return based on result if [ "`grep -c BAD: "$resultfile"`" != "0" ]; then #echo `grep ERRORS: "$resultfile"` - return 1 + exit 1 else - return 0 + exit 0 fi diff --git a/minetest-worldtest.sh b/minetest-worldtest.sh index ed63552..ee2d9b4 100755 --- a/minetest-worldtest.sh +++ b/minetest-worldtest.sh @@ -67,6 +67,18 @@ build_minetest () return 0 } +# Collect important results for viewing at the end +result_summary="" +result_note () +{ + echo $1 + if [ "$result_summary" == "" ]; then + result_summary="$1" + else + result_summary="$result_summary\\n$1" + fi +} + # Build all the versions, if not already built for ruledir in $rulesdir/*; do tag=`cat "$ruledir/tag"` @@ -90,7 +102,7 @@ for ruledir in $rulesdir/*; do echo "== Building $tag" build_minetest "$tag" "$ruledir" "$pkg" "$mtdir" if ! [ "$?" == "0" ]; then - echo "!! Failed to build $tag" + result_note "!! Failed to build $tag" fi fi done @@ -98,23 +110,51 @@ done # Make a world with each version for ruledir in $rulesdir/*; do tag=`cat "$ruledir/tag"` - echo "== Making world with version: $tag" + echo "== Testing version: $tag" mtdir=$builddir/minetest-$tag worlddir=$worldsdir/world-$tag - #echo "== Running minetest-worldtest-makeworld.sh for $tag" + resultfile=/tmp/minetest-worldtest-tmpresult.txt # Check compatibility with itself rm -rf "$worlddir" - $dir/minetest-worldtest-check-and-set.sh "$mtdir" "$worlddir" - if [ "$?" == "0" ]; then - echo "!! $tag returns valid for non-existent world" + $dir/minetest-worldtest-check-and-set.sh "$mtdir" "$worlddir" "$resultfile" + #if [ "$?" != "0" ]; then + if [ "`grep -c GOOD: "$resultfile"`" == "0" ]; then + result_note "== $tag returns all bad for non-existent world" + else + result_note "!! $tag returns some good for non-existent world" fi - $dir/minetest-worldtest-check-and-set.sh "$mtdir" "$worlddir" - if [ "$?" != "0" ]; then - echo "!! $tag returns invalid for self-generated world" + $dir/minetest-worldtest-check-and-set.sh "$mtdir" "$worlddir" "$resultfile" + #if [ "$?" == "0" ]; then + if [ "`grep -c BAD: "$resultfile"`" == "0" ]; then + result_note "== $tag returns all good for self-generated world" + else + result_note "!! $tag returns some bad for self-generated world" fi - # TODO: Check worlds generated by previous versions + # Check worlds generated by previous versions + for rule2dir in $rulesdir/*; do + tag2=`cat "$rule2dir/tag"` + mt2dir=$builddir/minetest-$tag2 + # If tag2 is our current one, stop checking for this and newer + if [ "$tag2" == "$tag" ]; then + break + fi + echo "== Creating world with version $tag2, loading it with $tag" + + rm -rf "$worlddir" + $dir/minetest-worldtest-check-and-set.sh "$mt2dir" "$worlddir" "$resultfile" + $dir/minetest-worldtest-check-and-set.sh "$mtdir" "$worlddir" "$resultfile" + if [ "`grep -c BAD: "$resultfile"`" == "0" ]; then + result_note "== $tag returns all good for world generated by $tag2" + else + result_note "!! $tag returns some bad for world generated by $tag2" + fi + done done +echo "" +echo "Result summary:" +echo -e $result_summary +# EOF diff --git a/rules.d/010-0.4.dev-20120606/worldtest_generate.patch b/rules.d/010-0.4.dev-20120606/worldtest_generate.patch index c174f49..698a9ae 100644 --- a/rules.d/010-0.4.dev-20120606/worldtest_generate.patch +++ b/rules.d/010-0.4.dev-20120606/worldtest_generate.patch @@ -1,5 +1,5 @@ diff --git a/src/server.cpp b/src/server.cpp -index 893d03b..a8fb1be 100644 +index 893d03b..06cdaad 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -212,6 +212,10 @@ void * EmergeThread::Thread() @@ -13,7 +13,7 @@ index 893d03b..a8fb1be 100644 { core::map::Iterator i; -@@ -1306,6 +1310,45 @@ void Server::AsyncRunStep() +@@ -1306,6 +1310,47 @@ void Server::AsyncRunStep() } } @@ -47,10 +47,12 @@ index 893d03b..a8fb1be 100644 + if(!message_triggered){ + dstream<set("worldtest_command", "loaded"); + } -+ if(m_nodedef->get(map->getNodeNoEx(v3s16(-1,-1,-1))).name == "default:nyancat") ++ if(g_settings->exists("worldtest_command") && ++ g_settings->get("worldtest_command") == "done") + m_shutdown_requested = true; + } + } @@ -59,7 +61,7 @@ index 893d03b..a8fb1be 100644 { JMutexAutoLock lock(m_env_mutex); // Step environment -@@ -1318,6 +1361,7 @@ void Server::AsyncRunStep() +@@ -1318,6 +1363,7 @@ void Server::AsyncRunStep() if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime)) { JMutexAutoLock lock(m_env_mutex); @@ -67,7 +69,7 @@ index 893d03b..a8fb1be 100644 // Run Map's timers and unload unused data ScopeProfiler sp(g_profiler, "Server: map timer and unload"); m_env->getMap().timerUpdate(map_timer_and_unload_dtime, -@@ -4853,6 +4897,20 @@ void dedicated_server_loop(Server &server, bool &kill) +@@ -4853,6 +4899,20 @@ void dedicated_server_loop(Server &server, bool &kill) { DSTACK(__FUNCTION_NAME); diff --git a/rules.d/010-0.4.dev-20120606/worldtest_lua.patch b/rules.d/010-0.4.dev-20120606/worldtest_lua.patch index a48df42..b8e2162 100644 --- a/rules.d/010-0.4.dev-20120606/worldtest_lua.patch +++ b/rules.d/010-0.4.dev-20120606/worldtest_lua.patch @@ -1,15 +1,17 @@ diff --git a/builtin/builtin.lua b/builtin/builtin.lua -index bd5adf9..aca18c2 100644 +index bd5adf9..766ea06 100644 --- a/builtin/builtin.lua +++ b/builtin/builtin.lua -@@ -22,3 +22,126 @@ dofile(minetest.get_modpath("__builtin").."/auth.lua") +@@ -22,3 +22,115 @@ dofile(minetest.get_modpath("__builtin").."/auth.lua") dofile(minetest.get_modpath("__builtin").."/chatcommands.lua") dofile(minetest.get_modpath("__builtin").."/static_spawn.lua") +-- Worldtest implementation + -+-- Requires a modified server that will load or generate all the MapBlocks -+-- surrounding the origin and quits when nyancat is set at (-1,-1,-1). ++-- Requires a modified server that will: ++-- - Load or generate all the MapBlocks surrounding the origin ++-- - When loaded, sets setting worldtest_command = "laoded" ++-- - Quits when setting worldtest_command == "done" + +local worldtest = {} +worldtest.done = false @@ -100,32 +102,19 @@ index bd5adf9..aca18c2 100644 + return + end + -+ -- Wait until world is loaded (by patched server code) -+ if -+ not minetest.env:get_node_or_nil({x=8, y=8, z=8}) or -+ not minetest.env:get_node_or_nil({x=8, y=8, z=-8}) or -+ not minetest.env:get_node_or_nil({x=8, y=-8, z=8}) or -+ not minetest.env:get_node_or_nil({x=8, y=-8, z=-8}) or -+ not minetest.env:get_node_or_nil({x=-8, y=8, z=8}) or -+ not minetest.env:get_node_or_nil({x=-8, y=8, z=-8}) or -+ not minetest.env:get_node_or_nil({x=-8, y=-8, z=8}) or -+ not minetest.env:get_node_or_nil({x=-8, y=-8, z=-8}) -+ then -+ return -+ end -+ -+ -- Hackily wait more to actually have all blocks generated -+ worldtest.timer = worldtest.timer + dtime -+ if worldtest.timer < 4.0 then ++ -- Wait until patched server has loaded world ++ if minetest.setting_get("worldtest_command") ~= "loaded" then + return + end + -+ minetest.log("action", "Worldtest(Lua): world loaded or generated (hopefully)") ++ minetest.log("action", "Worldtest(Lua): world loaded or generated") + + worldtest.check_and_set() + + minetest.log("action", "Worldtest(Lua): done") + ++ -- Command patched server to quit ++ minetest.setting_set("worldtest_command", "done") + worldtest.done = true +end) + diff --git a/rules.d/020-0.4.1/worldtest_generate.patch b/rules.d/020-0.4.1/worldtest_generate.patch index c174f49..698a9ae 100644 --- a/rules.d/020-0.4.1/worldtest_generate.patch +++ b/rules.d/020-0.4.1/worldtest_generate.patch @@ -1,5 +1,5 @@ diff --git a/src/server.cpp b/src/server.cpp -index 893d03b..a8fb1be 100644 +index 893d03b..06cdaad 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -212,6 +212,10 @@ void * EmergeThread::Thread() @@ -13,7 +13,7 @@ index 893d03b..a8fb1be 100644 { core::map::Iterator i; -@@ -1306,6 +1310,45 @@ void Server::AsyncRunStep() +@@ -1306,6 +1310,47 @@ void Server::AsyncRunStep() } } @@ -47,10 +47,12 @@ index 893d03b..a8fb1be 100644 + if(!message_triggered){ + dstream<set("worldtest_command", "loaded"); + } -+ if(m_nodedef->get(map->getNodeNoEx(v3s16(-1,-1,-1))).name == "default:nyancat") ++ if(g_settings->exists("worldtest_command") && ++ g_settings->get("worldtest_command") == "done") + m_shutdown_requested = true; + } + } @@ -59,7 +61,7 @@ index 893d03b..a8fb1be 100644 { JMutexAutoLock lock(m_env_mutex); // Step environment -@@ -1318,6 +1361,7 @@ void Server::AsyncRunStep() +@@ -1318,6 +1363,7 @@ void Server::AsyncRunStep() if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime)) { JMutexAutoLock lock(m_env_mutex); @@ -67,7 +69,7 @@ index 893d03b..a8fb1be 100644 // Run Map's timers and unload unused data ScopeProfiler sp(g_profiler, "Server: map timer and unload"); m_env->getMap().timerUpdate(map_timer_and_unload_dtime, -@@ -4853,6 +4897,20 @@ void dedicated_server_loop(Server &server, bool &kill) +@@ -4853,6 +4899,20 @@ void dedicated_server_loop(Server &server, bool &kill) { DSTACK(__FUNCTION_NAME); diff --git a/rules.d/020-0.4.1/worldtest_lua.patch b/rules.d/020-0.4.1/worldtest_lua.patch index a48df42..b8e2162 100644 --- a/rules.d/020-0.4.1/worldtest_lua.patch +++ b/rules.d/020-0.4.1/worldtest_lua.patch @@ -1,15 +1,17 @@ diff --git a/builtin/builtin.lua b/builtin/builtin.lua -index bd5adf9..aca18c2 100644 +index bd5adf9..766ea06 100644 --- a/builtin/builtin.lua +++ b/builtin/builtin.lua -@@ -22,3 +22,126 @@ dofile(minetest.get_modpath("__builtin").."/auth.lua") +@@ -22,3 +22,115 @@ dofile(minetest.get_modpath("__builtin").."/auth.lua") dofile(minetest.get_modpath("__builtin").."/chatcommands.lua") dofile(minetest.get_modpath("__builtin").."/static_spawn.lua") +-- Worldtest implementation + -+-- Requires a modified server that will load or generate all the MapBlocks -+-- surrounding the origin and quits when nyancat is set at (-1,-1,-1). ++-- Requires a modified server that will: ++-- - Load or generate all the MapBlocks surrounding the origin ++-- - When loaded, sets setting worldtest_command = "laoded" ++-- - Quits when setting worldtest_command == "done" + +local worldtest = {} +worldtest.done = false @@ -100,32 +102,19 @@ index bd5adf9..aca18c2 100644 + return + end + -+ -- Wait until world is loaded (by patched server code) -+ if -+ not minetest.env:get_node_or_nil({x=8, y=8, z=8}) or -+ not minetest.env:get_node_or_nil({x=8, y=8, z=-8}) or -+ not minetest.env:get_node_or_nil({x=8, y=-8, z=8}) or -+ not minetest.env:get_node_or_nil({x=8, y=-8, z=-8}) or -+ not minetest.env:get_node_or_nil({x=-8, y=8, z=8}) or -+ not minetest.env:get_node_or_nil({x=-8, y=8, z=-8}) or -+ not minetest.env:get_node_or_nil({x=-8, y=-8, z=8}) or -+ not minetest.env:get_node_or_nil({x=-8, y=-8, z=-8}) -+ then -+ return -+ end -+ -+ -- Hackily wait more to actually have all blocks generated -+ worldtest.timer = worldtest.timer + dtime -+ if worldtest.timer < 4.0 then ++ -- Wait until patched server has loaded world ++ if minetest.setting_get("worldtest_command") ~= "loaded" then + return + end + -+ minetest.log("action", "Worldtest(Lua): world loaded or generated (hopefully)") ++ minetest.log("action", "Worldtest(Lua): world loaded or generated") + + worldtest.check_and_set() + + minetest.log("action", "Worldtest(Lua): done") + ++ -- Command patched server to quit ++ minetest.setting_set("worldtest_command", "done") + worldtest.done = true +end) +