1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00

support: Add optstring support

This patch adds an option to test to add small command line option
through CMDLINE_OPTSTRING define.  For instance:

  #define CMDLINE_OPTSTRING "vd"

  static void
  cmdline_process_function (int c)
  {
    switch (c):
      'v':
        /* process '-v' option.  */
      break;
      'd':
        /* process '-d' option.  */
      break;
  }
  #define CMDLINE_PROCESS cmdline_process_function

It will add both '-v' and '-d' along with already default long options.

	* support/support_test_main.c (support_test_main):  Use optstring
	member for option string in getopt_long.
	* support/test-driver.c: Add comment about CMDLINE_OPTSTRING.
	(CMDLINE_OPTSTRING): New define.
	* support/test-driver.h (test_config): Add optstring member.
This commit is contained in:
Adhemerval Zanella
2017-05-24 09:17:34 -03:00
parent 70fe2eb794
commit 244361ebae
4 changed files with 20 additions and 1 deletions

View File

@@ -211,7 +211,8 @@ support_test_main (int argc, char **argv, const struct test_config *config)
mallopt (M_PERTURB, 42);
}
while ((opt = getopt_long (argc, argv, "+", options, NULL)) != -1)
while ((opt = getopt_long (argc, argv, config->optstring, options, NULL))
!= -1)
switch (opt)
{
case '?':