3 # Exercise pmgetopt(1) functionality.
5 # Copyright (c) 2014 Red Hat.
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
16 status
=1 # failure is the default!
17 $sudo rm -rf $tmp.
* $seq.full
18 trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
20 # real QA test starts here
21 cat > $tmp.config1
<<EOF
22 # getopts: A:a:D:gh:Ln:O:p:PS:s:T:t:Z:z?
23 # Usage: [options] [[...] command [...]]
29 -P,--pmie display pmie evaluation statistics
37 -g start in GUI mode with new time control
38 -n=FILE use an alternative PMNS
39 -O=TIME initial sample time within the time window
40 -p=N port for connection to existing time control
41 -S=TIME start of the time window
42 -s=N terminate after this many samples
43 -T=TIME end of the time window
44 -t=DELTA sampling interval
46 -z set reporting timezone to local time of metrics source
49 Anything beyond "End" will simply be appended to the usage message.
54 # verify basic handling of a series of options passed in
55 echo == verify usage message generation
56 pmgetopt
--config=$tmp.config1
--usage --progname=pcp
57 echo == verify handling of
-a xxx
-h yyy
58 pmgetopt
< $tmp.config1
-- -a xxx
-h yyy
59 echo == verify handling of
-z -g --timezone TZ
60 pmgetopt
< $tmp.config1
-- -z -g --timezone TZ
62 # verify automatic generation of getopt string and all short/long opt combos
63 cat > $tmp.config2
<<EOF
64 # Usage: [options] archive
70 -d, --delay pause between updates for archive replay
71 -f=N,--fixed=N fixed output format with N digits precision
72 --origin=TIME initial sample time within the time window
73 -t=DELTA, --samples=delta sampling interval
74 -r,--raw output raw counter values (no rate conversion)
75 -s=N terminate after this many samples
76 -u non-interpolated fetching; ignores interval
77 --width set the width of each column of output
81 echo == verify usage message generation without getopt
82 opts2
="--config=$tmp.config2 --progname=pcpqa"
83 pmgetopt
$opts2 --usage
84 echo == verify handling of mixing short and long options
85 pmgetopt
$opts2 -- --delay -f 5 /a
/b
/pcplog
86 echo == verify handling of spaces and single quotes
87 pmgetopt
$opts2 -- "/a/b/pcp log" "/c/d/foo'bar"
88 echo == verify handling of an invalid option
89 pmgetopt
$opts2 -- -x /a
/b
/pcplog
91 # verify automatic generation of getopt string and extra long opt combos
92 cat > $tmp.config3
<<EOF
100 echo == verify handling of archive folios and host
/archive lists
101 opts3
="--config=$tmp.config3 --progname=pcpqa"
102 pmgetopt
$opts3 --usage
103 pmgetopt
$opts3 -- --archive-folio=20071023-08-06-36.folio