test: Fix open-read test.

* build-aux/pre-inst-env.in (srcdir): Remove.
(abs_top_srcdir, abs_top_builddir): Export.
* lib/tests/posix/50-open-read.c (main): Use abs_top_srcdir.
This commit is contained in:
Jan Nieuwenhuizen 2019-06-28 20:37:47 +02:00
parent c83584f85f
commit babb1bb63e
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
2 changed files with 12 additions and 7 deletions

View file

@ -18,10 +18,12 @@
# You should have received a copy of the GNU General Public License
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
srcdir="@srcdir@"
abs_top_srcdir="@abs_top_srcdir@"
export abs_top_srcdir
abs_top_builddir="@abs_top_builddir@"
export abs_top_builddir
prefix=${prefix-@prefix@}
export prefix
program_prefix=${program_prefix-@program_prefix@}
MES_PREFIX=${MES_PREFIX-${abs_top_srcdir}/mes}

View file

@ -30,9 +30,12 @@ main (int argc, char const *argv[])
{
eputs ("test:getenv\n");
char file_name[PATH_MAX];
char *srcdir = getenv ("srcdir");
if (!srcdir)
return 1;
char *srcdir = getenv ("abs_top_srcdir");
if (! srcdir) // for running by hand
srcdir = ".";
eputs ("srcdir=");
eputs (srcdir);
eputs ("\n");
strcpy (file_name, srcdir);
strcpy (file_name + strlen (srcdir), "/lib/tests/posix/data/open-read");
eputs ("test open:");
@ -40,13 +43,13 @@ main (int argc, char const *argv[])
eputs ("\n");
int filedes = open (file_name, 0, 0);
if (filedes <= 2)
return 2;
return 1;
char buf[20];
int n = read (filedes, buf, sizeof (buf));
if (n != 5)
return 3;
return 2;
if (strcmp (buf, "hello"))
return 4;
return 3;
eputs ("test read: ");
eputs (buf);
eputs ("\n");