Speedup breakdancer ~10x by splitting into 10 seperate suites

memcached-breakdancer-engine-tests currently takes ~4 minutes to
run. To allow it to complete in a faster wallclock time, split it into
10 seperate suites with a shared library for each, and run each one as
it's own test.

This reduces the wallclock time down to ~30s (with
CTEST_PARALLEL_LEVEL=8).

Change-Id: Ib72e8a513e7a198d10908747c346d133b6355bcd
Reviewed-on: http://review.couchbase.org/42669
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
MB-12451 mcd leak when socket closes during read

Move the code which requires engine release to be
before the place we tear down the engine reference.

Change-Id: Ib4da63b25a2f1098969bd8bab804012ba1ef325a
Reviewed-on: http://review.couchbase.org/42472
Reviewed-by: Jim Walker <jim@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Remove superfluous "binary"

Change-Id: I637d576081c47c94dcc276c59ac4895d978de78f
Reviewed-on: http://review.couchbase.org/42703
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>
Introduced separate command for reloading audit config file

Change-Id: Ifd803e36534ec05366bc7d60c02cea2e7ad0227d
Reviewed-on: http://review.couchbase.org/42712
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Run SASL code as part of the tests

Change-Id: I383da9535590a79b26f800e03e8768ea454a8241
Reviewed-on: http://review.couchbase.org/42704
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Refactor: streamline sasl auth

Let the SASL AUTH/STEP code follow the generic packet
handling code.

Change-Id: If26df8e326a016a83c7b4e4ca230fc3f07b38a6e
Reviewed-on: http://review.couchbase.org/42709
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Verify that port numbers in cfg are unique

memcached uses the port number of an interface to uniquely identify
that interface. If a user attempts to configure two interfaces on the
same port (including port 0 for 'any available') then memcached's
connection management quickly breaks.

Therefore add a check that the port for an interface is unique.

Change-Id: I70b6ce0ea1a98e37d794de75b9b96b0f6d720cbe
Reviewed-on: http://review.couchbase.org/42714
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Speedup memcached_testapp by splitting into plain and SSL

Add a new argument to memcached_testapp : plain/SSL. This allows each
half to be tested in parallel, speeding up the wallclock runtime (if
CTEST_PARALLEL_LEVEL is used).

Change-Id: Ic9bde8f36ce60c53ccfd507e8c93ba40f87abf42
Reviewed-on: http://review.couchbase.org/42715
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Remove unneeded #ifdefs

Change-Id: If5d75f509414d5511ab54f5e30f98794871ba15d
Reviewed-on: http://review.couchbase.org/42747
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Add standalone program to operate on buckets

As part of project Tynset we need to be able to test lots of
buckets isolated with memcached (without having to run the
entire cluster) to monitor the internal resource usage. This
program may be used to create/delete/list buckets.

Change-Id: Iac39a648f7596a937bcac0e0f9d93cd25b97dad4
Reviewed-on: http://review.couchbase.org/42740
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Use cb_mktemp instead of mktemp

Using mktemp emits compiler warning on some systems.

Change-Id: I8f409b8863fbedd44f34489214f991372d0673b2
Reviewed-on: http://review.couchbase.org/42786
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Include strings.h for strcascmp() (win32 breakage)

Change-Id: Ic29ed91564310da4a9dd72d5a40a1368c115fccf
Reviewed-on: http://review.couchbase.org/42830
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Enable config_parse test for win32

Change-Id: Ib624a292b45238472b328df41bfae1ff031a1e56
Reviewed-on: http://review.couchbase.org/42831
Tested-by: buildbot <build@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
tcmalloc_test: Expand memory alloc functions tested, work with optimized build.

Expand to test that all the memory allocation functions used by
memcached are correctly tracked using mem_used. Also update tcmalloc_test
to work with optimized build:

- Change assert() to cb_assert()

- alloc_size is accessed from multiple thread so make atomic.

- Store return value from malloc() in a non-local variable to prevent
  compiler dead-code elimination from eliding calls to malloc/free.

Change-Id: Id2c17652fa50cd215eab560877165a4efffea099
Reviewed-on: http://review.couchbase.org/42520
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Removed index-out-of-bound error

Change-Id: I505a9e45c94fa7e6d512bc0f0ea113630ec6aad6
Reviewed-on: http://review.couchbase.org/43019
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Use cb_assert instead of assert

Change-Id: I0762e223e0f6e25134bf15999ff03dad17d0f176
Reviewed-on: http://review.couchbase.org/43020
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Check return value from asprintf

Otherwise gcc outputs warnings:
ignoring return value of asprintf, declared with attribute
warn_unused_result [-Wunused-result]

Change-Id: Ib43af5d5faf2cff527146b0f315c5146d693ed07
Reviewed-on: http://review.couchbase.org/43044
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
MB-12067 [jemalloc/Linux]: Implement mem_used tracking using wrapper functions

To be able to track mem_used we need to invoke callbacks whenever
memory is new'd or delete'd. The current allocator (TCMalloc) provides
hooks itself, but jemalloc does not, therefore (for Linux) we create
our own wrapper functions for malloc/calloc/realloc/free and get them
to invoke the hooks, as well as calling into jemalloc to perform the
actual memory (de)allocation.

Change-Id: I3b055f84be569fff43b81877b9ad18cbc67dfb2b
Reviewed-on: http://review.couchbase.org/42522
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-12608: Enable tcmalloc.aggressive_memory_decommit by default

Enable TCMalloc's 'aggressive decommit' mode by default.

Change-Id: Ia18d1e37e784a041d686d0001eda588f8f079dc4
Reviewed-on: http://review.couchbase.org/42901
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
MB-12067 [jemalloc/OS X]: Implement mem_used tracking using custom malloc zone

OS X doesn't allow direct interposing of malloc/calloc/free, instead
it provides the ability to register an alternate malloc zone. We
therefore use this feature to register a 'wrapper' zone, which
forwards all requests to the underlying default malloc, adding in
appropriate calls to any registered new/delete hooks.

Change-Id: I19b7eb36ac10739776c47d1a2b29f6eada9f824e
Reviewed-on: http://review.couchbase.org/42523
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: buildbot <build@couchbase.com>