Since commit a62de618 (Build util tests properly with make check),
running 'make check' in tests/ also runs 'make check' in each of the
tests subdirectories, which builds the tests in that dir. (And the
same goes for 'make test' and 'make tests'.)
This does ensure that the tests are built before we run them, but it's
a bit strange to build the tests under 'make check', a target that
usually runs tests.
We do this in the top-level tests dir to make sure that the tests are
built, but this purpose is served by the existing 'make all' target.
So to reduce some duplication of logic, and reduce the number of
targets the subdirs need to implement, just have 'make check' depend
on 'make all', so we know the tests are built when we go to run them.
Change-Id: I2fcbe88daeeae94cd7ef7a4a8326c4b56fadee5a
Reviewed-on: https://gerrit.openafs.org/14636
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Currently, several of our tests contain logic to locate files (via
srcdir or objdir), based on the C_TAP_SOURCE/BUILD environment
variables. This logic is duplicated in several places, so consolidate
the code into a couple of new functions: afstest_src_path and
afstest_obj_path. Update all callers to use these new functions.
Change-Id: I67a5e5d7f8fd7a1edb55a45e52d877ac41f9a2ea
Reviewed-on: https://gerrit.openafs.org/14319
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Currently, a few tests use the code in tests/common/ by linking
individual object files in there in addition to the test code (e.g.
linking ../common/config.o along with superuser-t.o).
This convention makes it very obnoxious to move code around in
tests/common/, since any users need to update their link lines. It
also makes it difficult for code in tests/common/ to make use of
functions in other tests/common/ files.
To fix this, just build all of the objects in tests/common/ into a
convenience library, called libafstest_common, and link the relevant
tests against that. Link a few requisite libraries (roken, rfc3961) in
libafstest_common, so each individual test doesn't need to link
against them.
Also link the TAP library itself in libafstest_common, so tests don't
have to explicitly link against it separately. To do this, convert it
into a libtool library, libafstest_tap.la.
Change-Id: I9c031c164efee20201336edcbfaff429e1d231b7
Reviewed-on: https://gerrit.openafs.org/14318
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Every va_start call is supposed to be paired with a matching va_end
call, but 'checkList' is missing any call to va_end. This doesn't
currently seem to cause any visible problems, but add the matching
va_end to avoid potential future issues.
Change-Id: I569618823f39f4da5b1787cc49c5509d8ea37528
Reviewed-on: https://gerrit.openafs.org/14704
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Currently 'make check' always runs all tests. We can run individual
tests manually, but doing so is a bit cumbersome to do under the same
environment as 'make check', since doing so means running something
like this:
$ MAKECHECK=1 $(abs_top_srcdir)/tests/libwrap @TOP_OBJDIR@/lib \
./runtests opr/fmt util/ktime
To make it easier to run single tests introduce a way of calling 'make
check' like this:
$ make check TESTS='opr/fmt util/ktime'
Which will run the same commands as 'make check', but will run
runtests with only the specified tests, instead of running the default
list.
Some makefiles currently use a "TESTS" or "tests" variable to list
their test binaries; rename them all to "BINS" to avoid conflicting
with this new use for "TESTS" and to make our makefiles a little more
consistent.
Change-Id: I427f83be0d4571794644a97123bcd1f32427bd05
Reviewed-on: https://gerrit.openafs.org/14317
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
The SOURCE and BUILD environment variables have been changed to
C_TAP_SOURCE and C_TAP_BUILD in the new version of c-tap-harness. The
runtests command syntax has changed as well.
Convert all of the old SOURCE and BUILD environment variables to the new
C_TAP_SOURCE and C_TAP_BUILD names.
Add the required -l command line option to specify the test list.
Add the new runtests -v option to run the tests in verbose mode to make
it easier to see which tests failed.
Change-Id: I209a6dc13d6cd1507519234fce1564fc4641e70b
Reviewed-on: https://gerrit.openafs.org/14295
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Fix a few miscellaneous issues with building and running our tests in
objdir builds:
- Our C tests use -I$(srcdir)/../.. in the CFLAGS, so we can #include
<tests/tap/basic.h>. However, basic.h actually gets copied from
src/external/c-tap-harness/tests/tap/ to tests/tap/ during the
build, and so basic.h is available in the objdir, not srcdir. For
objdir builds, this causes building the tests to fail with failing
to find basic.h. Fix this to use TOP_OBJDIR as the include path
instead.
- Our 'make check' in tests/ tries to run ./libwrap; but our cwd will
be in the objdir for objdir builds, and libwrap is a script in our
srcdir. Fix this to run libwrap from the srcdir path.
- In tests/opr/softsig-t, it tries to find the 'softsig-helper' binary
in the same dir as 'softsig-t'. However, softsig-t is just a script
in the srcdir, but softsig-helper is a binary built in the objdir.
Fix this to use the BUILD env var provided by the tests wrapper, by
default.
Change-Id: Iff642613bfc88d0d7e348660dc62f59e6fa8af75
Reviewed-on: https://gerrit.openafs.org/13939
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
The return value of asprintf() is the number of bytes printed, or -1 if there
was an error allocating a large enough buffer. In the latter case, the value
of the result string is undefined, and so it cannot be counted on to be NULL.
This change fixes numerous places where the result of asprintf is checked
incorrectly (by examining the output pointer and not the return value) or not
at all.
Change-Id: I9fef14d60c096795d59c42798f3906041fb18c86
Reviewed-on: http://gerrit.openafs.org/9978
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: D Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Add the flags argument to cmd_CreateSyntax() and update all callers.
The flags argument will be used to set command options, such as
CMD_HIDDEN.
Change-Id: Ia51be9635f262516cb084d236a9e0756f608bf16
Reviewed-on: http://gerrit.openafs.org/11430
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Return of an exit status of zero when running commands with -help,
instead of returning an error. By general convention, and in
previous versions, tools do not not treat -help as an error.
The AFS::Command perl modules, use -help as an introspection
technique, and fail when commands run with the -help option returns
non-zero.
Change-Id: I6ecd95f6ccd07218a2657dbb4dbf1c13599159f4
Reviewed-on: http://gerrit.openafs.org/8087
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Create a pthreaded version of libafsutil, named liboafs_util.la,
and use this library in all of the pthreaded binaries that we build,
replacing both inclusion of libafsutil.a, and direct compliation of
pthreaded versions of the util source files.
libafsutil.a is provided for legacy LWP applications, and the
convenience library libafsutil_pic.a remains until we address the way
in which the user space cache manager is built and linked.
Change-Id: Ibdc3d6e2fe56ca6f5b882cf03991d1a2e32c62b2
Reviewed-on: http://gerrit.openafs.org/8056
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Convert the libcmd and libcmd_pic libaries to being built using
libtool. Historically, these have been built as LWP code, but they
have no LWP dependencies, and no LWP-specific code within them. So,
make cmd a pthread-only library.
In addition to the libtool library liboafs_cmd.la, we build the
legacy libcmd.a and libcmd_pic.a as convenience libraries. libcmd64.a
(a 64bit variant, used solely by kdump), remains built through
"normal" means.
Update pthreaded users of libcmd to use the new liboafs_cmd.la. For
now, non-pthreaded users are left alone.
Change-Id: Id8445949754d1942f6e8752ae182b4e6f86fe94f
Reviewed-on: http://gerrit.openafs.org/8055
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Convert the libafs_comerr library so that it uses libtool.
comerr uses a pthread lock to protect the error tables, so it needs
to be built as both an LWP, and a pthread library (previously, we've
just built it as LWP, which is probably broken on some platforms, as
it won't define -D_REENTRANT)
libafscom_err.a remains as the LWP variant, and all pthreaded code is
modified to use the libtool liboafs_comerr.la library.
Change-Id: Id421cc97ad8681b42af7a5eb3cb512e1e1ce9a90
Reviewed-on: http://gerrit.openafs.org/8054
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: Derrick Brashear <shadow@your-file-system.com>
Convert opr so that it uses libtool. For backwards compatibility we
still build libopr.a, but we do so as a static convenience library.
As libopr.a may, in the future, be converted to an LWP library, change
all of the pthreaded binaries so that they link against the libtool
library liboafs_opr.la
Change-Id: Icee04ff4745334f06ffba16df5bb07fc9dcc0b54
Reviewed-on: http://gerrit.openafs.org/8034
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
Fix the configuration file path for the cmd test so that it works
when invoked from runtests
Change-Id: Id7d717e163abf5cfab2d551aaf08fb9967a87153
Reviewed-on: http://gerrit.openafs.org/7576
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
With this change, we gain the ability to set our command line options
from krb5.conf configuration files. This is only available for tools
which are implemented using the new cmd_OptionAs accessor methods.
Callers should load their configuration file using
cmd_OpenConfigFile("/path/to/config/file.conf");
(an addition to libauth to return a path to a system wide
configuration file will be forthcoming)
and then set their command name (for example, "fileserver", "afsd",
"vos" and so on) using
cmd_SetCommandName("mycommand");
The accessor functions will then populate their return values with
either:
a) The command line options, if specified
b) The contents of the tag matching the option name, in the
[command_subcommand] section of the configuration file, if it
exists
c) The contents of the same tag, in the [command] section of the
configuration file, if it that exists.
d) The contents of the same tag in the [defaults] section of the
configuration file.
Callers can also gain access to the entire configuration file by
calling cmd_RawFile, or to just the section corresponding to their
command line by calling cmd_RawSection. Note that when using the file
directly, it is up to callers to preserve consistency by implementing
similar inheritance rules as the above.
Change-Id: Ic501ab296af3638f961486869af79c9ce47b77b8
Reviewed-on: http://gerrit.openafs.org/7135
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Add additional tests to the libcmd test suite to verify the
behaviour of cmd_OptionPresent and cmd_OptionAsList
Change-Id: I81a235fb5ee87682c72ca942f1341f77be6fda39
Reviewed-on: http://gerrit.openafs.org/7392
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Instead of bundling our own copies of Russ's C TAP Harness, start using
source pulled from his git repository using the src/external import
mechanism. Note that we are not currently building the floating
point (is_double) portion of the harness.
In the process of doing so, we also upgrade our test harness to the latest
upstream version, 1.11. This is somewhat problematic, as there have been
some significant code changes since the version bundled with OpenAFS.
Work around these by
*) Referencing the basic.h header as <tests/tap/basic.h>, rather than
just <tap/basic.h>, to match the new upstream layout
*) Changing the include path so that the tests/ directory can be
found within it.
Change-Id: I63efbb30248165e5729005b0a791e7eb7afb051d
Reviewed-on: http://gerrit.openafs.org/7374
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Russ Allbery <rra@stanford.edu>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Change the command test so that it uses an enum, rather than #defines
for offsets into the parms array. This is mainly a cosmetic change, but
brings the test suite into line with the way that we're doing stuff in
the "real" code.
Change-Id: Ia9d72e13230edd4fe13af52ba6816cf775693c36
Reviewed-on: http://gerrit.openafs.org/7133
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Tom Keiser <tkeiser@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
The cmd/command-t test needs libopr, so give it to it
Change-Id: I74ca08efffb0c0f6245498c9dc0dcf5287915bbd
Reviewed-on: http://gerrit.openafs.org/6949
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Fix a build error in the cmd tap tests.
Change-Id: I757c5b508784fd938b70ca3829130275707dd39a
Reviewed-on: http://gerrit.openafs.org/4975
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Sometimes, when adding a new command parameter, it's necessary to
prevent it from colliding with an existing abbreviation. This patch
adds a new command flag CMD_NOABBRV which can be set on a parameter
to indicate that it should not be considered when checking for
ambiguous abbreviations.
For example, if a command has the existing '-cell' option which is
popularly abbreviated to '-c', adding a '-config' option would
cause the existing abbreviation to stop working. However, if '-config'
is added with the NOABBRV flag set, '-c' will continue to work.
Change-Id: I3b6d718f9dd81c44fb1d10c904db6a4a0fd763b8
Reviewed-on: http://gerrit.openafs.org/4810
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reorder the arguments of this recently introduced function to
make client code more readable.
Change-Id: I37f662f849bd96176230f75783e2a1c62d94b8c9
Reviewed-on: http://gerrit.openafs.org/4755
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Move the -flag parameter to be the first parameter, to test more of
the positional argument handling.
Change-Id: I637c58e8c76bfc23919f29a1c598084275426773
Reviewed-on: http://gerrit.openafs.org/4710
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
The cmd_OptionAsString function attempts to free the previous value
of the string passed to it. Make sure that we initialise the return
value to NULL before passing it in in the test suite.
Change-Id: I8500d5e6812f4d1655fc50618db472c745604e41
Reviewed-on: http://gerrit.openafs.org/4653
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
The cmd/command-t test requires libroken and was misspelled in the
TESTS file. Multiple tests require LD_LIBRARY_PATH to be set to find
libafsroken if it hasn't been installed, so set it when running
runtests via make check. (Note that this means runtests -o will not
work properly unless the user also sets LD_LIBRARY_PATH.)
Change-Id: Ib64f0505b3b75db33adb6c7b6452dcaac0b05dbc
Reviewed-on: http://gerrit.openafs.org/4594
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Some of our code uses arguments of the form -name=value. Add support
to libcmd for dealing with this type of argument, where name is
declared as CMD_SINGLE (or CMD_SINGLE_OR_FLAG)
Change-Id: Ifb7486abc4f6bf26594936ef11749c4fe29a2e9b
Reviewed-on: http://gerrit.openafs.org/4547
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tidy up the output that comes from cmd's -help option by wrapping
at 78 characters, and picking the breaks sensibly. This changes:
Usage: ./vos move -id <volume name or ID> -fromserver <machine name on source> -
frompartition <partition name on source> -toserver <machine name on destination>
-topartition <partition name on destination> [-live] [-cell <cell name>] [-noau
th] [-localauth] [-verbose] [-encrypt] [-noresolve] [-help]
to...
Usage: ./vos move -id <volume name or ID>
-fromserver <machine name on source>
-frompartition <partition name on source>
-toserver <machine name on destination>
-topartition <partition name on destination> [-live]
[-cell <cell name>] [-noauth] [-localauth] [-verbose]
[-encrypt] [-noresolve] [-help]
Change-Id: I494c287a9370d052763b464df33e69a936edef71
Reviewed-on: http://gerrit.openafs.org/4546
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add the CMD_SINGLE_OR_FLAG option which permits a parameter to
either have a single value, or no value at all. If it has no value,
then it behaves in the same way as the current 'flag' implementation.
Change-Id: I49cf313f1d3b9c369f87b1ff66bfcc038b8aa08a
Reviewed-on: http://gerrit.openafs.org/4545
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add support for adding aliases for parameters, in the same way as we
can for syntaxes. This allows multiple different names for a single
option, as well as providing a way around problems with abbreviations.
Aliases may not be abbreviated.
Change-Id: I5c440cf006cd5fd0065ecf1e54213745428063f7
Reviewed-on: http://gerrit.openafs.org/4544
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add a load of accessor functions to help with pulling values out
from the the cmd_syndesc structure. The idea here is to make it
simpler to manipulate command line values, as well as starting to
hide the structure of the cmd_syndesc structure from callers, with
a view to eventually making it private to the cmd library.
Change-Id: I38757d776364ceacd43e98fda16e995da35da65c
Reviewed-on: http://gerrit.openafs.org/4543
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Rather than having to use cmd_Seek, followed by cmd_AddParam,
followed by another cmd_Seek, add a function which permits parameters
to be added at specific reference points. This allows programs to
declare a list (either as an enum or specific #defines) of parameter
code points, rather than using raw numbers.
Change-Id: I25c0d501e678aa2818d296c776d8c5d03b8cdabe
Reviewed-on: http://gerrit.openafs.org/4542
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Split up the command line parsing behaviour out of the cmd_Dispatch
function, and into a function of its own - cmd_Parse. This lets servers
which only have a single "syntax" installed just parse, without needing
to go through a dispatch function, and all of the control flow
complexity that requires.
Change-Id: Ic4325bf933ee5b28cb80db36ef9b2b5fb6763f41
Reviewed-on: http://gerrit.openafs.org/4541
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add an option to completely disable the matching of abbreviations
when parsing command line options.
Change-Id: Ic3babf584c21f389503c9c69670d400d54a6f4a6
Reviewed-on: http://gerrit.openafs.org/4540
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add a new cmd_DisablePositionalCommands function which can be used
to completely disable positional commands, for functions which have
no desire to make use of them.
Change-Id: I5646e9976e544f06902ea6f85043a6330b1ac2fe
Reviewed-on: http://gerrit.openafs.org/4539
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add some tests for the command library to the integrated test
suite in tests. These are far from complete, and are mainly there
to ensure that we don't break any of this functionality when modifying
the library.
Change-Id: Ib6fbdca114c005c32c5ba8c41f9e350ca67e1fb8
Reviewed-on: http://gerrit.openafs.org/4538
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>