summaryrefslogtreecommitdiff
path: root/test/argp
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2016-11-03 20:19:02 +0100
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-11-03 20:19:02 +0100
commit24b4b8b66366176b40525baa1b2f056e8a68d0ce (patch)
treec705733ff04ff1d089eff6494622668632565a62 /test/argp
parent3384c45e66ddf18f235654b67ae34ac7dcb07534 (diff)
argp: be sure uClibc-ng feature is available
Diffstat (limited to 'test/argp')
-rw-r--r--test/argp/argp-ex1.c6
-rw-r--r--test/argp/argp-ex2.c6
-rw-r--r--test/argp/argp-ex3.c7
-rw-r--r--test/argp/argp-ex4.c6
-rw-r--r--test/argp/argp-test.c6
-rw-r--r--test/argp/bug-argp1.c7
-rw-r--r--test/argp/tst-argp1.c12
-rw-r--r--test/argp/tst-argp2.c6
8 files changed, 51 insertions, 5 deletions
diff --git a/test/argp/argp-ex1.c b/test/argp/argp-ex1.c
index 7bb5f22..5a4f93b 100644
--- a/test/argp/argp-ex1.c
+++ b/test/argp/argp-ex1.c
@@ -6,10 +6,16 @@
a (rather pointless) messages for --help. */
#include <stdlib.h>
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
#include <argp.h>
+#endif
int main (int argc, char **argv)
{
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
argp_parse (0, argc, argv, 0, 0, 0);
exit (0);
+#else
+ return 23;
+#endif
}
diff --git a/test/argp/argp-ex2.c b/test/argp/argp-ex2.c
index c49fbac..67c9b4b 100644
--- a/test/argp/argp-ex2.c
+++ b/test/argp/argp-ex2.c
@@ -20,6 +20,7 @@
parsers for various tasks). */
#include <stdlib.h>
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
#include <argp.h>
const char *argp_program_version =
@@ -37,9 +38,14 @@ static char doc[] =
used in the output for @samp{--help}, and the @samp{--version}
option will print out @code{argp_program_version}. */
static struct argp argp = { 0, 0, 0, doc };
+#endif
int main (int argc, char **argv)
{
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
argp_parse (&argp, argc, argv, 0, 0, 0);
exit (0);
+#else
+ return 23;
+#endif
}
diff --git a/test/argp/argp-ex3.c b/test/argp/argp-ex3.c
index 24d5c50..6e24fe8 100644
--- a/test/argp/argp-ex3.c
+++ b/test/argp/argp-ex3.c
@@ -53,6 +53,7 @@
An options vector should be terminated by an option with all fields zero. */
#include <stdlib.h>
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
#include <argp.h>
const char *argp_program_version =
@@ -129,8 +130,11 @@ parse_opt (int key, char *arg, struct argp_state *state)
/* Our argp parser. */
static struct argp argp = { options, parse_opt, args_doc, doc };
+#endif
+
int main (int argc, char **argv)
{
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
struct arguments arguments;
/* Default values. */
@@ -150,4 +154,7 @@ int main (int argc, char **argv)
arguments.silent ? "yes" : "no");
exit (0);
+#else
+ return 23;
+#endif
}
diff --git a/test/argp/argp-ex4.c b/test/argp/argp-ex4.c
index c77c7ef..97097c7 100644
--- a/test/argp/argp-ex4.c
+++ b/test/argp/argp-ex4.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <error.h>
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
#include <argp.h>
const char *argp_program_version =
@@ -130,9 +131,11 @@ parse_opt (int key, char *arg, struct argp_state *state)
/* Our argp parser. */
static struct argp argp = { options, parse_opt, args_doc, doc };
+#endif
int main (int argc, char **argv)
{
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
int i, j;
struct arguments arguments;
@@ -164,4 +167,7 @@ int main (int argc, char **argv)
}
exit (0);
+#else
+ return 23;
+#endif
}
diff --git a/test/argp/argp-test.c b/test/argp/argp-test.c
index 2e0c749..b0ad59b 100644
--- a/test/argp/argp-test.c
+++ b/test/argp/argp-test.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <time.h>
#include <string.h>
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
#include <argp.h>
const char *argp_program_version = "argp-test 1.0";
@@ -195,14 +196,19 @@ static struct argp_child argp_children[] = { { &sub_argp }, { 0 } };
static struct argp argp = {
options, parse_opt, args_doc, doc, argp_children, help_filter
};
+#endif
int
main (int argc, char **argv)
{
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
struct params params;
params.foonly = 0;
params.foonly_default = random ();
argp_parse (&argp, argc, argv, 0, 0, &params);
printf ("After parsing: foonly = %x\n", params.foonly);
return 0;
+#else
+ return 23;
+#endif
}
diff --git a/test/argp/bug-argp1.c b/test/argp/bug-argp1.c
index a28cf4b..39b573d 100644
--- a/test/argp/bug-argp1.c
+++ b/test/argp/bug-argp1.c
@@ -1,6 +1,6 @@
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
#include <argp.h>
-
static const struct argp_option test_options[] =
{
{ NULL, 'a', NULL, OPTION_DOC, NULL },
@@ -13,13 +13,18 @@ static struct argp test_argp =
test_options
};
+#endif
static int
do_test (int argc, char *argv[])
{
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
int i;
argp_parse (&test_argp, argc, argv, 0, &i, NULL);
return 0;
+#else
+ return 23;
+#endif
}
#define TEST_FUNCTION do_test (argc, argv)
diff --git a/test/argp/tst-argp1.c b/test/argp/tst-argp1.c
index 912e0cb..c3be15d 100644
--- a/test/argp/tst-argp1.c
+++ b/test/argp/tst-argp1.c
@@ -16,11 +16,9 @@
License along with the GNU C Library; see the file COPYING.LIB. If
not, see <http://www.gnu.org/licenses/>.  */
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
#include <argp.h>
-
-
-
#define OPT_TO_THREAD 300
#define OPT_TO_PROCESS 301
#define OPT_SYNC_SIGNAL 302
@@ -90,11 +88,12 @@ static struct argp argp =
{
test_options, parse_opt
};
-
+#endif
static int
do_test (void)
{
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
int argc = 2;
char *argv[3] = { (char *) "tst-argp1", (char *) "--help", NULL };
int remaining;
@@ -103,15 +102,20 @@ do_test (void)
argp_parse (&argp, argc, argv, 0, &remaining, NULL);
return 0;
+#else
+ return 23;
+#endif
}
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
/* Handle program arguments. */
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
return ARGP_ERR_UNKNOWN;
}
+#endif
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
diff --git a/test/argp/tst-argp2.c b/test/argp/tst-argp2.c
index 03afc0b..0e521a9 100644
--- a/test/argp/tst-argp2.c
+++ b/test/argp/tst-argp2.c
@@ -16,6 +16,7 @@
License along with the GNU C Library; see the file COPYING.LIB. If
not, see <http://www.gnu.org/licenses/>.  */
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
#include <argp.h>
static const struct argp_option opt1[] =
@@ -87,12 +88,17 @@ static struct argp argp1 =
opt1, NULL, "args doc1", "doc1", children1, NULL, NULL
};
+#endif
static int
do_test (void)
{
+#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
argp_help (&argp1, stdout, ARGP_HELP_LONG, (char *) "tst-argp2");
return 0;
+#else
+ return 23;
+#endif
}