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:
parent
c83584f85f
commit
babb1bb63e
|
@ -18,10 +18,12 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
srcdir="@srcdir@"
|
|
||||||
abs_top_srcdir="@abs_top_srcdir@"
|
abs_top_srcdir="@abs_top_srcdir@"
|
||||||
|
export abs_top_srcdir
|
||||||
abs_top_builddir="@abs_top_builddir@"
|
abs_top_builddir="@abs_top_builddir@"
|
||||||
|
export abs_top_builddir
|
||||||
prefix=${prefix-@prefix@}
|
prefix=${prefix-@prefix@}
|
||||||
|
export prefix
|
||||||
program_prefix=${program_prefix-@program_prefix@}
|
program_prefix=${program_prefix-@program_prefix@}
|
||||||
|
|
||||||
MES_PREFIX=${MES_PREFIX-${abs_top_srcdir}/mes}
|
MES_PREFIX=${MES_PREFIX-${abs_top_srcdir}/mes}
|
||||||
|
|
|
@ -30,9 +30,12 @@ main (int argc, char const *argv[])
|
||||||
{
|
{
|
||||||
eputs ("test:getenv\n");
|
eputs ("test:getenv\n");
|
||||||
char file_name[PATH_MAX];
|
char file_name[PATH_MAX];
|
||||||
char *srcdir = getenv ("srcdir");
|
char *srcdir = getenv ("abs_top_srcdir");
|
||||||
if (!srcdir)
|
if (! srcdir) // for running by hand
|
||||||
return 1;
|
srcdir = ".";
|
||||||
|
eputs ("srcdir=");
|
||||||
|
eputs (srcdir);
|
||||||
|
eputs ("\n");
|
||||||
strcpy (file_name, srcdir);
|
strcpy (file_name, srcdir);
|
||||||
strcpy (file_name + strlen (srcdir), "/lib/tests/posix/data/open-read");
|
strcpy (file_name + strlen (srcdir), "/lib/tests/posix/data/open-read");
|
||||||
eputs ("test open:");
|
eputs ("test open:");
|
||||||
|
@ -40,13 +43,13 @@ main (int argc, char const *argv[])
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
int filedes = open (file_name, 0, 0);
|
int filedes = open (file_name, 0, 0);
|
||||||
if (filedes <= 2)
|
if (filedes <= 2)
|
||||||
return 2;
|
return 1;
|
||||||
char buf[20];
|
char buf[20];
|
||||||
int n = read (filedes, buf, sizeof (buf));
|
int n = read (filedes, buf, sizeof (buf));
|
||||||
if (n != 5)
|
if (n != 5)
|
||||||
return 3;
|
return 2;
|
||||||
if (strcmp (buf, "hello"))
|
if (strcmp (buf, "hello"))
|
||||||
return 4;
|
return 3;
|
||||||
eputs ("test read: ");
|
eputs ("test read: ");
|
||||||
eputs (buf);
|
eputs (buf);
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
|
|
Loading…
Reference in a new issue