]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
automake cleanup: moving tests to test subdir
authorRoald J. van Loon <roaldvanloon@gmail.com>
Sat, 7 Sep 2013 13:27:33 +0000 (15:27 +0200)
committerRoald J. van Loon <roaldvanloon@gmail.com>
Sat, 7 Sep 2013 20:41:10 +0000 (22:41 +0200)
This are tests and should be in the src/test subdir.

Signed-off-by: Roald J. van Loon <roaldvanloon@gmail.com>
17 files changed:
src/Makefile.am
src/barclass.cc [deleted file]
src/fooclass.cc [deleted file]
src/streamtest.cc [deleted file]
src/test/barclass.cc [new file with mode: 0644]
src/test/fooclass.cc [new file with mode: 0644]
src/test/streamtest.cc [new file with mode: 0644]
src/test/test_trans.cc [new file with mode: 0644]
src/test/testclass.cc [new file with mode: 0644]
src/test/testcrypto.cc [new file with mode: 0644]
src/test/testkeys.cc [new file with mode: 0644]
src/test/testmsgr.cc [new file with mode: 0644]
src/test_trans.cc [deleted file]
src/testclass.cc [deleted file]
src/testcrypto.cc [deleted file]
src/testkeys.cc [deleted file]
src/testmsgr.cc [deleted file]

index 7513ed85085de1072da034884180c2954c565d1e..9a2317537cbc70fafffddb8bafcbc884ec824882 100644 (file)
@@ -239,7 +239,7 @@ ceph_test_rewrite_latency_SOURCES = test/test_rewrite_latency.cc
 ceph_test_rewrite_latency_LDADD = libcommon.la $(PTHREAD_LIBS) -lm $(CRYPTO_LIBS) $(EXTRALIBS)
 bin_DEBUGPROGRAMS += ceph_test_rewrite_latency
 
-ceph_test_msgr_SOURCES = testmsgr.cc
+ceph_test_msgr_SOURCES = test/testmsgr.cc
 ceph_test_msgr_LDADD = $(LIBGLOBAL_LDA)
 bin_DEBUGPROGRAMS += ceph_test_msgr
 
@@ -249,12 +249,12 @@ bin_DEBUGPROGRAMS += ceph_test_ioctls
 ceph_dupstore_SOURCES = dupstore.cc
 ceph_dupstore_CXXFLAGS= ${CRYPTO_CXXFLAGS} ${AM_CXXFLAGS}
 ceph_dupstore_LDADD = $(LIBOS_LDA) $(LIBGLOBAL_LDA)
-ceph_streamtest_SOURCES = streamtest.cc
+ceph_streamtest_SOURCES = test/streamtest.cc
 ceph_streamtest_CXXFLAGS= ${CRYPTO_CXXFLAGS} ${AM_CXXFLAGS}
 ceph_streamtest_LDADD = $(LIBOS_LDA) $(LIBGLOBAL_LDA)
 bin_DEBUGPROGRAMS += ceph_dupstore ceph_streamtest
 
-ceph_test_trans_SOURCES = test_trans.cc
+ceph_test_trans_SOURCES = test/test_trans.cc
 ceph_test_trans_CXXFLAGS= ${CRYPTO_CXXFLAGS} ${AM_CXXFLAGS}
 ceph_test_trans_LDADD = $(LIBOS_LDA) $(LIBGLOBAL_LDA)
 bin_DEBUGPROGRAMS += ceph_test_trans
@@ -516,12 +516,12 @@ bin_PROGRAMS += rbd
 endif
 
 
-ceph_test_crypto_SOURCES = testcrypto.cc
+ceph_test_crypto_SOURCES = test/testcrypto.cc
 ceph_test_crypto_LDADD =  $(LIBGLOBAL_LDA)
 ceph_test_crypto_CXXFLAGS = ${AM_CXXFLAGS}
 bin_DEBUGPROGRAMS += ceph_test_crypto
 
-ceph_test_keys_SOURCES = testkeys.cc
+ceph_test_keys_SOURCES = test/testkeys.cc
 ceph_test_keys_LDADD = libmon.a $(LIBGLOBAL_LDA) 
 ceph_test_keys_CXXFLAGS = ${AM_CXXFLAGS}
 bin_DEBUGPROGRAMS += ceph_test_keys
diff --git a/src/barclass.cc b/src/barclass.cc
deleted file mode 100644 (file)
index f5354f1..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-#include <iostream>
-#include <string.h>
-#include <stdlib.h>
-
-#include "objclass/objclass.h"
-
-CLS_VER(1,0)
-CLS_NAME(bar)
-
-cls_handle_t h_class;
-
-cls_method_handle_t h_foo;
-
-int foo_method(cls_method_context_t ctx, char *indata, int datalen,
-                                char **outdata, int *outdatalen)
-{
-   int i;
-
-   cls_log("hello world, this is bar");
-   cls_log("indata=%s", indata);
-
-   *outdata = (char *)malloc(128);
-   for (i=0; i<strlen(indata) + 1; i++) {
-     if (indata[i] == '0') {
-       (*outdata)[i] = '*';
-     } else {
-       (*outdata)[i] = indata[i];
-     }
-   }
-   *outdatalen = strlen(*outdata) + 1;
-   cls_log("outdata=%s", *outdata);
-
-   return 0;
-}
-
-void class_init()
-{
-   cls_log("Loaded bar class!");
-
-   cls_register("bar", &h_class);
-   cls_register_method(h_class, "bar", foo_method, &h_foo);
-
-   return;
-}
-
diff --git a/src/fooclass.cc b/src/fooclass.cc
deleted file mode 100644 (file)
index 2db2d81..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-#include <iostream>
-#include <string.h>
-#include <stdlib.h>
-
-#include "objclass/objclass.h"
-
-CLS_VER(1,0)
-CLS_NAME(foo)
-
-cls_handle_t h_class;
-
-cls_method_handle_t h_foo;
-
-int foo_method(cls_method_context_t ctx, char *indata, int datalen,
-                                char **outdata, int *outdatalen)
-{
-   int i;
-
-   cls_log("hello world, this is foo");
-   cls_log("indata=%s", indata);
-
-   *outdata = (char *)malloc(128);
-   for (i=0; i<strlen(indata) + 1; i++) {
-     if (indata[i] == '1') {
-       (*outdata)[i] = 'I';
-     } else {
-       (*outdata)[i] = indata[i];
-     }
-   }
-   *outdatalen = strlen(*outdata) + 1;
-   cls_log("outdata=%s", *outdata);
-
-   return 0;
-}
-
-void class_init()
-{
-   cls_log("Loaded foo class!");
-
-   cls_register("foo", &h_class);
-   cls_register_method(h_class, "foo", foo_method, &h_foo);
-
-   return;
-}
-
diff --git a/src/streamtest.cc b/src/streamtest.cc
deleted file mode 100644 (file)
index 21693ac..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
- * Foundation.  See file COPYING.
- * 
- */
-
-#include <iostream>
-#include "os/FileStore.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
-#include "common/debug.h"
-
-#undef dout_prefix
-#define dout_prefix *_dout
-
-struct io {
-  utime_t start, ack, commit;
-  bool done() {
-    return ack.sec() && commit.sec();
-  }
-};
-map<off_t,io> writes;
-Cond cond;
-Mutex lock("streamtest.cc lock");
-
-unsigned concurrent = 1;
-void throttle()
-{ 
-  Mutex::Locker l(lock);
-  while (writes.size() >= concurrent) {
-    //generic_dout(0) << "waiting" << dendl;
-    cond.Wait(lock);
-  }
-}
-
-double total_ack = 0;
-double total_commit = 0;
-int total_num = 0;
-
-void pr(off_t off)
-{
-  io &i = writes[off];
-  if (false) cout << off << "\t" 
-       << (i.ack - i.start) << "\t"
-       << (i.commit - i.start) << std::endl;
-  total_num++;
-  total_ack += (i.ack - i.start);
-  total_commit += (i.commit - i.start);
-  writes.erase(off);
-  cond.Signal();
-}
-
-void set_start(off_t off, utime_t t)
-{
-  Mutex::Locker l(lock);
-  writes[off].start = t;
-}
-
-void set_ack(off_t off, utime_t t)
-{
-  Mutex::Locker l(lock);
-  //generic_dout(0) << "ack " << off << dendl;
-  writes[off].ack = t;
-  if (writes[off].done())
-    pr(off);
-}
-
-void set_commit(off_t off, utime_t t)
-{
-  Mutex::Locker l(lock);
-  //generic_dout(0) << "commit " << off << dendl;
-  writes[off].commit = t;
-  if (writes[off].done())
-    pr(off);
-}
-
-
-struct C_Ack : public Context {
-  off_t off;
-  C_Ack(off_t o) : off(o) {}
-  void finish(int r) {
-    set_ack(off, ceph_clock_now(g_ceph_context));
-  }
-};
-struct C_Commit : public Context {
-  off_t off;
-  C_Commit(off_t o) : off(o) {}
-  void finish(int r) {
-    set_commit(off, ceph_clock_now(g_ceph_context));
-  }
-};
-
-
-int main(int argc, const char **argv)
-{
-  vector<const char*> args;
-  argv_to_vec(argc, argv, args);
-  env_to_vec(args);
-
-  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(g_ceph_context);
-
-  // args
-  if (args.size() < 3) return -1;
-  const char *filename = args[0];
-  int seconds = atoi(args[1]);
-  int bytes = atoi(args[2]);
-  const char *journal = 0;
-  if (args.size() >= 4)
-    journal = args[3];
-  if (args.size() >= 5)
-    concurrent = atoi(args[4]);
-
-  cout << "concurrent = " << concurrent << std::endl;
-
-  buffer::ptr bp(bytes);
-  bp.zero();
-  bufferlist bl;
-  bl.push_back(bp);
-
-  //float interval = 1.0 / 1000;
-  
-  cout << "#dev " << filename
-       << ", " << seconds << " seconds, " << bytes << " bytes per write" << std::endl;
-
-  ObjectStore *fs = new FileStore(filename, journal);
-  
-  if (fs->mkfs() < 0) {
-    cout << "mkfs failed" << std::endl;
-    return -1;
-  }
-  
-  if (fs->mount() < 0) {
-    cout << "mount failed" << std::endl;
-    return -1;
-  }
-
-  ObjectStore::Transaction ft;
-  ft.create_collection(coll_t());
-  fs->apply_transaction(ft);
-
-  utime_t now = ceph_clock_now(g_ceph_context);
-  utime_t start = now;
-  utime_t end = now;
-  end += seconds;
-  off_t pos = 0;
-  //cout << "stop at " << end << std::endl;
-  cout << "# offset\tack\tcommit" << std::endl;
-  while (now < end) {
-    sobject_t poid(object_t("streamtest"), 0);
-
-    set_start(pos, ceph_clock_now(g_ceph_context));
-    ObjectStore::Transaction *t = new ObjectStore::Transaction;
-    t->write(coll_t(), hobject_t(poid), pos, bytes, bl);
-    fs->queue_transaction(NULL, t, new C_Ack(pos), new C_Commit(pos));
-    pos += bytes;
-
-    throttle();
-
-    now = ceph_clock_now(g_ceph_context);
-
-    // wait?
-    /*
-    utime_t next = start;
-    next += interval;
-    if (now < next) {
-      float s = next - now;
-      s *= 1000 * 1000;  // s -> us
-      //cout << "sleeping for " << s << " us" << std::endl;
-      usleep((int)s);
-    }
-    */
-  }
-
-  cout << "total num " << total_num << std::endl;
-  cout << "avg ack\t" << (total_ack / (double)total_num) << std::endl;
-  cout << "avg commit\t" << (total_commit / (double)total_num) << std::endl;
-  cout << "tput\t" << prettybyte_t((double)(total_num * bytes) / (double)(end-start)) << "/sec" << std::endl;
-
-  fs->umount();
-
-}
-
diff --git a/src/test/barclass.cc b/src/test/barclass.cc
new file mode 100644 (file)
index 0000000..f5354f1
--- /dev/null
@@ -0,0 +1,48 @@
+
+
+
+#include <iostream>
+#include <string.h>
+#include <stdlib.h>
+
+#include "objclass/objclass.h"
+
+CLS_VER(1,0)
+CLS_NAME(bar)
+
+cls_handle_t h_class;
+
+cls_method_handle_t h_foo;
+
+int foo_method(cls_method_context_t ctx, char *indata, int datalen,
+                                char **outdata, int *outdatalen)
+{
+   int i;
+
+   cls_log("hello world, this is bar");
+   cls_log("indata=%s", indata);
+
+   *outdata = (char *)malloc(128);
+   for (i=0; i<strlen(indata) + 1; i++) {
+     if (indata[i] == '0') {
+       (*outdata)[i] = '*';
+     } else {
+       (*outdata)[i] = indata[i];
+     }
+   }
+   *outdatalen = strlen(*outdata) + 1;
+   cls_log("outdata=%s", *outdata);
+
+   return 0;
+}
+
+void class_init()
+{
+   cls_log("Loaded bar class!");
+
+   cls_register("bar", &h_class);
+   cls_register_method(h_class, "bar", foo_method, &h_foo);
+
+   return;
+}
+
diff --git a/src/test/fooclass.cc b/src/test/fooclass.cc
new file mode 100644 (file)
index 0000000..2db2d81
--- /dev/null
@@ -0,0 +1,48 @@
+
+
+
+#include <iostream>
+#include <string.h>
+#include <stdlib.h>
+
+#include "objclass/objclass.h"
+
+CLS_VER(1,0)
+CLS_NAME(foo)
+
+cls_handle_t h_class;
+
+cls_method_handle_t h_foo;
+
+int foo_method(cls_method_context_t ctx, char *indata, int datalen,
+                                char **outdata, int *outdatalen)
+{
+   int i;
+
+   cls_log("hello world, this is foo");
+   cls_log("indata=%s", indata);
+
+   *outdata = (char *)malloc(128);
+   for (i=0; i<strlen(indata) + 1; i++) {
+     if (indata[i] == '1') {
+       (*outdata)[i] = 'I';
+     } else {
+       (*outdata)[i] = indata[i];
+     }
+   }
+   *outdatalen = strlen(*outdata) + 1;
+   cls_log("outdata=%s", *outdata);
+
+   return 0;
+}
+
+void class_init()
+{
+   cls_log("Loaded foo class!");
+
+   cls_register("foo", &h_class);
+   cls_register_method(h_class, "foo", foo_method, &h_foo);
+
+   return;
+}
+
diff --git a/src/test/streamtest.cc b/src/test/streamtest.cc
new file mode 100644 (file)
index 0000000..21693ac
--- /dev/null
@@ -0,0 +1,191 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
+
+#include <iostream>
+#include "os/FileStore.h"
+#include "global/global_init.h"
+#include "common/ceph_argparse.h"
+#include "common/debug.h"
+
+#undef dout_prefix
+#define dout_prefix *_dout
+
+struct io {
+  utime_t start, ack, commit;
+  bool done() {
+    return ack.sec() && commit.sec();
+  }
+};
+map<off_t,io> writes;
+Cond cond;
+Mutex lock("streamtest.cc lock");
+
+unsigned concurrent = 1;
+void throttle()
+{ 
+  Mutex::Locker l(lock);
+  while (writes.size() >= concurrent) {
+    //generic_dout(0) << "waiting" << dendl;
+    cond.Wait(lock);
+  }
+}
+
+double total_ack = 0;
+double total_commit = 0;
+int total_num = 0;
+
+void pr(off_t off)
+{
+  io &i = writes[off];
+  if (false) cout << off << "\t" 
+       << (i.ack - i.start) << "\t"
+       << (i.commit - i.start) << std::endl;
+  total_num++;
+  total_ack += (i.ack - i.start);
+  total_commit += (i.commit - i.start);
+  writes.erase(off);
+  cond.Signal();
+}
+
+void set_start(off_t off, utime_t t)
+{
+  Mutex::Locker l(lock);
+  writes[off].start = t;
+}
+
+void set_ack(off_t off, utime_t t)
+{
+  Mutex::Locker l(lock);
+  //generic_dout(0) << "ack " << off << dendl;
+  writes[off].ack = t;
+  if (writes[off].done())
+    pr(off);
+}
+
+void set_commit(off_t off, utime_t t)
+{
+  Mutex::Locker l(lock);
+  //generic_dout(0) << "commit " << off << dendl;
+  writes[off].commit = t;
+  if (writes[off].done())
+    pr(off);
+}
+
+
+struct C_Ack : public Context {
+  off_t off;
+  C_Ack(off_t o) : off(o) {}
+  void finish(int r) {
+    set_ack(off, ceph_clock_now(g_ceph_context));
+  }
+};
+struct C_Commit : public Context {
+  off_t off;
+  C_Commit(off_t o) : off(o) {}
+  void finish(int r) {
+    set_commit(off, ceph_clock_now(g_ceph_context));
+  }
+};
+
+
+int main(int argc, const char **argv)
+{
+  vector<const char*> args;
+  argv_to_vec(argc, argv, args);
+  env_to_vec(args);
+
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+
+  // args
+  if (args.size() < 3) return -1;
+  const char *filename = args[0];
+  int seconds = atoi(args[1]);
+  int bytes = atoi(args[2]);
+  const char *journal = 0;
+  if (args.size() >= 4)
+    journal = args[3];
+  if (args.size() >= 5)
+    concurrent = atoi(args[4]);
+
+  cout << "concurrent = " << concurrent << std::endl;
+
+  buffer::ptr bp(bytes);
+  bp.zero();
+  bufferlist bl;
+  bl.push_back(bp);
+
+  //float interval = 1.0 / 1000;
+  
+  cout << "#dev " << filename
+       << ", " << seconds << " seconds, " << bytes << " bytes per write" << std::endl;
+
+  ObjectStore *fs = new FileStore(filename, journal);
+  
+  if (fs->mkfs() < 0) {
+    cout << "mkfs failed" << std::endl;
+    return -1;
+  }
+  
+  if (fs->mount() < 0) {
+    cout << "mount failed" << std::endl;
+    return -1;
+  }
+
+  ObjectStore::Transaction ft;
+  ft.create_collection(coll_t());
+  fs->apply_transaction(ft);
+
+  utime_t now = ceph_clock_now(g_ceph_context);
+  utime_t start = now;
+  utime_t end = now;
+  end += seconds;
+  off_t pos = 0;
+  //cout << "stop at " << end << std::endl;
+  cout << "# offset\tack\tcommit" << std::endl;
+  while (now < end) {
+    sobject_t poid(object_t("streamtest"), 0);
+
+    set_start(pos, ceph_clock_now(g_ceph_context));
+    ObjectStore::Transaction *t = new ObjectStore::Transaction;
+    t->write(coll_t(), hobject_t(poid), pos, bytes, bl);
+    fs->queue_transaction(NULL, t, new C_Ack(pos), new C_Commit(pos));
+    pos += bytes;
+
+    throttle();
+
+    now = ceph_clock_now(g_ceph_context);
+
+    // wait?
+    /*
+    utime_t next = start;
+    next += interval;
+    if (now < next) {
+      float s = next - now;
+      s *= 1000 * 1000;  // s -> us
+      //cout << "sleeping for " << s << " us" << std::endl;
+      usleep((int)s);
+    }
+    */
+  }
+
+  cout << "total num " << total_num << std::endl;
+  cout << "avg ack\t" << (total_ack / (double)total_num) << std::endl;
+  cout << "avg commit\t" << (total_commit / (double)total_num) << std::endl;
+  cout << "tput\t" << prettybyte_t((double)(total_num * bytes) / (double)(end-start)) << "/sec" << std::endl;
+
+  fs->umount();
+
+}
+
diff --git a/src/test/test_trans.cc b/src/test/test_trans.cc
new file mode 100644 (file)
index 0000000..43821c1
--- /dev/null
@@ -0,0 +1,77 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
+
+#include <iostream>
+#include "common/ceph_argparse.h"
+#include "common/debug.h"
+#include "os/FileStore.h"
+#include "global/global_init.h"
+#include "include/assert.h"
+
+#define dout_subsys ceph_subsys_filestore
+#undef dout_prefix
+#define dout_prefix *_dout
+
+struct Foo : public Thread {
+  void *entry() {
+    dout(0) << "foo started" << dendl;
+    sleep(1);
+    dout(0) << "foo asserting 0" << dendl;
+    assert(0);
+  }
+} foo;
+
+int main(int argc, const char **argv)
+{
+  vector<const char*> args;
+  argv_to_vec(argc, argv, args);
+  env_to_vec(args);
+
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+
+  // args
+  if (args.size() < 2) return -1;
+  const char *filename = args[0];
+  int mb = atoi(args[1]);
+
+  cout << "#dev " << filename << std::endl;
+  cout << "#mb " << mb << std::endl;
+
+  ObjectStore *fs = new FileStore(filename, NULL);
+  if (fs->mount() < 0) {
+    cout << "mount failed" << std::endl;
+    return -1;
+  }
+
+  ObjectStore::Transaction t;
+  char buf[1 << 20];
+  bufferlist bl;
+  bl.append(buf, sizeof(buf));
+  t.create_collection(coll_t());
+
+  for (int i=0; i<mb; i++) {
+    char f[30];
+    snprintf(f, sizeof(f), "foo%d\n", i);
+    sobject_t soid(f, CEPH_NOSNAP);
+    t.write(coll_t(), hobject_t(soid), 0, bl.length(), bl);
+  }
+  
+  dout(0) << "starting thread" << dendl;
+  foo.create();
+  dout(0) << "starting op" << dendl;
+  fs->apply_transaction(t);
+
+}
+
diff --git a/src/test/testclass.cc b/src/test/testclass.cc
new file mode 100644 (file)
index 0000000..22a97be
--- /dev/null
@@ -0,0 +1,57 @@
+
+
+
+#include <iostream>
+#include <string.h>
+#include <stdlib.h>
+
+#include "objclass/objclass.h"
+
+CLS_VER(1,0)
+CLS_NAME(test)
+
+cls_handle_t h_class;
+
+cls_method_handle_t h_foo;
+
+int foo_method(cls_method_context_t ctx, char *indata, int datalen,
+                                char **outdata, int *outdatalen)
+{
+   int i, r;
+
+   cls_log("hello world");
+   cls_log("indata=%s", indata);
+
+   *outdata = (char *)cls_alloc(128);
+   for (i=0; i<strlen(indata) + 1; i++) {
+     if (indata[i] == '0') {
+       (*outdata)[i] = '*';
+     } else {
+       (*outdata)[i] = indata[i];
+     }
+   }
+   *outdatalen = strlen(*outdata) + 1;
+   cls_log("outdata=%s", *outdata);
+
+   r = cls_call(ctx, "foo", "foo", *outdata, *outdatalen, outdata, outdatalen);
+
+   return r;
+}
+
+static cls_deps_t depend[] = {{"foo", "1.0"}, {"bar", "1.0"}, {NULL, NULL}};
+
+extern "C" cls_deps_t *class_deps()
+{
+   return depend;
+};
+
+void class_init()
+{
+   cls_log("Loaded class test!");
+
+   cls_register("test", &h_class);
+   cls_register_method(h_class, "foo", foo_method, &h_foo);
+
+   return;
+}
+
diff --git a/src/test/testcrypto.cc b/src/test/testcrypto.cc
new file mode 100644 (file)
index 0000000..0b7a9d5
--- /dev/null
@@ -0,0 +1,56 @@
+#include "auth/Crypto.h"
+#include "common/Clock.h"
+
+#include "common/config.h"
+#include "common/debug.h"
+
+#define dout_subsys ceph_subsys_auth
+
+#define AES_KEY_LEN    16
+
+int main(int argc, char *argv[])
+{
+  char aes_key[AES_KEY_LEN];
+  memset(aes_key, 0x77, sizeof(aes_key));
+  bufferptr keybuf(aes_key, sizeof(aes_key));
+  CryptoKey key(CEPH_CRYPTO_AES, ceph_clock_now(g_ceph_context), keybuf);
+
+  const char *msg="hello! this is a message\n";
+  char pad[16];
+  memset(pad, 0, 16);
+  bufferptr ptr(msg, strlen(msg));
+  bufferlist enc_in;
+  enc_in.append(ptr);
+  enc_in.append(msg, strlen(msg));
+
+  bufferlist enc_out;
+  std::string error;
+  key.encrypt(g_ceph_context, enc_in, enc_out, error);
+  if (!error.empty()) {
+    dout(0) << "couldn't encode! error " << error << dendl;
+    exit(1);
+  }
+
+  const char *enc_buf = enc_out.c_str();
+  for (unsigned i=0; i<enc_out.length(); i++) {
+    std::cout << hex << (int)(unsigned char)enc_buf[i] << dec << " ";
+    if (i && !(i%16))
+      std::cout << std::endl;
+  }
+
+  bufferlist dec_in, dec_out;
+
+  dec_in = enc_out;
+
+  key.decrypt(g_ceph_context, dec_in, dec_out, error);
+  if (!error.empty()) {
+    dout(0) << "couldn't decode! error " << error << dendl;
+    exit(1);
+  }
+
+  dout(0) << "decoded len: " << dec_out.length() << dendl;
+  dout(0) << "decoded msg: " << dec_out.c_str() << dendl;
+
+  return 0;
+}
+
diff --git a/src/test/testkeys.cc b/src/test/testkeys.cc
new file mode 100644 (file)
index 0000000..27c3812
--- /dev/null
@@ -0,0 +1,64 @@
+#include "auth/cephx/CephxKeyServer.h"
+#include "common/ceph_argparse.h"
+#include "global/global_init.h"
+#include "common/config.h"
+
+#define AES_KEY_LEN    16
+
+int main(int argc, const char **argv)
+{
+  vector<const char*> args;
+  argv_to_vec(argc, argv, args);
+  env_to_vec(args);
+
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+  KeyRing extra;
+  KeyServer server(g_ceph_context, &extra);
+
+  generic_dout(0) << "server created" << dendl;
+
+  getchar();
+
+#if 0
+  char aes_key[AES_KEY_LEN];
+  memset(aes_key, 0x77, sizeof(aes_key));
+  bufferptr keybuf(aes_key, sizeof(aes_key));
+  CryptoKey key(CEPH_CRYPTO_AES, ceph_clock_now(g_ceph_context), keybuf);
+
+  const char *msg="hello! this is a message\n";
+  char pad[16];
+  memset(pad, 0, 16);
+  bufferptr ptr(msg, strlen(msg));
+  bufferlist enc_in;
+  enc_in.append(ptr);
+  enc_in.append(msg, strlen(msg));
+
+  bufferlist enc_out;
+  if (key.encrypt(enc_in, enc_out) < 0) {
+    derr(0) << "couldn't encode!" << dendl;
+    exit(1);
+  }
+
+  const char *enc_buf = enc_out.c_str();
+  for (unsigned i=0; i<enc_out.length(); i++) {
+    std::cout << hex << (int)(unsigned char)enc_buf[i] << dec << " ";
+    if (i && !(i%16))
+      std::cout << std::endl;
+  }
+
+  bufferlist dec_in, dec_out;
+
+  dec_in = enc_out;
+
+  if (key.decrypt(dec_in, dec_out) < 0) {
+    derr(0) << "couldn't decode!" << dendl;
+  }
+
+  dout(0) << "decoded len: " << dec_out.length() << dendl;
+  dout(0) << "decoded msg: " << dec_out.c_str() << dendl;
+
+  return 0;
+#endif
+}
+
diff --git a/src/test/testmsgr.cc b/src/test/testmsgr.cc
new file mode 100644 (file)
index 0000000..4de779b
--- /dev/null
@@ -0,0 +1,145 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
+
+#include <sys/stat.h>
+#include <iostream>
+#include <string>
+using namespace std;
+
+#include "common/config.h"
+
+#include "mon/MonMap.h"
+#include "mon/MonClient.h"
+#include "msg/Messenger.h"
+#include "messages/MPing.h"
+
+#include "common/Timer.h"
+#include "global/global_init.h"
+#include "common/ceph_argparse.h"
+
+#ifndef DARWIN
+#include <envz.h>
+#endif // DARWIN
+
+#include <sys/types.h>
+#include <fcntl.h>
+
+#define dout_subsys ceph_subsys_ms
+
+Messenger *messenger = 0;
+
+Mutex lock("mylock");
+Cond cond;
+
+uint64_t received = 0;
+
+class Admin : public Dispatcher {
+public:
+  Admin() 
+    : Dispatcher(g_ceph_context)
+  {
+  }
+private:
+  bool ms_dispatch(Message *m) {
+
+    //cerr << "got ping from " << m->get_source() << std::endl;
+    dout(0) << "got ping from " << m->get_source() << dendl;
+    lock.Lock();
+    ++received;
+    cond.Signal();
+    lock.Unlock();
+
+    m->put();
+    return true;
+  }
+
+  bool ms_handle_reset(Connection *con) { return false; }
+  void ms_handle_remote_reset(Connection *con) {}
+
+} dispatcher;
+
+
+int main(int argc, const char **argv, const char *envp[]) {
+
+  vector<const char*> args;
+  argv_to_vec(argc, argv, args);
+  env_to_vec(args);
+
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+
+  dout(0) << "i am mon " << args[0] << dendl;
+
+  // get monmap
+  MonClient mc(g_ceph_context);
+  if (mc.build_initial_monmap() < 0)
+    return -1;
+  
+  // start up network
+  int whoami = mc.monmap.get_rank(args[0]);
+  assert(whoami >= 0);
+  ostringstream ss;
+  ss << mc.monmap.get_addr(whoami);
+  std::string sss(ss.str());
+  g_ceph_context->_conf->set_val("public_addr", sss.c_str());
+  g_ceph_context->_conf->apply_changes(NULL);
+  Messenger *rank = Messenger::create(g_ceph_context,
+                                     entity_name_t::MON(whoami), "tester",
+                                     getpid());
+  int err = rank->bind(g_ceph_context->_conf->public_addr);
+  if (err < 0)
+    return 1;
+
+  // start monitor
+  messenger = rank;
+  messenger->set_default_send_priority(CEPH_MSG_PRIO_HIGH);
+  messenger->add_dispatcher_head(&dispatcher);
+
+  rank->start();
+  
+  int isend = 0;
+  if (whoami == 0)
+    isend = 100;
+
+  lock.Lock();
+  uint64_t sent = 0;
+  while (1) {
+    while (received + isend <= sent) {
+      //cerr << "wait r " << received << " s " << sent << " is " << isend << std::endl;
+      dout(0) << "wait r " << received << " s " << sent << " is " << isend << dendl;
+      cond.Wait(lock);
+    }
+
+    int t = rand() % mc.get_num_mon();
+    if (t == whoami)
+      continue;
+    
+    if (rand() % 10 == 0) {
+      //cerr << "mark_down " << t << std::endl;
+      dout(0) << "mark_down " << t << dendl;
+      messenger->mark_down(mc.get_mon_addr(t));
+    } 
+    //cerr << "pinging " << t << std::endl;
+    dout(0) << "pinging " << t << dendl;
+    messenger->send_message(new MPing, mc.get_mon_inst(t));
+    cerr << isend << "\t" << ++sent << "\t" << received << "\r";
+  }
+  lock.Unlock();
+
+  // wait for messenger to finish
+  rank->wait();
+  
+  return 0;
+}
+
diff --git a/src/test_trans.cc b/src/test_trans.cc
deleted file mode 100644 (file)
index 43821c1..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
- * Foundation.  See file COPYING.
- * 
- */
-
-#include <iostream>
-#include "common/ceph_argparse.h"
-#include "common/debug.h"
-#include "os/FileStore.h"
-#include "global/global_init.h"
-#include "include/assert.h"
-
-#define dout_subsys ceph_subsys_filestore
-#undef dout_prefix
-#define dout_prefix *_dout
-
-struct Foo : public Thread {
-  void *entry() {
-    dout(0) << "foo started" << dendl;
-    sleep(1);
-    dout(0) << "foo asserting 0" << dendl;
-    assert(0);
-  }
-} foo;
-
-int main(int argc, const char **argv)
-{
-  vector<const char*> args;
-  argv_to_vec(argc, argv, args);
-  env_to_vec(args);
-
-  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(g_ceph_context);
-
-  // args
-  if (args.size() < 2) return -1;
-  const char *filename = args[0];
-  int mb = atoi(args[1]);
-
-  cout << "#dev " << filename << std::endl;
-  cout << "#mb " << mb << std::endl;
-
-  ObjectStore *fs = new FileStore(filename, NULL);
-  if (fs->mount() < 0) {
-    cout << "mount failed" << std::endl;
-    return -1;
-  }
-
-  ObjectStore::Transaction t;
-  char buf[1 << 20];
-  bufferlist bl;
-  bl.append(buf, sizeof(buf));
-  t.create_collection(coll_t());
-
-  for (int i=0; i<mb; i++) {
-    char f[30];
-    snprintf(f, sizeof(f), "foo%d\n", i);
-    sobject_t soid(f, CEPH_NOSNAP);
-    t.write(coll_t(), hobject_t(soid), 0, bl.length(), bl);
-  }
-  
-  dout(0) << "starting thread" << dendl;
-  foo.create();
-  dout(0) << "starting op" << dendl;
-  fs->apply_transaction(t);
-
-}
-
diff --git a/src/testclass.cc b/src/testclass.cc
deleted file mode 100644 (file)
index 22a97be..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-#include <iostream>
-#include <string.h>
-#include <stdlib.h>
-
-#include "objclass/objclass.h"
-
-CLS_VER(1,0)
-CLS_NAME(test)
-
-cls_handle_t h_class;
-
-cls_method_handle_t h_foo;
-
-int foo_method(cls_method_context_t ctx, char *indata, int datalen,
-                                char **outdata, int *outdatalen)
-{
-   int i, r;
-
-   cls_log("hello world");
-   cls_log("indata=%s", indata);
-
-   *outdata = (char *)cls_alloc(128);
-   for (i=0; i<strlen(indata) + 1; i++) {
-     if (indata[i] == '0') {
-       (*outdata)[i] = '*';
-     } else {
-       (*outdata)[i] = indata[i];
-     }
-   }
-   *outdatalen = strlen(*outdata) + 1;
-   cls_log("outdata=%s", *outdata);
-
-   r = cls_call(ctx, "foo", "foo", *outdata, *outdatalen, outdata, outdatalen);
-
-   return r;
-}
-
-static cls_deps_t depend[] = {{"foo", "1.0"}, {"bar", "1.0"}, {NULL, NULL}};
-
-extern "C" cls_deps_t *class_deps()
-{
-   return depend;
-};
-
-void class_init()
-{
-   cls_log("Loaded class test!");
-
-   cls_register("test", &h_class);
-   cls_register_method(h_class, "foo", foo_method, &h_foo);
-
-   return;
-}
-
diff --git a/src/testcrypto.cc b/src/testcrypto.cc
deleted file mode 100644 (file)
index 0b7a9d5..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "auth/Crypto.h"
-#include "common/Clock.h"
-
-#include "common/config.h"
-#include "common/debug.h"
-
-#define dout_subsys ceph_subsys_auth
-
-#define AES_KEY_LEN    16
-
-int main(int argc, char *argv[])
-{
-  char aes_key[AES_KEY_LEN];
-  memset(aes_key, 0x77, sizeof(aes_key));
-  bufferptr keybuf(aes_key, sizeof(aes_key));
-  CryptoKey key(CEPH_CRYPTO_AES, ceph_clock_now(g_ceph_context), keybuf);
-
-  const char *msg="hello! this is a message\n";
-  char pad[16];
-  memset(pad, 0, 16);
-  bufferptr ptr(msg, strlen(msg));
-  bufferlist enc_in;
-  enc_in.append(ptr);
-  enc_in.append(msg, strlen(msg));
-
-  bufferlist enc_out;
-  std::string error;
-  key.encrypt(g_ceph_context, enc_in, enc_out, error);
-  if (!error.empty()) {
-    dout(0) << "couldn't encode! error " << error << dendl;
-    exit(1);
-  }
-
-  const char *enc_buf = enc_out.c_str();
-  for (unsigned i=0; i<enc_out.length(); i++) {
-    std::cout << hex << (int)(unsigned char)enc_buf[i] << dec << " ";
-    if (i && !(i%16))
-      std::cout << std::endl;
-  }
-
-  bufferlist dec_in, dec_out;
-
-  dec_in = enc_out;
-
-  key.decrypt(g_ceph_context, dec_in, dec_out, error);
-  if (!error.empty()) {
-    dout(0) << "couldn't decode! error " << error << dendl;
-    exit(1);
-  }
-
-  dout(0) << "decoded len: " << dec_out.length() << dendl;
-  dout(0) << "decoded msg: " << dec_out.c_str() << dendl;
-
-  return 0;
-}
-
diff --git a/src/testkeys.cc b/src/testkeys.cc
deleted file mode 100644 (file)
index 27c3812..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "auth/cephx/CephxKeyServer.h"
-#include "common/ceph_argparse.h"
-#include "global/global_init.h"
-#include "common/config.h"
-
-#define AES_KEY_LEN    16
-
-int main(int argc, const char **argv)
-{
-  vector<const char*> args;
-  argv_to_vec(argc, argv, args);
-  env_to_vec(args);
-
-  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(g_ceph_context);
-  KeyRing extra;
-  KeyServer server(g_ceph_context, &extra);
-
-  generic_dout(0) << "server created" << dendl;
-
-  getchar();
-
-#if 0
-  char aes_key[AES_KEY_LEN];
-  memset(aes_key, 0x77, sizeof(aes_key));
-  bufferptr keybuf(aes_key, sizeof(aes_key));
-  CryptoKey key(CEPH_CRYPTO_AES, ceph_clock_now(g_ceph_context), keybuf);
-
-  const char *msg="hello! this is a message\n";
-  char pad[16];
-  memset(pad, 0, 16);
-  bufferptr ptr(msg, strlen(msg));
-  bufferlist enc_in;
-  enc_in.append(ptr);
-  enc_in.append(msg, strlen(msg));
-
-  bufferlist enc_out;
-  if (key.encrypt(enc_in, enc_out) < 0) {
-    derr(0) << "couldn't encode!" << dendl;
-    exit(1);
-  }
-
-  const char *enc_buf = enc_out.c_str();
-  for (unsigned i=0; i<enc_out.length(); i++) {
-    std::cout << hex << (int)(unsigned char)enc_buf[i] << dec << " ";
-    if (i && !(i%16))
-      std::cout << std::endl;
-  }
-
-  bufferlist dec_in, dec_out;
-
-  dec_in = enc_out;
-
-  if (key.decrypt(dec_in, dec_out) < 0) {
-    derr(0) << "couldn't decode!" << dendl;
-  }
-
-  dout(0) << "decoded len: " << dec_out.length() << dendl;
-  dout(0) << "decoded msg: " << dec_out.c_str() << dendl;
-
-  return 0;
-#endif
-}
-
diff --git a/src/testmsgr.cc b/src/testmsgr.cc
deleted file mode 100644 (file)
index 4de779b..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
- * Foundation.  See file COPYING.
- * 
- */
-
-#include <sys/stat.h>
-#include <iostream>
-#include <string>
-using namespace std;
-
-#include "common/config.h"
-
-#include "mon/MonMap.h"
-#include "mon/MonClient.h"
-#include "msg/Messenger.h"
-#include "messages/MPing.h"
-
-#include "common/Timer.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
-
-#ifndef DARWIN
-#include <envz.h>
-#endif // DARWIN
-
-#include <sys/types.h>
-#include <fcntl.h>
-
-#define dout_subsys ceph_subsys_ms
-
-Messenger *messenger = 0;
-
-Mutex lock("mylock");
-Cond cond;
-
-uint64_t received = 0;
-
-class Admin : public Dispatcher {
-public:
-  Admin() 
-    : Dispatcher(g_ceph_context)
-  {
-  }
-private:
-  bool ms_dispatch(Message *m) {
-
-    //cerr << "got ping from " << m->get_source() << std::endl;
-    dout(0) << "got ping from " << m->get_source() << dendl;
-    lock.Lock();
-    ++received;
-    cond.Signal();
-    lock.Unlock();
-
-    m->put();
-    return true;
-  }
-
-  bool ms_handle_reset(Connection *con) { return false; }
-  void ms_handle_remote_reset(Connection *con) {}
-
-} dispatcher;
-
-
-int main(int argc, const char **argv, const char *envp[]) {
-
-  vector<const char*> args;
-  argv_to_vec(argc, argv, args);
-  env_to_vec(args);
-
-  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(g_ceph_context);
-
-  dout(0) << "i am mon " << args[0] << dendl;
-
-  // get monmap
-  MonClient mc(g_ceph_context);
-  if (mc.build_initial_monmap() < 0)
-    return -1;
-  
-  // start up network
-  int whoami = mc.monmap.get_rank(args[0]);
-  assert(whoami >= 0);
-  ostringstream ss;
-  ss << mc.monmap.get_addr(whoami);
-  std::string sss(ss.str());
-  g_ceph_context->_conf->set_val("public_addr", sss.c_str());
-  g_ceph_context->_conf->apply_changes(NULL);
-  Messenger *rank = Messenger::create(g_ceph_context,
-                                     entity_name_t::MON(whoami), "tester",
-                                     getpid());
-  int err = rank->bind(g_ceph_context->_conf->public_addr);
-  if (err < 0)
-    return 1;
-
-  // start monitor
-  messenger = rank;
-  messenger->set_default_send_priority(CEPH_MSG_PRIO_HIGH);
-  messenger->add_dispatcher_head(&dispatcher);
-
-  rank->start();
-  
-  int isend = 0;
-  if (whoami == 0)
-    isend = 100;
-
-  lock.Lock();
-  uint64_t sent = 0;
-  while (1) {
-    while (received + isend <= sent) {
-      //cerr << "wait r " << received << " s " << sent << " is " << isend << std::endl;
-      dout(0) << "wait r " << received << " s " << sent << " is " << isend << dendl;
-      cond.Wait(lock);
-    }
-
-    int t = rand() % mc.get_num_mon();
-    if (t == whoami)
-      continue;
-    
-    if (rand() % 10 == 0) {
-      //cerr << "mark_down " << t << std::endl;
-      dout(0) << "mark_down " << t << dendl;
-      messenger->mark_down(mc.get_mon_addr(t));
-    } 
-    //cerr << "pinging " << t << std::endl;
-    dout(0) << "pinging " << t << dendl;
-    messenger->send_message(new MPing, mc.get_mon_inst(t));
-    cerr << isend << "\t" << ++sent << "\t" << received << "\r";
-  }
-  lock.Unlock();
-
-  // wait for messenger to finish
-  rank->wait();
-  
-  return 0;
-}
-