Skip to content

Commit

Permalink
Make tests c89 friendly
Browse files Browse the repository at this point in the history
Change-Id: I92c7460b94b914b3bd8be60d285c0fde4b876222
Reviewed-on: http://review.couchbase.org/12336
Reviewed-by: Dustin Sallings <dustin@spy.net>
Tested-by: Dustin Sallings <dustin@spy.net>
  • Loading branch information
avsej authored and dustin committed Jan 14, 2012
1 parent c5a5079 commit 9b17c40
Show file tree
Hide file tree
Showing 15 changed files with 310 additions and 252 deletions.
15 changes: 15 additions & 0 deletions tests/config/testapp-config
@@ -0,0 +1,15 @@
{
"hashAlgorithm": "CRC",
"numReplicas": 2,
"serverList": [
"server1:11211",
"server2:11210",
"server3:11211"
],
"vBucketMap": [
[ 0, 1, 2 ],
[ 1, 2, 0 ],
[ 2, 1, -1 ],
[ 1, 2, 0 ]
]
}
55 changes: 55 additions & 0 deletions tests/config/testapp-config-couch-api-base
@@ -0,0 +1,55 @@
{
"nodes": [
{
"hostname": "192.168.2.123:9002",
"couchApiBase": "http://192.168.2.123:9502/default",
"ports": {
"proxy": 12005,
"direct": 12004
}
},
{
"hostname": "192.168.2.123:9000",
"couchApiBase": "http://192.168.2.123:9500/default",
"ports": {
"proxy": 12001,
"direct": 12000
}
},
{
"hostname": "192.168.2.123:9001",
"couchApiBase": "http://192.168.2.123:9501/default",
"ports": {
"proxy": 12003,
"direct": 12002
}
}
],
"vBucketServerMap": {
"hashAlgorithm": "CRC",
"numReplicas": 1,
"serverList": [
"192.168.2.123:12000",
"192.168.2.123:12002",
"192.168.2.123:12004"
],
"vBucketMap": [
[ 0, 1 ],
[ 0, 1 ],
[ 0, 1 ],
[ 1, 2 ],
[ 1, 2 ],
[ 2, 0 ],
[ 2, 1 ],
[ 2, 1 ],
[ 1, 0 ],
[ 1, 0 ],
[ 1, 0 ],
[ 0, 2 ],
[ 0, 2 ],
[ 0, 2 ],
[ 2, 0 ],
[ 2, 0 ]
]
}
}
15 changes: 15 additions & 0 deletions tests/config/testapp-config-diff1
@@ -0,0 +1,15 @@
{
"hashAlgorithm": "CRC",
"numReplicas": 2,
"serverList": [
"server1:11211",
"server2:11210",
"server3:11211"
],
"vBucketMap": [
[ 0, 1, 2 ],
[ 1, 2, 0 ],
[ 2, 1, -1 ],
[ 1, 2, 0 ]
]
}
15 changes: 15 additions & 0 deletions tests/config/testapp-config-diff2
@@ -0,0 +1,15 @@
{
"hashAlgorithm": "CRC",
"numReplicas": 2,
"serverList": [
"server1:11211",
"server2:11210",
"server4:11211"
],
"vBucketMap": [
[ 0, 1, 2 ],
[ 1, 2, 0 ],
[ 2, 1, -1 ],
[ 0, 2, 0 ]
]
}
18 changes: 18 additions & 0 deletions tests/config/testapp-config-diff3
@@ -0,0 +1,18 @@
{
"hashAlgorithm": "CRC",
"numReplicas": 1,
"serverList": [
"server1:11211",
"server2:11210"
],
"vBucketMap": [
[ 0, 1 ],
[ 1, 0 ],
[ 1, 0 ],
[ 0, 1 ],
[ 0, 1 ],
[ 1, 0 ],
[ 1, 0 ],
[ 0, 1 ]
]
}
15 changes: 15 additions & 0 deletions tests/config/testapp-config-flat
@@ -0,0 +1,15 @@
{
"hashAlgorithm": "CRC",
"numReplicas": 2,
"serverList": [
"server1:11211",
"server2:11210",
"server3:11211"
],
"vBucketMap": [
[ 0, 1, 2 ],
[ 1, 2, 0 ],
[ 2, 1, -1 ],
[ 1, 2, 0 ]
]
}
18 changes: 18 additions & 0 deletions tests/config/testapp-config-in-envelope
@@ -0,0 +1,18 @@
{
"otherKeyThatIsIgnored": 12345,
"vBucketServerMap": {
"hashAlgorithm": "CRC",
"numReplicas": 2,
"serverList": [
"server1:11211",
"server2:11210",
"server3:11211"
],
"vBucketMap": [
[ 0, 1, 2 ],
[ 1, 2, 0 ],
[ 2, 1, -1 ],
[ 1, 2, 0 ]
]
}
}
25 changes: 25 additions & 0 deletions tests/config/testapp-config-in-envelope-fft
@@ -0,0 +1,25 @@
{
"otherKeyThatIsIgnored": 12345,
"vBucketServerMap": {
"hashAlgorithm": "CRC",
"numReplicas": 2,
"serverList": [
"server1:11211",
"server2:11210",
"server3:11211",
"server4:11211"
],
"vBucketMap": [
[ 0, 1, 2 ],
[ 1, 2, 0 ],
[ 2, 1, -1 ],
[ 1, 2, 0 ]
],
"vBucketMapForward": [
[ 3, 0, 0 ],
[ 2, 1, 3 ],
[ 1, 2, 2 ],
[ 0, 3, 1 ]
]
}
}
48 changes: 48 additions & 0 deletions tests/config/testapp-config-in-envelope2
@@ -0,0 +1,48 @@
{
"name": "default",
"uri": "/pools/default/buckets/default",
"streamingUri": "/pools/default/bucketsStreaming/default",
"flushCacheUri": "/pools/default/buckets/default/controller/doFlush",
"nodes": [
{
"clusterMembership": "inactiveAdded",
"status": "unhealthy",
"hostname": "127.0.0.1",
"version": "unknown",
"os": "unknown",
"ports": {
"proxy": 11213,
"direct": 11212
},
"uptime": "0",
"memoryTotal": 0,
"memoryFree": 0,
"mcdMemoryReserved": 64,
"mcdMemoryAllocated": 0
}
],
"stats": {
"uri": "/pools/default/buckets/default/stats"
},
"vBucketServerMap": {
"hashAlgorithm": "CRC",
"numReplicas": 2,
"serverList": [
"server1:11211",
"server2:11210",
"server3:11211"
],
"vBucketMap": [
[ 0, 1, 2 ],
[ 1, 2, 0 ],
[ 2, 1, -1 ],
[ 1, 2, 0 ]
]
},
"basicStats": {
"cacheSize": 64,
"opsPerSec": 0.0,
"evictionsPerSec": 0.0,
"cachePercentUsed": 0.0
}
}
17 changes: 17 additions & 0 deletions tests/config/testapp-config-user-password1
@@ -0,0 +1,17 @@
{
"hashAlgorithm": "CRC",
"numReplicas": 2,
"serverList": [
"server1:11211",
"server2:11210",
"server3:11211"
],
"name": "theUser",
"saslPassword": "thePassword",
"vBucketMap": [
[ 0, 1, 2 ],
[ 1, 2, 0 ],
[ 2, 1, -1 ],
[ 1, 2, 0 ]
]
}
17 changes: 17 additions & 0 deletions tests/config/testapp-config-user-password2
@@ -0,0 +1,17 @@
{
"hashAlgorithm": "CRC",
"numReplicas": 2,
"serverList": [
"server1:11211",
"server2:11210",
"server3:11211"
],
"name": "theUserIsDifferent",
"saslPassword": "thePasswordIsDifferent",
"vBucketMap": [
[ 0, 1, 2 ],
[ 1, 2, 0 ],
[ 2, 1, -1 ],
[ 1, 2, 0 ]
]
}
14 changes: 14 additions & 0 deletions tests/macros.h
@@ -0,0 +1,14 @@
#ifndef TESTS_MACROS_H
#define TESTS_MACROS_H

#define assert(expr) \
do { \
if (!(expr)) { \
fprintf(stderr, "%s:%d: assertion failed\n", \
__FILE__, __LINE__); \
fflush(stderr); \
abort(); \
} \
} while (0)

#endif
3 changes: 2 additions & 1 deletion tests/regression.c
@@ -1,5 +1,4 @@
#undef NDEBUG
#include <assert.h>
#include <dirent.h>
#include <limits.h>
#include <errno.h>
Expand All @@ -9,6 +8,8 @@

#include <libvbucket/vbucket.h>

#include "tests/macros.h"

int main(void) {
char *root = getenv("srcdir");
if (root != NULL) {
Expand Down

0 comments on commit 9b17c40

Please sign in to comment.