Commit Graph

41 Commits

Author SHA1 Message Date
Andrew Deason
e07768aaf7 tests: Introduce afstest.pm
Create a perl module for some generic common code for our tests
written in perl: afstest.pm. With this commit, the module just
contains a couple of functions to calculate paths in our src and obj
trees (src_path(), obj_path()), analogous to afstest_src_path and
afstest_obj_path in our C helper library, libafstest_common.la.

Convert all existing perl test code that uses C_TAP_SOURCE/C_TAP_BUILD
to use these new functions.

Change-Id: I5e4d45e3d2d59449bbfc426476cb29b710c73bc1
Reviewed-on: https://gerrit.openafs.org/14800
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
2021-10-03 17:55:18 -04:00
Andrew Deason
41dd504fe1 tests: Remove check/test/tests subdir targets
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>
2021-08-26 10:29:57 -04:00
Andrew Deason
405001be72 tests: Introduce libafstest_common
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>
2021-08-07 20:38:05 -04:00
Andrew Deason
004c797daa tests: Introduce 'make check TESTS=test/name'
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>
2021-06-11 05:18:49 -04:00
Michael Meffie
624219a1b2 tests: Accommodate c-tap-harness 4.7
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>
2020-08-20 22:36:56 -04:00
Andrew Deason
df5480057c tests: Skip SIGBUS test on FreeBSD
Currently, 'softsig-helper -buserror' causes a SIGBUS on most
platforms, but can result in SIGSEGV on FreeBSD by default (at least
on 11.3-RELEASE). Skip the test on FreeBSD, until we can provide a
more reliable way to generate SIGBUS.

Note that when the sysctl machdep.prot_fault_translation is set to 1,
'softsig-helper -buserror' generates a SIGBUS instead of SIGSEGV,
suggesting that generating a SIGBUS here is the old 'compat' behavior.
When machdep.prot_fault_translation is 0 (the default), the code path
in the FreeBSD kernel that dictates whether to send a SIGBUS or
SIGSEGV in this situation depends on some autodetection heuristics,
and so may produce different results depending on FreeBSD releases or
even compiler settings (due to detection of ABI based on some ELF
notes in the relevant binary).

For some details on this sysctl, see
<https://www.freebsd.org/news/status/report-2019-07-2019-09.html#Signals-delivered-on-unhandled-Page-Faults>
or the FreeBSD source code. In 11.3-RELEASE, the decision to issue a
SIGBUS or SIGSEGV can be found around sys/amd64/amd64/trap.c:355.

Change-Id: Ib75b43cc12302532ee87a3744fc364424f2a3ca6
Reviewed-on: https://gerrit.openafs.org/14145
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2020-04-26 17:35:35 -04:00
Andrew Deason
1bd03c9c22 tests: Run perl via 'env'
The 'perl' binary may not be /usr/bin/perl, depending on the system.
For example, on modern FreeBSD it tends to be /usr/local/bin/perl
instead.

To avoid relying on perl to be in a specific location, just run via
/usr/bin/env instead, so we pick up perl from $PATH instead.

Change-Id: Ic8dc247c82342ff79dfa80426c489ccb8e3e1450
Reviewed-on: https://gerrit.openafs.org/14144
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2020-04-17 20:12:42 -04:00
Andrew Deason
19524a49d4 opr: Allow non-2^x for n_buckets in opr_cache_init
Currently, opr_cache_init requires that opts->n_buckets is a power of
2 (since our underlying opr_dict requires this). However, callers may
want to pick a number of buckets based on some other value. Requiring
each caller to calculate the nearest power-of-2 is annoying, so
instead just have opr_cache_init itself calculate a nearby power of 2.

That is, with this commit, opts->n_buckets is allowed to not be a
power of 2; when it's not a power of 2, opr_cache_init will calculate
the next highest power of 2 and use that as the number of buckets.

Change-Id: Icd3c56c1fe0733e3dac964ea9a98ff7b436254e6
Reviewed-on: https://gerrit.openafs.org/14122
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2020-04-10 09:55:35 -04:00
Cheyenne Wills
d369f4e5c9 tests: Add cache-t to .gitignore in tests/opr
Commit 48fbb45 (opr: Introduce opr_cache) added a new test (cache-t),
but did not update the .gitignore file for it.

Change-Id: I6de6130257a62f495ac942c05937eb109ce84a75
Reviewed-on: https://gerrit.openafs.org/14102
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2020-03-20 15:56:54 -04:00
Andrew Deason
48fbb45967 opr: Introduce opr_cache
Add a simple general-purpose in-memory cache implementation, called
opr_cache. Keys and values are simple flat opaque buffers (no complex
nested structures allowed), hashing is done with jhash, and cache
eviction is mostly random with some LRU bias.

Partly based off a different implementation by
mbarbosa@sinenomine.net.

Change-Id: I16b5988947ff603dfe31613cd7be3908a69264e5
Reviewed-on: https://gerrit.openafs.org/13884
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2020-03-06 11:57:51 -05:00
Andrew Deason
f4ab3767b7 tests: Fix most tests for objdir builds
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>
2019-12-13 00:03:21 -05:00
Anders Kaseorg
5151c03351 opr: Make opr_jhash_opaque consistent with opr_jhash
Change-Id: I42e1030f8c841dcb974476012a774b91c87d3fb0
Reviewed-on: https://gerrit.openafs.org/12494
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-12-22 15:59:31 -05:00
Anders Kaseorg
93a7e754a4 tests/opr/softsig-t: Avoid hanging due to intermediate sh -c
If the build directory happened to contain shell metacharacters, like
the ~ in /build/openafs-vb8tid/openafs-1.8.0~pre1 used by the Debian
builders, Perl was running softsig-helper via an intermediate sh -c,
which would then intercept the signals we tried to send to
softsig-helper.  Use the list syntax to avoid this sh -c.

Change-Id: I054b9c8f606e197accb414bfe3f89719255c62c4
Reviewed-on: https://gerrit.openafs.org/12488
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-12-21 00:17:47 -05:00
Michael Meffie
8b2c4665aa tests: fix signo to signame lookup in opr/softsig tests
Fix the loop condition when scanning the signal number to name table to
convert a signal number to a name.  Instead of looping sizeof(size_t)
times, loop for the number of elements in the table.

This bug was masked on 64 bit-platforms, since the signal number to name
table table currently has 8 elements, which is coincidently the same as
sizeof(size_t) on 64-bit platforms.  The bug becomes apparent on 32-bit
systems; only the first 4 elements of the table are checked.

Example error output before this fix:

    $ cd tests
    $ ./libwrap ../lib ./runtests -o opr/softsig
    1..11
    ok 1
    ok 2
    ok 3
    ok 4
    ok 5
    not ok 6
    # Failed test in ./opr/softsig-t at line 57.
    # got: 'Received UNK
    # '
    # expected: 'Received TERM
    # '
    not ok 7
    # Failed test in ./opr/softsig-t at line 60.
    # got: 'Received UNK
    # '
    # expected: 'Received USR1
    # '
    not ok 8
    # Failed test in ./opr/softsig-t at line 63.
    # got: 'Received UNK
    # '
    # expected: 'Received USR2
    # '
    ok 9 - Helper exited on KILL signal.
    ok 10 - Helper exited on SEGV signal.
    ok 11 # skip Skipping buserror test; SIGBUS constant is not defined.
    # Looks like you failed 3 tests of 11.

Change-Id: I863cc9f3650c4a5e9ac9159d90e063b986a8460a
Reviewed-on: https://gerrit.openafs.org/12367
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-12-16 15:20:39 -05:00
Michael Meffie
c0876aa6b5 test: skip buserror test when SIGBUS is not defined in perl POSIX module
Older versions of the perl POSIX module do not define the SIGBUS symbol, which
causes the opr/softsig-t perl test to fail to compile.  Instead of trying to
defined SIGBUS, which may be platform dependent, skip the buserror unit test on
these older platforms.

Change-Id: Ib8cfd77215ea43566e9d47b501d4989556b83734
Reviewed-on: http://gerrit.openafs.org/12186
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-02-10 23:47:52 -05:00
Marcio Barbosa
c38382c127 tests: give the full path to the softsig test helper program
In order to start the softsig test helper properly,
the full path of this program is necessary.

FIXES 132246

Change-Id: I4e9ff1e62a0b82078338eeaf0d4368ac1b35dccc
Reviewed-on: http://gerrit.openafs.org/11977
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-08-26 10:54:50 -04:00
Anders Kaseorg
5a0603ced2 tests/opr/jhash-t.c: Fix unsigned constant warning
Resolves this warning on 32-bit GCC:

jhash-t.c: In function ‘main’:
jhash-t.c:60:4: warning: this decimal constant is unsigned only in ISO C90
    is_int(3704403432, opr_jhash(test, 2, 0),
    ^
jhash-t.c:62:4: warning: this decimal constant is unsigned only in ISO C90
    is_int(3704403432, opr_jhash_int2(test[0], test[1], 0),
    ^

Change-Id: Ie3ab0f5aacdc719fa63f32e545b5863ec351f5eb
Reviewed-on: http://gerrit.openafs.org/11961
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-08-02 21:59:41 -04:00
Anders Kaseorg
ac39d879f8 tests/opr/time-t.c: Use labs instead of abs for long argument
Resolves this warning with clang:

time-t.c:46:8: warning: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause
      truncation of value [-Wabsolute-value]
    ok(abs(osTime - osNow) < 2, "opr_time_Now returns a reasonable value");
       ^
time-t.c:46:8: note: use function 'labs' instead
    ok(abs(osTime - osNow) < 2, "opr_time_Now returns a reasonable value");
       ^~~
       labs

Change-Id: Ib98069e1349161d936c8ada0e69f9b33d2f71ce3
Reviewed-on: http://gerrit.openafs.org/11965
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-08-01 23:05:26 -04:00
Michael Meffie
73e080cbb0 tests: fix typo in softsig test helper
Change-Id: I74183a04b54b70bf3593a53fdb5f164cbd6c3b98
Reviewed-on: http://gerrit.openafs.org/11893
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-06-20 21:09:25 -04:00
Simon Wilkinson
cb0081604e opr: Add new softsig implementation
Signals and pthreaded applications are a poor match. OpenAFS has had
the softsig system (currently in src/util/softsig.c) in an attempt to
alleviate some of these problems. However, that implementation itself
has a number of problems. It uses signal functions that are unsafe in
pthreaded applications, and uses pthread_kill within its signal
handlers. Over the years it has been responsible for a number of
portability bugs.

The old implementation continues to receive signals in the main thread
of the application. However, the handler code is run within a seperate
signal handler thread. When the main thread receives a signal a stub
handler is invoked, which simply pthread_kill()s the signal handler
thread.

The new implementation simplifies things by only receiving signals in
the handler thread. It uses only pthread-compatible signal functions,
and invokes no code from within async signal handlers.

A complete test suite is supplied.

Change-Id: I4bac68c2f853f1e7578b54ddced3833a97dd3f82
Reviewed-on: http://gerrit.openafs.org/6947
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Daria Brashear <shadow@your-file-system.com>
2015-05-26 14:06:18 -04:00
Benjamin Kaduk
81a1a53a36 Clean up our cleaning
'make clean' and 'make maintainer-clean' still leave around a fair
number of droppings, prior to this commit.

We were not descending into the 'tests' top-level directory while
cleaning.  Furthermore, tests/opr/Makefile needed $(LT_CLEAN), and
tests/rx/Makefile needed to spell it correctly.

The libtoolization places a lot of files to be removed in the
'pristine' target.

The processing used to implement the =include directive in the pod
sources for the man pages leaves around the non-.in versions of
files; we should clean that up in the 'pristine' target as well.

The 'pristine' target should likewise remove the man pages which
are generated from the pod files.

Additionally, the documentation build uses a Doxyfile which is
output by configure; that should be removed (if present) by the
'distclean' target.

When hcrypto was converted to libtool, the use of ${OBJECTS} in
the clean target was missed, so we were leaving around most of the
actual object files -- $(LT_CLEAN) does not handle this for us.
Change the rule to remove *.o as is done elsewhere.

The conversion of libafsrpc to libtool added a convenience library
libafsrpc_sys.la, and changed how syscall.o was generated on
most architectures, to be the result of compiling an empty .c file
(instead of just an empty .o file).  This introduced a new
intermediate file, syscall.c, which must be cleaned up.

tvolser was only listing volserver and not vos in its list of
executables to remove while cleaning.

The conversion of venus/test to libtool was not done quite right.
Makefile.libtool and the .lo suffix are only needed when libtool
is being used to link *libraries*; just Makefile.pthread suffices
when libtool is being used to link executables.  As such, remove
the inclusion of Makefile.libtool, and change the .lo targets back
to regular .o ones, and add back *.o to the list of files to remove
in the 'clean' target (it was needed there even without the
other changes to that Makefile).

Change-Id: Ifbc3eee4ad2dce54df991301bc5edd11eb29a24a
Reviewed-on: http://gerrit.openafs.org/11532
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2014-11-28 18:04:15 -05:00
Andrew Deason
96e001088c tests: Fix fmt-t.c warning
'main' in fmt-t.c was declared as a prototype-less function, which
triggers a warning, which is an error with --enable-checking. Fix it
by declaring 'main' properly.

Change-Id: I45cfec591acd0ef8d7836c79e997e8ffe29b9e38
Reviewed-on: http://gerrit.openafs.org/11539
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Nathaniel Filardo <nwfilardo@gmail.com>
2014-11-05 08:39:25 -05:00
Benjamin Kaduk
bcf3d33f28 Add missing tests to tests/opr/.gitignore
dict-t and fmt-t were missing.

While here, sort the existing entries.

Change-Id: If62e0f9f93f4d51900cdd7747beede561861f51e
Reviewed-on: http://gerrit.openafs.org/11454
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2014-09-10 11:13:21 -04:00
Nathaniel Wesley Filardo
f4ab11a8dd Add a small string formatting utility to opr
This is to be used by the (coming next) vos-foreach utility, but it seemed
sufficiently general and useful to break out into its own free-standing
component.

Change-Id: I92c3a615fecb80e1766f78492b229a826a23e18a
Reviewed-on: http://gerrit.openafs.org/10965
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: D Brashear <shadow@your-file-system.com>
2014-05-21 07:22:41 -04:00
Jeffrey Hutzelman
21d8df0432 Make opr_uuid_toString return a status
Don't assume that converting a UUID to a string will always succeed.
Instead, opr_uuid_toString should return a status result to indicate
whether the operation was successful or not.

Change-Id: I49e6bf53b2a878342d3137510d2eca522e58604d
Reviewed-on: http://gerrit.openafs.org/9990
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-06-21 11:17:48 -07:00
Simon Wilkinson
b28c51d594 opr: Don't confuse isLast and isEnd
opr_queue_IsEnd's implementation was incorrect - it would return
true when the element was the last item in the list, not when it
was the end of the list (equal to the head record)

Correct the implementation of isEnd, and add an implementation for
isLast.

This fixes a bug in RX, wher we would never notice that the last
packet in the transmit queue was acknowledged, because the loop that
iterates over the queue uses isEnd to detect when its work is done.

Change-Id: I8966e05c479c18d025bb5cc4cf77514ce002be95
Reviewed-on: http://gerrit.openafs.org/8493
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2012-11-23 06:18:31 -08:00
Simon Wilkinson
5be3cdc3f3 opr: Add dictionary implementation
Add a simple implementation of a dictionary/hash structure based around
opr queues and the jhash hashing function.

Change-Id: I4ae5cafcef377b05c8caa7c455737a992b1d36cd
Reviewed-on: http://gerrit.openafs.org/8355
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2012-11-01 12:18:01 -07:00
Simon Wilkinson
07372cf7e7 opr: Add opr_jhash_int2 function
Add a function to jhash that can be used to hash a pair of unsigned
integers (or other stuff that can cast to them) without having to build
up an array.

Provide a couple of tests for the new function

Change-Id: I594848f64316fb459eff565933691f560512ca79
Reviewed-on: http://gerrit.openafs.org/8354
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2012-11-01 11:30:20 -07:00
Simon Wilkinson
dca06bd104 tests: Convert opr tests to use libtool
Avoid the problems with libopr's dependencies by just converting
the tests to use the libtool version of the opr library. While we're
at it, make the tests pthreaded too.

Change-Id: I4e570b288ea57c758c848be1d545e5ee59771ab9
Reviewed-on: http://gerrit.openafs.org/8127
Reviewed-by: Jason Edgecombe <jason@rampaginggeek.com>
Tested-by: Jason Edgecombe <jason@rampaginggeek.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2012-09-16 13:35:16 -07:00
Derrick Brashear
fe2641e35b tests: deal with one more unsigned warning
C90 wants this unsigned hint before it will dtrt

Change-Id: Ic60b0336df7e8c4373582ffa352f4042ebc021c1
Reviewed-on: http://gerrit.openafs.org/8050
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: Derrick Brashear <shadow@your-file-system.com>
2012-09-06 21:31:56 -07:00
Marc Dionne
d77a99106d tests/opr: fixes for the uuid-t.c tests
It's always good to have a plan.

Also, use correct mask when checking for DCE bit.

Change-Id: I4ab72aeb89efbd63d2d15fdc57aea8d2c1eb13d9
Reviewed-on: http://gerrit.openafs.org/8047
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: Derrick Brashear <shadow@your-file-system.com>
2012-09-06 04:45:59 -07:00
Derrick Brashear
97dfe2b73c tests: modernize tests to compile in warning-as-errorland
the tests haven't been loved as we've been killing warnings. clean up.

Change-Id: I9c36114d3172c4a6347f5e890df6edb5caf796b4
Reviewed-on: http://gerrit.openafs.org/7232
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2012-09-06 04:43:30 -07:00
Simon Wilkinson
3bb8e4c396 opr: Add opr_jhash_opaque
Add a function which can be used to obtain a hash of an arbitrary
opaque string of arbitrary length

Change-Id: I9e6aa29fa06a54976b81eda399c8838b73007962
Reviewed-on: http://gerrit.openafs.org/7978
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2012-08-14 13:48:44 -07:00
Simon Wilkinson
6f6bfb31ac opr: Add UUID handling functions
Add a set of functions to the opr library to handle creating and
manipulating UUIDs.

The opr_uuid_t type is held as a 16 octet character string, which
comprises the UUID encoded into network byte order. This is the
primary form for manipulating UUIDs with this library, as it avoids
any nbo/hbo problems.

For applications which require raw access to the UUID components,
the opr_uuid_unpacked structure is provided, and
opr_uuid_pack/opr_uuid_unpack can be used to convert to and from
this format.

Finally, functions to print the UUID as a string, and parse a UUID
from a string, are provided. When printing, we use the standard UUID
format of 000000-0000-0000-0000-00000000. However, the afsUUID library
used to print UUIDs as 000000-0000-0000-00-00-00000000, so we also
accept this format.

Change-Id: I78ef79b7ab8ae15fb955c6495118722875c94f8d
Reviewed-on: http://gerrit.openafs.org/7977
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
2012-08-14 12:53:08 -07:00
Simon Wilkinson
4660b53e69 opr: Add simple time type
Add a simple time type to the opr library, which provides helper
routines to implement the 100ns time format selected for on-the-wire
use for AFS-3 (this also provides a handy single integer internal
time format)

Change-Id: I1f2d81e61a3e4124e0dd49830a115b72d7a7b37f
Reviewed-on: http://gerrit.openafs.org/7559
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
2012-06-14 15:23:02 -07:00
Simon Wilkinson
c877c0b419 tests: Start using the upstream C TAP harness
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>
2012-05-11 16:36:44 -07:00
Simon Wilkinson
4188865670 Update .gitignore files
Update (and create) .gitignore files across the tree

Change-Id: I7534e4f1eac44e6024f86591a171b63a64c6f320
Reviewed-on: http://gerrit.openafs.org/7241
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
2012-04-18 20:26:54 -07:00
Simon Wilkinson
20448059f0 opr: Add Bob Jenkins's hash functions
This imports a small subset of Bob Jenkins lookup3.c hash functions
into the opr library. At present we only import the subset of this
that deals with aligned arrays of integers, as this addresses our
immediate need.

It seems likely that if we're interested in a hash function for string
arrays (or other arbitrary data), that more recent functions such like
SpookyHash (from Bob Jenkins, again) or CityHash (from Google) may be
a better solution.

The immediate use case for this is removing the use of the '%' operator
when indexing speed critical hash tables, as well as ensuring fairer
distribution of entries across these tables.

A short set of test cases is also provided

Change-Id: I0ae26382e77da02204a30a95747f7d6de8c4f24a
Reviewed-on: http://gerrit.openafs.org/6095
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
2011-11-21 07:45:14 -08:00
Simon Wilkinson
5574ff814f opr: Add a red/black tree implementation
Add an implementation of red/black trees to our runtime library.

This is originally derived from the FreeBSD macro-based rbtree
implementation, but is heavily reworked to not use macros, to improve
legibility, and to favour speed over structure compactness.

A test suite is provided in tests/opr/

Change-Id: I123209d3f89b5f8c1b85d1e5cd7d1d650ccc68ed
Reviewed-on: http://gerrit.openafs.org/5838
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
2011-11-12 06:48:17 -08:00
Michael Meffie
9c130285d8 opr: queue swap
Add inline function to pivot two queues.
Implementation by Simon Wilkinson.

Change-Id: I704a1ff3e0d6314e2bfe47c870226cb6ffd44b1b
Reviewed-on: http://gerrit.openafs.org/5742
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
2011-11-03 13:12:06 -07:00
Simon Wilkinson
55efff93fe opr: Move queue header out of util
Move the header which is installed as opr/queues.h out of util/ and
into the new, top level, opr/ directory. Similarly move the tests out
of the util/ test suite, and into the opr/ tests

Change-Id: I81af487f09e1f0f4b25654a1f64c5ac75fd5a95b
Reviewed-on: http://gerrit.openafs.org/5656
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
2011-10-23 16:11:05 -07:00