octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Failing getpwuid test in 4.0.0-rc2


From: Rik
Subject: Failing getpwuid test in 4.0.0-rc2
Date: Mon, 23 Mar 2015 10:30:51 -0700

The failing test is

***** testif HAVE_GETPWUID
 x = getpwuid (getuid ());
 assert (x.dir, tilde_expand ("~"));
 assert (x.dir, tilde_expand (sprintf ("~%s", x.name)));
 assert ("foobar", tilde_expand ("foobar"));
!!!!! test failed
ASSERT errors for:  assert (x.dir,tilde_expand ("~"))

  Location  |  Observed  |  Expected  |  Reason
     []         /root     /home/steph    Strings don't match

I've traced the issue back to oct-env.cc quoted below:

std::string
octave_env::do_get_home_directory (void) const
{
  std::string hd = do_getenv ("HOME");

#if defined (__MINGW32__) || defined (_MSC_VER)
  // Maybe we are started directly from cmd.exe.
  if (hd.empty ())
    {
      std::string drv = do_getenv ("HOMEDRIVE");
      if (drv.empty ())
        hd = do_getenv ("HOMEPATH");
      else
        hd = drv + do_getenv ("HOMEPATH");
    }
#endif

  if (hd.empty ())
    {
      octave_passwd pw = octave_passwd::getpwuid (octave_syscalls::getuid ());

      hd = pw ? pw.dir () : std::string (file_ops::dir_sep_str ());
    }

  return hd;
}

Octave uses the value of the HOME environment variable as the preferred
expansion for '~' rather than the directory listed in the passwd file for
the current user ID.  This creates a mismatch because the BIST expects only
the latter behavior.  We could change the BIST test to try HOME first and
fall back to the passwd file.  Or we could say that this just doesn't
happen often enough to fix.

--Rik



reply via email to

[Prev in Thread] Current Thread [Next in Thread]