|
Packit |
33f14e |
/* Test the gnulib getprogname module.
|
|
Packit |
33f14e |
Copyright (C) 2016-2017 Free Software Foundation, Inc.
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
This program is free software: you can redistribute it and/or modify
|
|
Packit |
33f14e |
it under the terms of the GNU General Public License as published by
|
|
Packit |
33f14e |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit |
33f14e |
(at your option) any later version.
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
This program is distributed in the hope that it will be useful,
|
|
Packit |
33f14e |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
33f14e |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
33f14e |
GNU General Public License for more details.
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
You should have received a copy of the GNU General Public License
|
|
Packit |
33f14e |
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
#include <config.h>
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
#include "getprogname.h"
|
|
Packit |
33f14e |
#include <string.h>
|
|
Packit |
33f14e |
#include <assert.h>
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
#ifdef __hpux
|
|
Packit |
33f14e |
# define STREQ(a, b) (strncmp (a, b, 14) == 0)
|
|
Packit |
33f14e |
#else
|
|
Packit |
33f14e |
# define STREQ(a, b) (strcmp (a, b) == 0)
|
|
Packit |
33f14e |
#endif
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
int
|
|
Packit |
33f14e |
main (void)
|
|
Packit |
33f14e |
{
|
|
Packit |
33f14e |
char const *p = getprogname ();
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
/* libtool creates a temporary executable whose name is sometimes prefixed
|
|
Packit |
33f14e |
with "lt-" (depends on the platform). But the name of the temporary
|
|
Packit |
33f14e |
executable is a detail that should not be visible to the end user and to
|
|
Packit |
33f14e |
the test suite. Remove this "lt-" prefix here. */
|
|
Packit |
33f14e |
if (strncmp (p, "lt-", 3) == 0)
|
|
Packit |
33f14e |
p += 3;
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
/* Note: You can make this test fail
|
|
Packit |
33f14e |
a) by running it on a case-insensitive file system (such as on Windows,
|
|
Packit |
33f14e |
Cygwin, or on Mac OS X with a case-insensitive HFS+ file system),
|
|
Packit |
33f14e |
with an invocation that contains upper case characters, e.g.
|
|
Packit |
33f14e |
test-GETPROGNAME,
|
|
Packit |
33f14e |
b) by hardlinking or symlinking it to a different name (e.g. test-foo)
|
|
Packit |
33f14e |
and invoking it through that name.
|
|
Packit |
33f14e |
That's not the intended use. The Makefile always invokes it as
|
|
Packit |
33f14e |
'test-getprogname${EXEEXT}'. */
|
|
Packit |
33f14e |
#if defined __CYGWIN__
|
|
Packit |
33f14e |
/* The Cygwin getprogname() function strips the ".exe" suffix. */
|
|
Packit |
33f14e |
assert (STREQ (p, "test-getprogname"));
|
|
Packit |
33f14e |
#else
|
|
Packit |
33f14e |
assert (STREQ (p, "test-getprogname" EXEEXT));
|
|
Packit |
33f14e |
#endif
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
return 0;
|
|
Packit |
33f14e |
}
|