diff --git a/meson.build b/meson.build
index f10f46d0d87c79ba7da4a5abcd43611d08eececc..4eeb541bd8b1cdaef0aa6269ec591f73aeee9d5c 100644
--- a/meson.build
+++ b/meson.build
@@ -1,6 +1,3 @@
-# TODO:
-# - See what to do with xvfb-run (see #1892). Maybe try to detect it from meson.build, and pass it optionally to the test driver script
-
 project('dynare',
         'cpp', 'fortran', 'c',
         version : '6-unstable',
@@ -1837,9 +1834,15 @@ mod_and_m_tests = [
 
 base_test_driver_args = [ get_option('build_for') ]
 if get_option('build_for') == 'matlab'
-  base_test_driver_args += [ matlab_exe.full_path(), matlab_version, matlab_arch ]
+  base_test_driver_args += [ matlab_exe.full_path(), matlab_version, matlab_arch, '' ]
 else
   base_test_driver_args += [ octave_exe.full_path(), octave_version, '' ]
+  xvfb_run_exe = find_program('xvfb-run', required : false) # Debian-specific utility
+  if xvfb_run_exe.found()
+    base_test_driver_args += xvfb_run_exe.full_path()
+  else
+    base_test_driver_args += ''
+  endif
 endif
 base_test_driver_args += [ meson.current_source_dir(), meson.current_build_dir() ]
 
diff --git a/scripts/test-driver b/scripts/test-driver
index bb42e9799e8c23fcb4b4891232d8046c7337e890..e868ec057ccce6fff847dedd96610244ea3f78f2 100755
--- a/scripts/test-driver
+++ b/scripts/test-driver
@@ -6,7 +6,7 @@ set -e
 shopt -s extglob
 
 if (($# < 7 )); then
-    echo "Usage: $0 build_for matlab_octave_exe matlab_octave_version matlab_arch source_root build_root test_file(s) [-- extra_file(s)]" 2>&1
+    echo "Usage: $0 build_for matlab_octave_exe matlab_octave_version matlab_arch xvfb_run_exe source_root build_root test_file(s) [-- extra_file(s)]" 2>&1
     exit 1
 fi
 
@@ -14,9 +14,10 @@ build_for=$1
 matlab_octave_exe=$2
 matlab_octave_version=$3
 matlab_arch=$4
-source_root=$5
-build_root=$6
-shift 6
+xvfb_run_exe=$5
+source_root=$6
+build_root=$7
+shift 7
 
 test_files=()
 while (($# > 0)); do
@@ -111,6 +112,11 @@ for test_file in "${test_files[@]}"; do
         # We cannot use the --no-window-system option, and we have to use xvfb
         # See the following Octave bug: https://savannah.gnu.org/bugs/?62101
         # (this affects at least tests/shock_decomposition/ls2003_plot.mod)
-        xvfb-run -a "$matlab_octave_exe" --no-init-file --silent --no-history "$test_arg"
+        test_cmd=("$matlab_octave_exe" --no-init-file --silent --no-history "$test_arg")
+        if [[ -n $xvfb_run_exe ]]; then
+            "$xvfb_run_exe" -a "${test_cmd[@]}"
+        else
+            "${test_cmd[@]}"
+        fi
     fi
 done