From b12e1c5bdef1ca422cff9db1a32185ff5e10e9a2 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Mon, 5 May 2008 20:29:45 +0000 Subject: [PATCH] - jbj: extend coverage to several additional setup routines. --- .popt | 0 CHANGES | 1 + test-poptrc | 5 +++-- test1.c | 4 ++++ testit.sh | 7 +++++-- 5 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 .popt diff --git a/.popt b/.popt new file mode 100644 index 0000000..e69de29 diff --git a/CHANGES b/CHANGES index 9ab258e..457522c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,5 @@ 1.14 -> 1.15: + - jbj: extend coverage to several additional setup routines. - jbj: add tests for --usage/--help coverage. - jbj: add lconv/gcov targets to Makefile.am. - jbj: refactor automagic (*opt->arg) option arg store to poptSaveArg(). diff --git a/test-poptrc b/test-poptrc index 509e013..9d5370f 100644 --- a/test-poptrc +++ b/test-poptrc @@ -1,4 +1,5 @@ -test1 alias --simple --arg2 +test1 alias --simple --arg2 \ + --POPTdesc=$"simple description" --POPTargs=$"ARG" test1 alias --two --arg1 --arg2 alias test1 alias --takerest -- test1 alias -T --arg2 @@ -7,6 +8,6 @@ test1 alias -O --arg1 test1 alias --grab --arg2 "'foo !#:+'" test1 alias --grabbar --grab bar -test1 exec --echo-args echo +test1 exec --echo-args /bin/echo test1 alias -e --echo-args test1 exec -a /bin/echo diff --git a/test1.c b/test1.c index 24e7371..a39f0cb 100644 --- a/test1.c +++ b/test1.c @@ -161,6 +161,7 @@ static struct poptOption options[] = { NULL, NULL }, { NULL, '\0', POPT_ARG_INCLUDE_TABLE, &callbackArgs, 0, "Callback arguments", NULL }, + POPT_AUTOALIAS POPT_AUTOHELP POPT_TABLEEND }; @@ -230,6 +231,9 @@ int main(int argc, const char ** argv) optCon = poptGetContext("test1", argc, argv, options, 0); /*@=temptrans@*/ (void) poptReadConfigFile(optCon, "./test-poptrc"); + (void) poptReadDefaultConfig(optCon, 1); + + poptSetExecPath(optCon, ".", 1); #if 1 while ((rc = poptGetNextOpt(optCon)) > 0) /* Read all the options ... */ diff --git a/testit.sh b/testit.sh index 1a16e47..b788edb 100755 --- a/testit.sh +++ b/testit.sh @@ -7,7 +7,7 @@ run() { echo Running test $name. - result=`$builddir/$prog $*` + result=`HOME=$builddir $builddir/$prog $*` if [ "$answer" != "$result" ]; then echo "Test \"$prog $*\" failed with: \"$result\" != \"$answer\" " exit 2 @@ -111,7 +111,7 @@ Usage: lt-test1 [-I?] [-c|--cb2=STRING] [--arg1] [-2|--arg2=ARG] [-f|--float=FLOAT] [-d|--double=DOUBLE] [--randint=INT] [--randlong=LONG] [--randlonglong=LONGLONG] [--argv] [--bitset] [--bitclr] [--nstr=STRING] [--lstr=STRING] [-I|--inc] - [-c|--cb=STRING] [--longopt] [-?|--help] [--usage]" --usage + [-c|--cb=STRING] [--longopt] [-?|--help] [--usage] [--simple=ARG]" --usage run test1 "test1 - 51" "\ Usage: lt-test1 [OPTION...] @@ -151,6 +151,9 @@ Callback arguments -c, --cb=STRING Test argument callbacks --longopt Unused option for help testing +Options implemented via popt alias/exec: + --simple=ARG simple description + Help options: -?, --help Show this help message --usage Display brief usage message" --help