diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index bcdf7fd..a9b6ee5 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -1484,11 +1484,14 @@ sub command_line_setup {
# Search through list of locations that are known
# to be "fast disks" to find a suitable location
# Use --mem=
as first location to look.
- my @tmpfs_locations= ($opt_mem, "/dev/shm", "/tmp");
+ my @tmpfs_locations= ("/run/shm", "/dev/shm", "/tmp");
+
+ # Use $ENV{'MTR_MEM'} as first location to look (if defined)
+ unshift(@tmpfs_locations, $ENV{'MTR_MEM'}) if defined $ENV{'MTR_MEM'};
foreach my $fs (@tmpfs_locations)
{
- if ( -d $fs )
+ if ( -d $fs && ! -l $fs )
{
my $template= "var_${opt_build_thread}_XXXX";
$opt_mem= tempdir( $template, DIR => $fs, CLEANUP => 0);