RPM Package Manager, CVS Repository
/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 18-Sep-2010 00:49:48
Branch: HEAD Handle: 2010091722494500
Added files:
rpm/tests/mongo .cvsignore Makefile.am test.h
Modified files:
rpm/tests/mongo all_types.c auth.c benchmark.c count_delete.c
endian_swap.c errors.c json.c pair.c resize.c
simple.c sizes.c update.c
Log:
- mongo: add the test cases from mongo-c-driver.
Summary:
Revision Changes Path
1.1 +15 -0 rpm/tests/mongo/.cvsignore
1.1 +107 -0 rpm/tests/mongo/Makefile.am
1.2 +6 -4 rpm/tests/mongo/all_types.c
1.2 +10 -4 rpm/tests/mongo/auth.c
1.2 +5 -7 rpm/tests/mongo/benchmark.c
1.2 +10 -4 rpm/tests/mongo/count_delete.c
1.2 +7 -3 rpm/tests/mongo/endian_swap.c
1.2 +10 -4 rpm/tests/mongo/errors.c
1.2 +6 -3 rpm/tests/mongo/json.c
1.2 +10 -4 rpm/tests/mongo/pair.c
1.2 +6 -2 rpm/tests/mongo/resize.c
1.2 +10 -4 rpm/tests/mongo/simple.c
1.2 +5 -2 rpm/tests/mongo/sizes.c
1.1 +29 -0 rpm/tests/mongo/test.h
1.2 +10 -4 rpm/tests/mongo/update.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/.cvsignore
============================================================================
$ cvs diff -u -r0 -r1.1 .cvsignore
--- /dev/null 2010-09-18 00:46:43.000000000 +0200
+++ .cvsignore 2010-09-18 00:49:46.022467323 +0200
@@ -0,0 +1,15 @@
+.deps
+.libs
+Makefile
+Makefile.in
+all_types
+auth
+benchmark
+count_delete
+endian_swap
+errors
+pair
+resize
+simple
+sizes
+update
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/Makefile.am
============================================================================
$ cvs diff -u -r0 -r1.1 Makefile.am
--- /dev/null 2010-09-18 00:46:43.000000000 +0200
+++ Makefile.am 2010-09-18 00:49:46.142473992 +0200
@@ -0,0 +1,107 @@
+## Process this file with automake to produce Makefile.in.
+
+AUTOMAKE_OPTIONS = 1.4 foreign
+
+EXTRA_DIST =
+
+EXTRA_PROGRAMS = \
+ json
+
+noinst_PROGRAMS = \
+ all_types \
+ auth \
+ benchmark \
+ count_delete \
+ endian_swap \
+ errors \
+ pair \
+ resize \
+ simple \
+ sizes \
+ update
+
+AM_CPPFLAGS = \
+ -I$(srcdir) \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/rpmdb \
+ -I$(top_srcdir)/rpmio
+
+RPMIO_LDADD = \
+ $(top_builddir)/rpmio/librpmio.la \
+ $(top_builddir)/misc/librpmmisc.la \
+ @LTLIBINTL@
+
+#RPMDB_LDADD = \
+# $(top_builddir)/rpmdb/librpmdb.la \
+# $(RPMIO_LDADD)
+
+#RPM_LDADD = \
+# $(top_builddir)/build/librpmbuild.la \
+# $(top_builddir)/lib/librpm.la \
+# $(RPMDB_LDADD)
+
+mongoserver = localhost
+
+all_types_SOURCES = all_types.c
+all_types_LDADD = $(RPMIO_LDADD)
+
+auth_SOURCES = auth.c
+auth_LDADD = $(RPMIO_LDADD)
+
+benchmark_SOURCES = benchmark.c
+benchmark_LDADD = $(RPMIO_LDADD)
+
+count_delete_SOURCES = count_delete.c
+count_delete_LDADD = $(RPMIO_LDADD)
+
+endian_swap_SOURCES = endian_swap.c
+endian_swap_LDADD = $(RPMIO_LDADD)
+
+errors_SOURCES = errors.c
+errors_LDADD = $(RPMIO_LDADD)
+
+json_SOURCES = json.c
+json_LDADD = $(RPMIO_LDADD)
+
+pair_SOURCES = pair.c
+pair_LDADD = $(RPMIO_LDADD)
+
+resize_SOURCES = resize.c
+resize_LDADD = $(RPMIO_LDADD)
+
+simple_SOURCES = simple.c
+simple_LDADD = $(RPMIO_LDADD)
+
+sizes_SOURCES = sizes.c
+sizes_LDADD = $(RPMIO_LDADD)
+
+update_SOURCES = update.c
+update_LDADD = $(RPMIO_LDADD)
+
+check-local:
+ @echo "=== mongo-c-driver ==="
+ @echo "--> all_types"
+ @-./all_types
+ @echo "--> auth"
+ @-./auth $(mongoserver)
+ @echo "--> benchmark"
+ @-./benchmark $(mongoserver)
+ @echo "--> count_delete"
+ @-./count_delete $(mongoserver)
+ @echo "--> endian_swap"
+ @-./endian_swap
+ @echo "--> errors"
+ @-./errors $(mongoserver)
+# @echo "--> json"
+# @-./json
+ @echo "--> pair"
+ @-./pair $(mongoserver)
+ @echo "--> resize"
+ @-./resize
+ @echo "--> simple"
+ @-./simple $(mongoserver)
+ @echo "--> sizes"
+ @-./sizes
+ @echo "--> update"
+ @-./update $(mongoserver)
+
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/all_types.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 all_types.c
--- rpm/tests/mongo/all_types.c 17 Sep 2010 20:34:08 -0000 1.1
+++ rpm/tests/mongo/all_types.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,10 +1,12 @@
+#include "system.h"
+
#include "test.h"
#include "bson.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-int main(){
+#include "debug.h"
+
+int main(int argc, char *argv[])
+{
bson_buffer bb;
bson b;
bson_iterator it, it2, it3;
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/auth.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 auth.c
--- rpm/tests/mongo/auth.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/auth.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,14 +1,20 @@
+#include "system.h"
+
#include "test.h"
#include "mongo.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
+
+#include "debug.h"
+
+#if !defined(TEST_SERVER)
+#define TEST_SERVER "127.0.0.1"
+#endif
static mongo_connection conn[1];
static mongo_connection_options opts;
static const char* db = "test";
-int main(){
+int main(int argc, char *argv[])
+{
INIT_SOCKETS_FOR_WINDOWS;
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/benchmark.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 benchmark.c
--- rpm/tests/mongo/benchmark.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/benchmark.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,14 +1,11 @@
/* test.c */
+#include "system.h"
+
#include "test.h"
#include "mongo.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#ifndef _WIN32
-#include <sys/time.h>
-#endif
+#include "debug.h"
/* supports preprocessor concatenation */
#define DB "benchmarks"
@@ -362,7 +359,8 @@
ASSERT(!mongo_cmd_get_last_error(conn, DB, NULL));
}
-int main(){
+int main(int argc, char *argv[])
+{
mongo_connection_options opts;
INIT_SOCKETS_FOR_WINDOWS;
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/count_delete.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 count_delete.c
--- rpm/tests/mongo/count_delete.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/count_delete.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,12 +1,18 @@
/* count_delete.c */
+#include "system.h"
+
#include "test.h"
#include "mongo.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-int main(){
+#include "debug.h"
+
+#if !defined(TEST_SERVER)
+#define TEST_SERVER "127.0.0.1"
+#endif
+
+int main(int argc, char *argv[])
+{
mongo_connection conn[1];
mongo_connection_options opts;
bson_buffer bb;
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/endian_swap.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 endian_swap.c
--- rpm/tests/mongo/endian_swap.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/endian_swap.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,10 +1,14 @@
/* endian_swap.c */
+#include "system.h"
+
#include "test.h"
-#include "platform_hacks.h"
-#include <stdio.h>
+#include "bson.h"
+
+#include "debug.h"
-int main(){
+int main(int argc, char *argv[])
+{
int small = 0x00112233;
int64_t big = 0x0011223344556677;
double d = 1.2345;
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/errors.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 errors.c
--- rpm/tests/mongo/errors.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/errors.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,15 +1,21 @@
+#include "system.h"
+
#include "test.h"
#include "mongo.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
+
+#include "debug.h"
+
+#if !defined(TEST_SERVER)
+#define TEST_SERVER "127.0.0.1"
+#endif
static mongo_connection conn[1];
static mongo_connection_options opts;
static const char* db = "test";
static const char* ns = "test.c.error";
-int main(){
+int main(int argc, char *argv[])
+{
bson obj;
INIT_SOCKETS_FOR_WINDOWS;
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/json.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 json.c
--- rpm/tests/mongo/json.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/json.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,13 +1,15 @@
/* testjson.c */
+#include "system.h"
+
#include "test.h"
-#include <stdio.h>
-#include <string.h>
#include "mongo.h"
#include "json/json.h"
#include "md5.h"
+#include "debug.h"
+
void json_to_bson_append_element( bson_buffer * bb , const char * k , struct json_object * v );
/**
@@ -148,7 +150,8 @@
#define JSONBSONTEST run_json_to_bson_test
-int main(){
+int main(int argc, char *argv[])
+{
run_json_to_bson_test( "1" , 0 , 0 );
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/pair.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 pair.c
--- rpm/tests/mongo/pair.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/pair.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,14 +1,20 @@
+#include "system.h"
+
#include "test.h"
#include "mongo.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
+
+#include "debug.h"
+
+#if !defined(TEST_SERVER)
+#define TEST_SERVER "127.0.0.1"
+#endif
static mongo_connection conn[1];
static mongo_connection_options left;
static mongo_connection_options right;
-int main(){
+int main(int argc, char *argv[])
+{
INIT_SOCKETS_FOR_WINDOWS;
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/resize.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 resize.c
--- rpm/tests/mongo/resize.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/resize.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,13 +1,17 @@
/* resize.c */
+#include "system.h"
+
#include "test.h"
#include "bson.h"
-#include <string.h>
+
+#include "debug.h"
/* 64 Xs */
const char* bigstring = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
-int main(){
+int main(int argc, char *argv[])
+{
bson_buffer bb;
bson b;
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/simple.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 simple.c
--- rpm/tests/mongo/simple.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/simple.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,12 +1,18 @@
/* test.c */
+#include "system.h"
+
#include "test.h"
#include "mongo.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-int main(){
+#include "debug.h"
+
+#if !defined(TEST_SERVER)
+#define TEST_SERVER "127.0.0.1"
+#endif
+
+int main(int argc, char *argv[])
+{
mongo_connection conn[1];
mongo_connection_options opts;
bson_buffer bb;
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/sizes.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 sizes.c
--- rpm/tests/mongo/sizes.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/sizes.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,10 +1,13 @@
/* sizes.c */
+#include "system.h"
+
#include "test.h"
#include "mongo.h"
-#include <stdio.h>
-int main(){
+#include "debug.h"
+
+int main(int argc, char *argv[]){
mongo_reply mr;
ASSERT(sizeof(int) == 4);
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/test.h
============================================================================
$ cvs diff -u -r0 -r1.1 test.h
--- /dev/null 2010-09-18 00:46:43.000000000 +0200
+++ test.h 2010-09-18 00:49:48.412593089 +0200
@@ -0,0 +1,29 @@
+#define ASSERT(x) \
+ do{ \
+ if(!(x)){ \
+ printf("failed assert (%d): %s\n", __LINE__, #x); \
+ exit(1); \
+ }\
+ }while(0)
+
+#ifdef _WIN32
+#define INIT_SOCKETS_FOR_WINDOWS \
+ do{ \
+ WSADATA out; \
+ WSAStartup(MAKEWORD(2,2), &out); \
+ } while(0)
+#else
+#define INIT_SOCKETS_FOR_WINDOWS do {} while(0)
+#endif
+
+#ifdef MONGO_BIG_ENDIAN
+#define bson_little_endian64(out, in) ( bson_swap_endian64(out, in) )
+#define bson_little_endian32(out, in) ( bson_swap_endian32(out, in) )
+#define bson_big_endian64(out, in) ( memcpy(out, in, 8) )
+#define bson_big_endian32(out, in) ( memcpy(out, in, 4) )
+#else
+#define bson_little_endian64(out, in) ( memcpy(out, in, 8) )
+#define bson_little_endian32(out, in) ( memcpy(out, in, 4) )
+#define bson_big_endian64(out, in) ( bson_swap_endian64(out, in) )
+#define bson_big_endian32(out, in) ( bson_swap_endian32(out, in) )
+#endif
@@ .
patch -p0 <<'@@ .'
Index: rpm/tests/mongo/update.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 update.c
--- rpm/tests/mongo/update.c 17 Sep 2010 20:34:09 -0000 1.1
+++ rpm/tests/mongo/update.c 17 Sep 2010 22:49:45 -0000 1.2
@@ -1,10 +1,16 @@
+#include "system.h"
+
#include "test.h"
#include "mongo.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-int main(){
+#include "debug.h"
+
+#if !defined(TEST_SERVER)
+#define TEST_SERVER "127.0.0.1"
+#endif
+
+int main(int argc, char *argv[])
+{
mongo_connection conn[1];
mongo_connection_options opts;
bson_buffer bb;
@@ .
Received on Sat Sep 18 00:49:48 2010