diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/buildbot/buildwin32.sh | 46 | ||||
-rwxr-xr-x | util/buildbot/buildwin64.sh | 33 | ||||
-rwxr-xr-x | util/bump_version.sh | 2 | ||||
-rwxr-xr-x | util/ci/build.sh | 14 | ||||
-rwxr-xr-x | util/ci/build_prometheus_cpp.sh | 2 | ||||
-rwxr-xr-x | util/ci/clang-tidy.sh | 12 | ||||
-rw-r--r-- | util/ci/common.sh | 9 | ||||
-rwxr-xr-x | util/generate-texture-normals.sh | 255 | ||||
-rw-r--r-- | util/helper_mod/init.lua | 51 | ||||
-rw-r--r-- | util/helper_mod/mod.conf | 3 | ||||
-rwxr-xr-x | util/stress_mapgen.sh | 30 | ||||
-rwxr-xr-x | util/test_multiplayer.sh | 45 |
12 files changed, 156 insertions, 346 deletions
diff --git a/util/buildbot/buildwin32.sh b/util/buildbot/buildwin32.sh index 9eb9a4050..3df48f178 100755 --- a/util/buildbot/buildwin32.sh +++ b/util/buildbot/buildwin32.sh @@ -8,7 +8,7 @@ GAME_GIT=https://github.com/minetest/minetest_game GAME_BRANCH=master GAME_NAME=minetest_game -dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" if [ $# -ne 1 ]; then echo "Usage: $0 <build directory>" exit 1 @@ -28,7 +28,7 @@ if [ -z "$compiler" ]; then echo "Unable to determine which MinGW compiler to use" exit 1 fi -toolchain_file=$dir/toolchain_${compiler/-gcc/}.cmake +toolchain_file=$topdir/toolchain_${compiler/-gcc/}.cmake echo "Using $toolchain_file" # Try to find runtime DLLs in various paths (varies by distribution, sigh) @@ -45,17 +45,18 @@ done echo "The compiler runtime DLLs could not be found, they might be missing in the final package." # Get stuff -irrlicht_version=1.9.0mt4 -ogg_version=1.3.4 +irrlicht_version=$(cat $topdir/../../misc/irrlichtmt_tag.txt) +ogg_version=1.3.5 +openal_version=1.21.1 vorbis_version=1.3.7 -curl_version=7.76.1 +curl_version=7.81.0 gettext_version=0.20.1 -freetype_version=2.10.4 -sqlite3_version=3.35.5 +freetype_version=2.11.1 +sqlite3_version=3.37.2 luajit_version=2.1.0-beta3 leveldb_version=1.23 zlib_version=1.2.11 -zstd_version=1.4.9 +zstd_version=1.5.2 mkdir -p $libdir @@ -78,19 +79,22 @@ download () { fi } +# 'dw2' just points to rebuilt versions after a toolchain change +# this distinction should be gotten rid of next time + cd $libdir download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win32.zip" irrlicht-$irrlicht_version.zip -download "http://minetest.kitsunemimi.pw/zlib-$zlib_version-win32.zip" +download "http://minetest.kitsunemimi.pw/dw2/zlib-$zlib_version-win32.zip" download "http://minetest.kitsunemimi.pw/zstd-$zstd_version-win32.zip" download "http://minetest.kitsunemimi.pw/libogg-$ogg_version-win32.zip" -download "http://minetest.kitsunemimi.pw/libvorbis-$vorbis_version-win32.zip" +download "http://minetest.kitsunemimi.pw/dw2/libvorbis-$vorbis_version-win32.zip" download "http://minetest.kitsunemimi.pw/curl-$curl_version-win32.zip" -download "http://minetest.kitsunemimi.pw/gettext-$gettext_version-win32.zip" +download "http://minetest.kitsunemimi.pw/dw2/gettext-$gettext_version-win32.zip" download "http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win32.zip" freetype-$freetype_version.zip download "http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win32.zip" -download "http://minetest.kitsunemimi.pw/luajit-$luajit_version-win32.zip" -download "http://minetest.kitsunemimi.pw/libleveldb-$leveldb_version-win32.zip" leveldb-$leveldb_version.zip -download "http://minetest.kitsunemimi.pw/openal_stripped.zip" '' unzip_nofolder +download "http://minetest.kitsunemimi.pw/dw2/luajit-$luajit_version-win32.zip" +download "http://minetest.kitsunemimi.pw/dw2/libleveldb-$leveldb_version-win32.zip" leveldb-$leveldb_version.zip +download "http://minetest.kitsunemimi.pw/openal-soft-$openal_version-win32.zip" # Set source dir, downloading Minetest as needed if [ -n "$EXISTING_MINETEST_DIR" ]; then @@ -112,14 +116,12 @@ git_hash=$(cd $sourcedir && git rev-parse --short HEAD) # Build the thing cd $builddir [ -d build ] && rm -rf build -mkdir build -cd build irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';') vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';') gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';') -cmake -S $sourcedir -B . \ +cmake -S $sourcedir -B build \ -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \ -DCMAKE_INSTALL_PREFIX=/tmp \ -DVERSION_EXTRA=$git_hash \ @@ -154,9 +156,9 @@ cmake -S $sourcedir -B . \ -DVORBIS_DLL="$vorbis_dlls" \ -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \ \ - -DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include/AL \ - -DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \ - -DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \ + -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL \ + -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a \ + -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll \ \ -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll \ -DCURL_INCLUDE_DIR=$libdir/curl/include \ @@ -180,9 +182,9 @@ cmake -S $sourcedir -B . \ -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \ -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll -make -j$(nproc) +cmake --build build -j$(nproc) -[ -z "$NO_PACKAGE" ] && make package +[ -z "$NO_PACKAGE" ] && cmake --build build --target package exit 0 # EOF diff --git a/util/buildbot/buildwin64.sh b/util/buildbot/buildwin64.sh index eb1eae4c2..9d222ab42 100755 --- a/util/buildbot/buildwin64.sh +++ b/util/buildbot/buildwin64.sh @@ -8,7 +8,7 @@ GAME_GIT=https://github.com/minetest/minetest_game GAME_BRANCH=master GAME_NAME=minetest_game -dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" if [ $# -ne 1 ]; then echo "Usage: $0 <build directory>" exit 1 @@ -28,7 +28,7 @@ if [ -z "$compiler" ]; then echo "Unable to determine which MinGW compiler to use" exit 1 fi -toolchain_file=$dir/toolchain_${compiler/-gcc/}.cmake +toolchain_file=$topdir/toolchain_${compiler/-gcc/}.cmake echo "Using $toolchain_file" # Try to find runtime DLLs in various paths (varies by distribution, sigh) @@ -45,17 +45,18 @@ done echo "The compiler runtime DLLs could not be found, they might be missing in the final package." # Get stuff -irrlicht_version=1.9.0mt4 -ogg_version=1.3.4 +irrlicht_version=$(cat $topdir/../../misc/irrlichtmt_tag.txt) +ogg_version=1.3.5 +openal_version=1.21.1 vorbis_version=1.3.7 -curl_version=7.76.1 +curl_version=7.81.0 gettext_version=0.20.1 -freetype_version=2.10.4 -sqlite3_version=3.35.5 +freetype_version=2.11.1 +sqlite3_version=3.37.2 luajit_version=2.1.0-beta3 leveldb_version=1.23 zlib_version=1.2.11 -zstd_version=1.4.9 +zstd_version=1.5.2 mkdir -p $libdir @@ -90,7 +91,7 @@ download "http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win64.zip" download "http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win64.zip" download "http://minetest.kitsunemimi.pw/luajit-$luajit_version-win64.zip" download "http://minetest.kitsunemimi.pw/libleveldb-$leveldb_version-win64.zip" leveldb-$leveldb_version.zip -download "http://minetest.kitsunemimi.pw/openal_stripped64.zip" 'openal_stripped.zip' unzip_nofolder +download "http://minetest.kitsunemimi.pw/openal-soft-$openal_version-win64.zip" # Set source dir, downloading Minetest as needed if [ -n "$EXISTING_MINETEST_DIR" ]; then @@ -112,14 +113,12 @@ git_hash=$(cd $sourcedir && git rev-parse --short HEAD) # Build the thing cd $builddir [ -d build ] && rm -rf build -mkdir build -cd build irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';') vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';') gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';') -cmake -S $sourcedir -B . \ +cmake -S $sourcedir -B build \ -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \ -DCMAKE_INSTALL_PREFIX=/tmp \ -DVERSION_EXTRA=$git_hash \ @@ -154,9 +153,9 @@ cmake -S $sourcedir -B . \ -DVORBIS_DLL="$vorbis_dlls" \ -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \ \ - -DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include/AL \ - -DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \ - -DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \ + -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL \ + -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a \ + -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll \ \ -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll \ -DCURL_INCLUDE_DIR=$libdir/curl/include \ @@ -180,9 +179,9 @@ cmake -S $sourcedir -B . \ -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \ -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll -make -j$(nproc) +cmake --build build -j$(nproc) -[ -z "$NO_PACKAGE" ] && make package +[ -z "$NO_PACKAGE" ] && cmake --build build --target package exit 0 # EOF diff --git a/util/bump_version.sh b/util/bump_version.sh index 3e64bfd86..271886d68 100755 --- a/util/bump_version.sh +++ b/util/bump_version.sh @@ -26,6 +26,7 @@ perform_release() { sed -i -re "s/^set\(DEVELOPMENT_BUILD TRUE\)$/set(DEVELOPMENT_BUILD FALSE)/" CMakeLists.txt sed -i 's/project.ext.set("versionExtra", "-dev")/project.ext.set("versionExtra", "")/' android/build.gradle + sed -i 's/project.ext.set("developmentBuild", 1)/project.ext.set("developmentBuild", 0)/' android/build.gradle sed -i -re "s/\"versionCode\", [0-9]+/\"versionCode\", $NEW_ANDROID_VERSION_CODE/" android/build.gradle sed -i '/\<release/s/\(version\)="[^"]*"/\1="'"$RELEASE_VERSION"'"/' misc/net.minetest.minetest.appdata.xml @@ -55,6 +56,7 @@ back_to_devel() { # Update Android versions sed -i 's/set("versionExtra", "")/set("versionExtra", "-dev")/' android/build.gradle + sed -i 's/project.ext.set("developmentBuild", 0)/project.ext.set("developmentBuild", 1)/' android/build.gradle sed -i -re "s/set\(\"versionMajor\", [0-9]+\)/set(\"versionMajor\", $NEXT_VERSION_MAJOR)/" android/build.gradle sed -i -re "s/set\(\"versionMinor\", [0-9]+\)/set(\"versionMinor\", $NEXT_VERSION_MINOR)/" android/build.gradle sed -i -re "s/set\(\"versionPatch\", [0-9]+\)/set(\"versionPatch\", $NEXT_VERSION_PATCH)/" android/build.gradle diff --git a/util/ci/build.sh b/util/ci/build.sh index ba77cd645..88349b852 100755 --- a/util/ci/build.sh +++ b/util/ci/build.sh @@ -1,8 +1,10 @@ #! /bin/bash -e -mkdir cmakebuild -cd cmakebuild -cmake -DCMAKE_BUILD_TYPE=Debug \ - -DRUN_IN_PLACE=TRUE -DENABLE_GETTEXT=TRUE \ - -DBUILD_SERVER=TRUE ${CMAKE_FLAGS} .. -make -j2 +cmake -B build \ + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \ + -DRUN_IN_PLACE=TRUE \ + -DENABLE_GETTEXT=${CMAKE_ENABLE_GETTEXT:-TRUE} \ + -DBUILD_SERVER=${CMAKE_BUILD_SERVER:-TRUE} \ + ${CMAKE_FLAGS} + +cmake --build build --parallel $(($(nproc) + 1)) diff --git a/util/ci/build_prometheus_cpp.sh b/util/ci/build_prometheus_cpp.sh index edfd574cd..f3e4a5559 100755 --- a/util/ci/build_prometheus_cpp.sh +++ b/util/ci/build_prometheus_cpp.sh @@ -8,6 +8,6 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DCMAKE_BUILD_TYPE=Release \ -DENABLE_TESTING=0 -make -j2 +make -j$(nproc) sudo make install diff --git a/util/ci/clang-tidy.sh b/util/ci/clang-tidy.sh index bb4e99fef..e678cf3b9 100755 --- a/util/ci/clang-tidy.sh +++ b/util/ci/clang-tidy.sh @@ -1,17 +1,13 @@ #! /bin/bash -eu -mkdir -p cmakebuild -cd cmakebuild -cmake -DCMAKE_BUILD_TYPE=Debug \ +cmake -B build -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DRUN_IN_PLACE=TRUE \ -DENABLE_{GETTEXT,SOUND}=FALSE \ - -DBUILD_SERVER=TRUE .. -make GenerateVersion - -cd .. + -DBUILD_SERVER=TRUE +cmake --build build --target GenerateVersion ./util/ci/run-clang-tidy.py \ - -clang-tidy-binary=clang-tidy-9 -p cmakebuild \ + -clang-tidy-binary=clang-tidy-9 -p build \ -quiet -config="$(cat .clang-tidy)" \ 'src/.*' diff --git a/util/ci/common.sh b/util/ci/common.sh index f9df54c4a..3015680c4 100644 --- a/util/ci/common.sh +++ b/util/ci/common.sh @@ -7,19 +7,16 @@ install_linux_deps() { libhiredis-dev libogg-dev libgmp-dev libvorbis-dev libopenal-dev \ gettext libpq-dev libleveldb-dev libcurl4-openssl-dev libzstd-dev) - if [[ "$1" == "--old-irr" ]]; then + if [[ "$1" == "--no-irr" ]]; then shift - pkgs+=(libirrlicht-dev) else - wget "https://github.com/minetest/irrlicht/releases/download/1.9.0mt4/ubuntu-bionic.tar.gz" + local ver=$(cat misc/irrlichtmt_tag.txt) + wget "https://github.com/minetest/irrlicht/releases/download/$ver/ubuntu-bionic.tar.gz" sudo tar -xaf ubuntu-bionic.tar.gz -C /usr/local fi sudo apt-get update sudo apt-get install -y --no-install-recommends ${pkgs[@]} "$@" - - # workaround for bug with Github Actions' ubuntu-18.04 image - sudo apt-get remove -y libgcc-11-dev gcc-11 || : } # Mac OSX build only diff --git a/util/generate-texture-normals.sh b/util/generate-texture-normals.sh deleted file mode 100755 index 6279dfa69..000000000 --- a/util/generate-texture-normals.sh +++ /dev/null @@ -1,255 +0,0 @@ -#!/bin/bash - -# This script generates normalmaps using The GIMP to do the heavy lifting. -# give any unrecognized switch (say, -h) for usage info. - -rm /tmp/normals_filelist.txt - -numprocs=6 - -skiptools=false -skipinventory=false -invresolution=64 -dryrun=false -pattern="*.png *.jpg" - -filter=0 -scale=8 -wrap=0 -heightsource=0 -conversion=0 -invertx=0 -inverty=0 - -while test -n "$1"; do - case "$1" in - --scale|-s) - if [ -z "$2" ] ; then echo "Missing scale parameter"; exit 1; fi - scale=$2 - shift - shift - ;; - --pattern|-p) - if [ -z "$2" ] ; then echo "Missing pattern parameter"; exit 1; fi - pattern=$2 - shift - shift - ;; - --skiptools|-t) - skiptools=true - shift - ;; - --skipinventory|-i) - if [[ $2 =~ ^[0-9]+$ ]]; then - invresolution=$2 - shift - fi - skipinventory=true - shift - ;; - --filter|-f) - if [ -z "$2" ] ; then echo "Missing filter parameter"; exit 1; fi - - case "$2" in - sobel3|1) - filter=1 - ;; - sobel5|2) - filter=2 - ;; - prewitt3|3) - filter=3 - ;; - prewitt5|4) - filter=4 - ;; - 3x3|5) - filter=5 - ;; - 5x5|6) - filter=6 - ;; - 7x7|7) - filter=7 - ;; - 9x9|8) - filter=8 - ;; - *) - filter=0 - ;; - esac - - shift - shift - ;; - --heightalpha|-a) - heightsource=1 - shift - ;; - --conversion|-c) - if [ -z "$2" ] ; then echo "Missing conversion parameter"; exit 1; fi - - case "$2" in - biased|1) - conversion=1 - ;; - red|2) - conversion=2 - ;; - green|3) - conversion=3 - ;; - blue|4) - conversion=4 - ;; - maxrgb|5) - conversion=5 - ;; - minrgb|6) - conversion=6 - ;; - colorspace|7) - conversion=7 - ;; - normalize-only|8) - conversion=8 - ;; - heightmap|9) - conversion=9 - ;; - *) - conversion=0 - ;; - esac - - shift - shift - ;; - --wrap|-w) - wrap=1 - shift - ;; - --invertx|-x) - invertx=1 - shift - ;; - --inverty|-y) - inverty=1 - shift - ;; - --dryrun|-d) - dryrun=true - shift - ;; - *) - echo -e "\nUsage:\n" - echo "`basename $0` [--scale|-s <value>] [--filter|-f <string>]" - echo " [--wrap|-w] [--heightalpha|-a] [--invertx|-x] [--inverty|-y]" - echo " [--conversion|-c <string>] [--skiptools|-t] [--skipinventory|-i [<value>]]" - echo " [--dryrun|-d] [--pattern|-p <pattern>]" - echo -e "\nDefaults to a scale of 8, checking all files in the current directory, and not" - echo "skipping apparent tools or inventory images. Filter, if specified, may be one" - echo "of: sobel3, sobel5, prewitt3, prewitt5, 3x3, 5x5, 7x7, or 9x9, or a value 1" - echo "through 8 (1=sobel3, 2=sobel5, etc.). Defaults to 0 (four-sample). The height" - echo "source is taken from the image's alpha channel if heightalpha is specified.\n" - echo "" - echo "If inventory skip is specified, an optional resolution may also be included" - echo "(default is 64). Conversion can be one of: biased, red, green, blue, maxrgb," - echo "minrgb, colorspace, normalize-only, heightmap or a value from 1 to 9" - echo "corresponding respectively to those keywords. Defaults to 0 (simple" - echo "normalize) if not specified. Wrap, if specified, enables wrapping of the" - echo "normalmap around the edges of the texture (defaults to no). Invert X/Y" - echo "reverses the calculated gradients for the X and/or Y dimensions represented" - echo "by the normalmap (both default to non-inverted)." - echo "" - echo "The pattern, can be an escaped pattern string such as \*apple\* or" - echo "default_\*.png or similar (defaults to all PNG and JPG images in the current" - echo "directory that do not contain \"_normal\" or \"_specular\" in their filenames)." - echo "" - echo "If set for dry-run, the actions this script will take will be printed, but no" - echo "images will be generated. Passing an invalid value to a switch will generally" - echo "cause that switch to revert to its default value." - echo "" - exit 1 - ;; - esac -done - -echo -e "\nProcessing files based on pattern \"$pattern\" ..." - -normalMap() -{ - out=`echo "$1" | sed 's/.png/_normal.png/' | sed 's/.jpg/_normal.png/'` - - echo "Launched process to generate normalmap: \"$1\" --> \"$out\"" >&2 - - gimp -i -b " - (define - (normalMap-fbx-conversion fileName newFileName filter nscale wrap heightsource conversion invertx inverty) - (let* - ( - (image (car (gimp-file-load RUN-NONINTERACTIVE fileName fileName))) - (drawable (car (gimp-image-get-active-layer image))) - (drawable (car (gimp-image-flatten image))) - ) - (if (> (car (gimp-drawable-type drawable)) 1) - (gimp-convert-rgb image) () - ) - - (plug-in-normalmap - RUN-NONINTERACTIVE - image - drawable - filter - 0.0 - nscale - wrap - heightsource - 0 - conversion - 0 - invertx - inverty - 0 - 0.0 - drawable) - (gimp-file-save RUN-NONINTERACTIVE image drawable newFileName newFileName) - (gimp-image-delete image) - ) - ) - (normalMap-fbx-conversion \"$1\" \"$out\" $2 $3 $4 $5 $6 $7 $8)" -b '(gimp-quit 0)' -} - -export -f normalMap - -for file in `ls $pattern |grep -v "_normal.png"|grep -v "_specular"` ; do - - invtest=`file "$file" |grep "$invresolution x $invresolution"` - if $skipinventory && [ -n "$invtest" ] ; then - echo "Skipped presumed "$invresolution"px inventory image: $file" >&2 - continue - fi - - tooltest=`echo "$file" \ - | grep -v "_tool" \ - | grep -v "_shovel" \ - | grep -v "_pick" \ - | grep -v "_axe" \ - | grep -v "_sword" \ - | grep -v "_hoe" \ - | grep -v "bucket_"` - - if $skiptools && [ -z "$tooltest" ] ; then - echo "Skipped presumed tool image: $file" >&2 - continue - fi - - if $dryrun ; then - echo "Would have generated a normalmap for $file" >&2 - continue - else - echo \"$file\" $filter $scale $wrap $heightsource $conversion $invertx $inverty - fi -done | xargs -P $numprocs -n 8 -I{} bash -c normalMap\ \{\}\ \{\}\ \{\}\ \{\}\ \{\}\ \{\}\ \{\}\ \{\} - diff --git a/util/helper_mod/init.lua b/util/helper_mod/init.lua new file mode 100644 index 000000000..4da832ed7 --- /dev/null +++ b/util/helper_mod/init.lua @@ -0,0 +1,51 @@ +local mode = core.settings:get("helper_mode") + +if mode == "devtest" then + + -- Provide feedback to script by creating files in world path + core.after(0, function() + io.close(io.open(core.get_worldpath() .. "/startup", "w")) + end) + local function callback(test_ok) + if not test_ok then + io.close(io.open(core.get_worldpath() .. "/test_failure", "w")) + end + io.close(io.open(core.get_worldpath() .. "/done", "w")) + core.request_shutdown("", false, 2) + end + -- If tests are enabled exit when they're done, otherwise exit on player join + if core.settings:get_bool("devtest_unittests_autostart") and core.global_exists("unittests") then + unittests.on_finished = callback + else + core.register_on_joinplayer(function() callback(true) end) + end + +elseif mode == "mapgen" then + + -- Stress-test mapgen by constantly generating new area + local csize = tonumber(core.settings:get("chunksize")) * core.MAP_BLOCKSIZE + local MINP, MAXP = vector.new(0, -csize, 0), vector.new(csize*3, csize*2, csize) + local DIR = "x" + local pstart = vector.new(0, 0, 0) + local next_, callback + next_ = function(arg) + print("emerging " .. core.pos_to_string(pstart)) + core.emerge_area( + vector.add(pstart, MINP), vector.add(pstart, MAXP), + callback, arg + ) + end + local trig = {} + callback = function(blockpos, action, calls_rem, n) + if action == core.EMERGE_CANCELLED or action == core.EMERGE_ERRORED then + return + end + if calls_rem <= 20 and not trig[n] then + trig[n] = true + pstart[DIR] = pstart[DIR] + (MAXP[DIR] - MINP[DIR]) + next_(n + 1) + end + end + core.after(0, next_, 1) + +end diff --git a/util/helper_mod/mod.conf b/util/helper_mod/mod.conf new file mode 100644 index 000000000..efdd9eaf3 --- /dev/null +++ b/util/helper_mod/mod.conf @@ -0,0 +1,3 @@ +name = helper_mod +description = Helper used by various test scripts +optional_depends = unittests diff --git a/util/stress_mapgen.sh b/util/stress_mapgen.sh new file mode 100755 index 000000000..6bbe57483 --- /dev/null +++ b/util/stress_mapgen.sh @@ -0,0 +1,30 @@ +#!/bin/bash +dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +gameid=${gameid:-devtest} +minetest=$dir/../bin/minetest +testspath=$dir/../tests +conf_server=$testspath/server.conf +worldpath=$testspath/world + +run () { + if [ -n "$PERF" ]; then + perf record -z --call-graph dwarf -- "$@" + else + "$@" + fi +} + +[ -e "$minetest" ] || { echo "executable $minetest missing"; exit 1; } + +rm -rf "$worldpath" +mkdir -p "$worldpath/worldmods" + +settings=(sqlite_synchronous=0 helper_mode=mapgen) +[ -n "$PROFILER" ] && settings+=(profiler_print_interval=15) +printf '%s\n' "${settings[@]}" >"$testspath/server.conf" \ + +ln -s "$dir/helper_mod" "$worldpath/worldmods/" + +args=(--config "$conf_server" --world "$worldpath" --gameid $gameid) +[ -n "$PROFILER" ] && args+=(--verbose) +run "$minetest" --server "${args[@]}" diff --git a/util/test_multiplayer.sh b/util/test_multiplayer.sh index 5ffc044e0..1fcf298e8 100755 --- a/util/test_multiplayer.sh +++ b/util/test_multiplayer.sh @@ -1,6 +1,6 @@ #!/bin/bash dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -gameid=devtest +gameid=${gameid:-devtest} minetest=$dir/../bin/minetest testspath=$dir/../tests conf_client1=$testspath/client1.conf @@ -23,50 +23,33 @@ gdbrun () { gdb -q -batch -ex 'set confirm off' -ex 'r' -ex 'bt' --args "$@" } -[ -e $minetest ] || { echo "executable $minetest missing"; exit 1; } +[ -e "$minetest" ] || { echo "executable $minetest missing"; exit 1; } -rm -rf $worldpath -mkdir -p $worldpath/worldmods/test +rm -rf "$worldpath" +mkdir -p "$worldpath/worldmods" -printf '%s\n' >$testspath/client1.conf \ +printf '%s\n' >"$testspath/client1.conf" \ video_driver=null name=client1 viewing_range=10 \ enable_{sound,minimap,shaders}=false -printf '%s\n' >$testspath/server.conf \ - max_block_send_distance=1 devtest_unittests_autostart=true +printf '%s\n' >"$testspath/server.conf" \ + max_block_send_distance=1 devtest_unittests_autostart=true \ + helper_mode=devtest -cat >$worldpath/worldmods/test/init.lua <<"LUA" -core.after(0, function() - io.close(io.open(core.get_worldpath() .. "/startup", "w")) -end) -local function callback(test_ok) - if not test_ok then - io.close(io.open(core.get_worldpath() .. "/test_failure", "w")) - end - io.close(io.open(core.get_worldpath() .. "/done", "w")) - core.request_shutdown("", false, 2) -end -if core.settings:get_bool("devtest_unittests_autostart") then - unittests.on_finished = callback -else - core.register_on_joinplayer(function() callback(true) end) -end -LUA -printf '%s\n' >$worldpath/worldmods/test/mod.conf \ - name=test optional_depends=unittests +ln -s "$dir/helper_mod" "$worldpath/worldmods/" echo "Starting server" -gdbrun $minetest --server --config $conf_server --world $worldpath --gameid $gameid 2>&1 | sed -u 's/^/(server) /' & -waitfor $worldpath/startup +gdbrun "$minetest" --server --config "$conf_server" --world "$worldpath" --gameid $gameid 2>&1 | sed -u 's/^/(server) /' & +waitfor "$worldpath/startup" echo "Starting client" -gdbrun $minetest --config $conf_client1 --go --address 127.0.0.1 2>&1 | sed -u 's/^/(client) /' & -waitfor $worldpath/done +gdbrun "$minetest" --config "$conf_client1" --go --address 127.0.0.1 2>&1 | sed -u 's/^/(client) /' & +waitfor "$worldpath/done" echo "Waiting for client and server to exit" wait -if [ -f $worldpath/test_failure ]; then +if [ -f "$worldpath/test_failure" ]; then echo "There were test failures." exit 1 fi |