summaryrefslogtreecommitdiffstats
path: root/src/test/old
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2009-10-06 20:38:59 +0200
committerSage Weil <sage@newdream.net>2009-10-06 23:00:54 +0200
commited0841608788733c24aa2b6f5c68df1cc4fcdab6 (patch)
tree3f1ebc2591948f4642a02e2fe921bedd97f86836 /src/test/old
parentconf: also skip utf8 encoded characters that are not printable in current locale (diff)
downloadceph-ed0841608788733c24aa2b6f5c68df1cc4fcdab6.tar.xz
ceph-ed0841608788733c24aa2b6f5c68df1cc4fcdab6.zip
move tests around
Diffstat (limited to 'src/test/old')
-rw-r--r--src/test/old/test_disk_bw.cc59
-rw-r--r--src/test/old/test_seek_read.c63
-rw-r--r--src/test/old/test_setlayout.c24
-rw-r--r--src/test/old/test_short_seek_read.c70
-rw-r--r--src/test/old/testbucket.cc67
-rw-r--r--src/test/old/testbuffers.cc40
-rw-r--r--src/test/old/testcounter.cc70
-rw-r--r--src/test/old/testcrush.cc266
-rw-r--r--src/test/old/testfilepath.cc22
-rw-r--r--src/test/old/testmpi.cc53
-rw-r--r--src/test/old/testnewbuffers.cc91
-rw-r--r--src/test/old/testos.cc343
-rw-r--r--src/test/old/testosbdb.cc347
-rw-r--r--src/test/old/testtree.cc46
-rw-r--r--src/test/old/testxattr.cc30
15 files changed, 1591 insertions, 0 deletions
diff --git a/src/test/old/test_disk_bw.cc b/src/test/old/test_disk_bw.cc
new file mode 100644
index 00000000000..fc36da74fad
--- /dev/null
+++ b/src/test/old/test_disk_bw.cc
@@ -0,0 +1,59 @@
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/uio.h>
+
+#include "common/Clock.h"
+
+#include <iostream>
+using namespace std;
+
+int main(int argc, char **argv)
+{
+ void *buf;
+ int fd, count, loop = 0, ret;
+
+ if (argc != 4) {
+ fprintf(stderr, "Usage: %s device bsize count\n", argv[0]);
+ exit (0);
+ }
+
+ int bsize = atoi(argv[2]);
+ count = atoi(argv[3]);
+
+ posix_memalign(&buf, sysconf(_SC_PAGESIZE), bsize);
+
+ //if ((fd = open(argv[1], O_SYNC|O_RDWR)) < 0) {
+ if ((fd = open(argv[1], O_DIRECT|O_RDWR)) < 0) {
+
+ fprintf(stderr, "Can't open device %s\n", argv[1]);
+ exit (4);
+ }
+
+
+ utime_t start = g_clock.now();
+ while (loop++ < count) {
+ ret = ::write(fd, buf, bsize);
+ //if ((loop % 100) == 0)
+ //fprintf(stderr, ".");
+ }
+ ::fsync(fd);
+ ::close(fd);
+ utime_t end = g_clock.now();
+ end -= start;
+
+
+ char hostname[80];
+ gethostname(hostname, 80);
+
+ double mb = bsize*count/1024/1024;
+
+ cout << hostname << "\t" << mb << " MB\t" << end << " seconds\t" << (mb / (double)end) << " MB/sec" << std::endl;
+}
diff --git a/src/test/old/test_seek_read.c b/src/test/old/test_seek_read.c
new file mode 100644
index 00000000000..adfa95d4a2d
--- /dev/null
+++ b/src/test/old/test_seek_read.c
@@ -0,0 +1,63 @@
+#include "include/types.h"
+#include "common/Clock.h"
+
+#include <linux/fs.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+
+int main(int argc, char **argv)
+{
+ char *fn = argv[1];
+
+ int fd = ::open(fn, O_RDWR|O_DIRECT);//|O_SYNC|O_DIRECT);
+ if (fd < 0) return 1;
+
+ uint64_t bytes = 0;
+ int r = ioctl(fd, BLKGETSIZE64, &bytes);
+ uint64_t numblocks = bytes / 4096;
+
+ //uint64_t numblocks = atoll(argv[2]) * 4;// / 4096;
+ int count = 1000;
+
+ cout << "fn " << fn << endl;
+ cout << "numblocks " << numblocks << endl;
+
+ int blocks = 1;
+ while (blocks <= 1024) {
+ //cout << "fd is " << fd << endl;
+
+ void *buf;
+ ::posix_memalign(&buf, 4096, 4096*blocks);
+
+ int s = blocks*4096;
+
+ utime_t start = g_clock.now();
+ for (int i=0; i<count; i++) {
+ off64_t so, o = (lrand48() % numblocks) * 4096;
+ //cout << "s = " << s << " o = " << o << endl;
+ //::lseek(fd, o, SEEK_SET);
+ lseek64(fd, o, SEEK_SET);
+
+ int r = ::read(fd, buf, blocks*4096);
+ //int r = ::read(fd, buf, s);
+ if (r < 0) cout << "r = " << r << " " << strerror(errno) << endl;
+ }
+ utime_t end = g_clock.now();
+
+ double timeper = end - start;
+ timeper /= count;
+ cout << blocks << "\t" << s << "\t" << (double)timeper << endl;
+
+ blocks *= 2;
+ free(buf);
+ }
+
+ close(fd);
+
+}
+
diff --git a/src/test/old/test_setlayout.c b/src/test/old/test_setlayout.c
new file mode 100644
index 00000000000..d0ad8954e8f
--- /dev/null
+++ b/src/test/old/test_setlayout.c
@@ -0,0 +1,24 @@
+#define __USE_GNU 1
+#include <fcntl.h>
+#include <netinet/in.h>
+#include <linux/types.h>
+#include "include/ceph_fs.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "kernel/ioctl.h"
+
+
+main() {
+ struct ceph_file_layout l;
+ int fd = open("foo.txt", O_RDONLY);
+ int r = ioctl(fd, CEPH_IOC_GET_LAYOUT, &l, sizeof(l));
+ printf("get = %d\n", r);
+
+ l.fl_stripe_unit = 65536;
+ l.fl_object_size = 65536;
+
+ r = ioctl(fd, CEPH_IOC_SET_LAYOUT, &l, sizeof(l));
+ printf("set = %d\n", r);
+}
diff --git a/src/test/old/test_short_seek_read.c b/src/test/old/test_short_seek_read.c
new file mode 100644
index 00000000000..6eef26d5532
--- /dev/null
+++ b/src/test/old/test_short_seek_read.c
@@ -0,0 +1,70 @@
+#include "include/types.h"
+#include "common/Clock.h"
+
+#include <linux/fs.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+
+int main(int argc, char **argv)
+{
+ char *fn = argv[1];
+
+ int fd = ::open(fn, O_RDWR|O_DIRECT);//|O_SYNC|O_DIRECT);
+ if (fd < 0) return 1;
+
+ uint64_t bytes = 0;
+ int r = ioctl(fd, BLKGETSIZE64, &bytes);
+ uint64_t numblocks = bytes / 4096;
+
+ //uint64_t numblocks = atoll(argv[2]) * 4;// / 4096;
+ int count = 1000;
+
+ cout << "fn " << fn << endl;
+ cout << "numblocks " << numblocks << endl;
+
+ int blocks = 1;
+ while (blocks <= 1024) {
+ //cout << "fd is " << fd << endl;
+
+ void *buf;
+ ::posix_memalign(&buf, 4096, 4096*blocks);
+
+ int s = blocks*4096;
+
+ double timeper = 0.0;
+ for (int i=0; i<count; i++) {
+ off64_t so, o = (lrand48() % numblocks) * 4096;
+ //cout << "s = " << s << " o = " << o << endl;
+ //::lseek(fd, o, SEEK_SET);
+ lseek64(fd, o, SEEK_SET);
+ int r = ::read(fd, buf, 4096);
+ //int r = ::read(fd, buf, s);
+ if (r < 0) cout << "r = " << r << " " << strerror(errno) << endl;
+
+ int range = 1000000/4096;
+ so = o + 4096*((rand() % range) );//- range/2);
+ //cout << o << " " << so << " " << (so-o) << endl;
+
+ utime_t start = g_clock.now();
+ lseek64(fd, so, SEEK_SET);
+ r = ::read(fd, buf, blocks*4096);
+ utime_t end = g_clock.now();
+ timeper += (end-start);
+ }
+
+ timeper /= count;
+ cout << blocks << "\t" << s << "\t" << (double)timeper << endl;
+
+ blocks *= 2;
+ free(buf);
+ }
+
+ close(fd);
+
+}
+
diff --git a/src/test/old/testbucket.cc b/src/test/old/testbucket.cc
new file mode 100644
index 00000000000..d8676da18fa
--- /dev/null
+++ b/src/test/old/testbucket.cc
@@ -0,0 +1,67 @@
+
+
+#include "../crush/Bucket.h"
+using namespace crush;
+
+#include <iostream>
+#include <vector>
+using namespace std;
+
+
+ostream& operator<<(ostream& out, vector<int>& v)
+{
+ out << "[";
+ for (int i=0; i<v.size(); i++) {
+ if (i) out << " ";
+ out << v[i];
+ }
+ out << "]";
+ return out;
+}
+
+
+int main()
+{
+ Hash h(73);
+
+ vector<int> disks;
+ for (int i=0; i<20; i++)
+ disks.push_back(i);
+
+
+ /*
+ UniformBucket ub(1, 1, 0, 10, disks);
+ ub.make_primes(h);
+ cout << "primes are " << ub.primes << endl;
+ */
+
+ MixedBucket mb(2, 1);
+ for (int i=0;i<20;i++)
+ mb.add_item(i, 10);
+
+ /*
+ MixedBucket b(3, 1);
+ b.add_item(1, ub.get_weight());
+ b.add_item(2, mb.get_weight());
+ */
+ MixedBucket b= mb;
+
+ vector<int> ocount(disks.size());
+ int numrep = 3;
+
+ vector<int> v(numrep);
+ for (int x=1; x<1000000; x++) {
+ //cout << H(x) << "\t" << h(x) << endl;
+ for (int i=0; i<numrep; i++) {
+ int d = b.choose_r(x, i, h);
+ v[i] = d;
+ ocount[d]++;
+ }
+ //cout << v << "\t" << endl;//ocount << endl;
+ }
+
+ for (int i=0; i<ocount.size(); i++) {
+ cout << "disk " << i << " has " << ocount[i] << endl;
+ }
+
+}
diff --git a/src/test/old/testbuffers.cc b/src/test/old/testbuffers.cc
new file mode 100644
index 00000000000..be2298ff838
--- /dev/null
+++ b/src/test/old/testbuffers.cc
@@ -0,0 +1,40 @@
+
+#include <iostream>
+using namespace std;
+
+#include "include/bufferlist.h"
+
+
+int main()
+{
+
+ bufferptr p1 = new buffer("123456",6);
+ bufferptr p2 = p1;
+
+ cout << "it is '" << p1.c_str() << "'" << endl;
+
+ bufferptr p3 = new buffer("abcdef",6);
+
+ cout << "p3 is " << p3 << endl;
+
+ bufferlist bl;
+ bl.push_back(p2);
+ bl.push_back(p1);
+ bl.push_back(p3);
+
+ cout << "bl is " << bl << endl;
+
+ cout << "len is " << bl.length() << endl;
+
+ bufferlist took;
+ bl.splice(10,4,&took);
+
+ cout << "took out " << took << "leftover is " << bl << endl;
+ //cout << "len is " << bl.length() << endl;
+
+ bufferlist bl2;
+ bl2.substr_of(bl, 3, 5);
+ cout << "bl2 is " << bl2 << endl;
+
+
+}
diff --git a/src/test/old/testcounter.cc b/src/test/old/testcounter.cc
new file mode 100644
index 00000000000..a3194489e48
--- /dev/null
+++ b/src/test/old/testcounter.cc
@@ -0,0 +1,70 @@
+
+#include "common/DecayCounter.h"
+
+#include <list>
+using namespace std;
+
+struct RealCounter {
+public:
+ list<int> hits;
+
+ void hit(int ms) {
+ hits.push_back(ms);
+ }
+
+ int get(double hl, int now) {
+ trim(now-hl);
+ return hits.size();
+ }
+
+ void trim(int to) {
+ while (!hits.empty() &&
+ hits.front() < to)
+ hits.pop_front();
+ }
+
+
+};
+
+int main(int argc, char **argv)
+{
+ int target;
+ double hl = atof(argv[1]);
+ cerr << "halflife " << hl << endl;
+
+ DecayCounter dc(hl);
+ RealCounter rc;
+
+ utime_t now = g_clock.now();
+
+ for (int ms=0; ms < 300*1000; ms++) {
+ if (ms % 30000 == 0) {
+ target = 1 + (rand() % 10) * 10;
+ if (ms > 200000) target = 0;
+ }
+
+ if (target &&
+ (rand() % (1000/target) == 0)) {
+ dc.hit();
+ rc.hit(ms);
+ }
+
+ if (ms % 500 == 0) dc.get(now);
+ if (ms % 100 == 0) {
+ //dc.get(now);
+ DecayCounter o = dc;
+ cout << ms << "\t"
+ << target*hl << "\t"
+ << rc.get(hl*1000, ms) << "\t"
+ << o.get(now) << "\t"
+ << dc.val << "\t"
+ // << dc.delta << "\t"
+ << o.get_last_vel() << "\t"
+ << o.get_last() + o.get_last_vel() << "\t"
+ << endl;
+ }
+
+ now += .001;
+ }
+
+}
diff --git a/src/test/old/testcrush.cc b/src/test/old/testcrush.cc
new file mode 100644
index 00000000000..bd432b23ee9
--- /dev/null
+++ b/src/test/old/testcrush.cc
@@ -0,0 +1,266 @@
+
+
+#include "../crush/crush.h"
+using namespace crush;
+
+#include <math.h>
+
+#include <iostream>
+#include <vector>
+using namespace std;
+
+/*
+ostream& operator<<(ostream& out, vector<int>& v)
+{
+ out << "[";
+ for (int i=0; i<v.size(); i++) {
+ if (i) out << " ";
+ out << v[i];
+ }
+ out << "]";
+ return out;
+}
+*/
+
+void make_disks(int n, int& no, vector<int>& d)
+{
+ d.clear();
+ while (n) {
+ d.push_back(no);
+ no++;
+ n--;
+ }
+}
+
+
+Bucket *make_bucket(Crush& c, vector<int>& wid, int h, int& ndisks, int& nbuckets)
+{
+ if (h == 0) {
+ // uniform
+ Hash hash(123);
+ vector<int> disks;
+ for (int i=0; i<wid[h]; i++)
+ disks.push_back(ndisks++);
+ UniformBucket *b = new UniformBucket(nbuckets--, 1, 0, 10, disks);
+ b->make_primes(hash);
+ c.add_bucket(b);
+ //cout << h << " uniformbucket with " << wid[h] << " disks" << endl;
+ return b;
+ } else {
+ // mixed
+ MixedBucket *b = new MixedBucket(nbuckets--, h+1);
+ for (int i=0; i<wid[h]; i++) {
+ Bucket *n = make_bucket(c, wid, h-1, ndisks, nbuckets);
+ b->add_item(n->get_id(), n->get_weight());
+ }
+ c.add_bucket(b);
+ //cout << h << " mixedbucket with " << wid[h] << endl;
+ return b;
+ }
+}
+
+int make_hierarchy(Crush& c, vector<int>& wid, int& ndisks, int& nbuckets)
+{
+ Bucket *b = make_bucket(c, wid, wid.size()-1, ndisks, nbuckets);
+ return b->get_id();
+}
+
+
+
+int main()
+{
+ Hash h(73232313);
+
+ // crush
+ Crush c;
+
+
+ // buckets
+ vector<int> disks;
+ int root = -1;
+ int nbuckets = -1;
+ int ndisks = 0;
+
+ if (0) {
+ make_disks(12, ndisks, disks);
+ UniformBucket ub1(-1, 1, 0, 30, disks);
+ ub1.make_primes(h);
+ cout << "ub1 primes are " << ub1.primes << endl;
+ c.add_bucket(&ub1);
+
+ make_disks(17, ndisks, disks);
+ UniformBucket ub2(-2, 1, 0, 30, disks);
+ ub2.make_primes(h);
+ cout << "ub2 primes are " << ub2.primes << endl;
+ c.add_bucket(&ub2);
+
+ make_disks(4, ndisks, disks);
+ UniformBucket ub3(-3, 1, 0, 30, disks);
+ ub3.make_primes(h);
+ cout << "ub3 primes are " << ub3.primes << endl;
+ c.add_bucket(&ub3);
+
+ make_disks(20, ndisks, disks);
+ MixedBucket umb1(-4, 1);
+ for (int i=0; i<20; i++)
+ umb1.add_item(disks[i], 30);
+ c.add_bucket(&umb1);
+
+ MixedBucket b(-100, 1);
+ //b.add_item(-2, ub1.get_weight());
+ b.add_item(-4, umb1.get_weight());
+ //b.add_item(-2, ub2.get_weight());
+ //b.add_item(-3, ub3.get_weight());
+ }
+
+ if (0) {
+ int bucket = -1;
+ MixedBucket *root = new MixedBucket(bucket--, 2);
+
+ for (int i=0; i<5; i++) {
+ MixedBucket *b = new MixedBucket(bucket--, 1);
+
+ int n = 5;
+
+ if (1) {
+ // add n buckets of n disks
+ for (int j=0; j<n; j++) {
+
+ MixedBucket *d = new MixedBucket(bucket--, 1);
+
+ make_disks(n, ndisks, disks);
+ for (int k=0; k<n; k++)
+ d->add_item(disks[k], 10);
+
+ //b->add_item(disks[j], 10);
+ c.add_bucket(d);
+ b->add_item(d->get_id(), d->get_weight());
+ }
+
+ c.add_bucket(b);
+ root->add_item(b->get_id(), b->get_weight());
+ } else {
+ // add n*n disks
+ make_disks(n*n, ndisks, disks);
+ for (int k=0; k<n*n; k++)
+ b->add_item(disks[k], 10);
+
+ c.add_bucket(b);
+ root->add_item(b->get_id(), b->get_weight());
+ }
+ }
+
+ c.add_bucket(root);
+ }
+
+
+ if (1) {
+ vector<int> wid;
+ for (int d=0; d<5; d++)
+ wid.push_back(10);
+ root = make_hierarchy(c, wid, ndisks, nbuckets);
+ }
+
+
+
+ // rule
+ int numrep = 1;
+
+ Rule rule;
+ if (0) {
+ rule.steps.push_back(RuleStep(CRUSH_RULE_TAKE, -100));
+ rule.steps.push_back(RuleStep(CRUSH_RULE_CHOOSE, numrep, 0));
+ }
+ if (1) {
+ /*
+ rule.steps.push_back(RuleStep(CRUSH_RULE_TAKE, -4));
+ rule.steps.push_back(RuleStep(CRUSH_RULE_CHOOSE, 2, 0));
+ rule.steps.push_back(RuleStep(CRUSH_RULE_EMIT));
+ */
+ rule.steps.push_back(RuleStep(CRUSH_RULE_TAKE, root));
+ rule.steps.push_back(RuleStep(CRUSH_RULE_CHOOSE, 1, 0));
+ rule.steps.push_back(RuleStep(CRUSH_RULE_EMIT));
+ }
+
+ //c.overload[10] = .1;
+
+
+ int pg_per = 100;
+ int numpg = pg_per*ndisks/numrep;
+
+ vector<int> ocount(ndisks);
+ cout << ndisks << " disks, " << 1-nbuckets << " buckets" << endl;
+ cout << pg_per << " pgs per disk" << endl;
+ cout << numpg << " logical pgs" << endl;
+ cout << "numrep is " << numrep << endl;
+
+
+ int place = 1000000;
+ int times = place / numpg;
+ if (!times) times = 1;
+
+ cout << "looping " << times << " times" << endl;
+
+ float tvar = 0;
+ int tvarnum = 0;
+
+ int x = 0;
+ for (int t=0; t<times; t++) {
+ vector<int> v(numrep);
+
+ for (int z=0; z<ndisks; z++) ocount[z] = 0;
+
+ for (int xx=1; xx<numpg; xx++) {
+ x++;
+
+ //cout << H(x) << "\t" << h(x) << endl;
+ c.do_rule(rule, x, v);
+ //cout << "v = " << v << endl;// " " << v[0] << " " << v[1] << " " << v[2] << endl;
+
+ bool bad = false;
+ for (int i=0; i<numrep; i++) {
+ //int d = b.choose_r(x, i, h);
+ //v[i] = d;
+ ocount[v[i]]++;
+ for (int j=i+1; j<numrep; j++) {
+ if (v[i] == v[j])
+ bad = true;
+ }
+ }
+ if (bad)
+ cout << "bad set " << x << ": " << v << endl;
+
+ //cout << v << "\t" << ocount << endl;
+ }
+
+ /*
+ for (int i=0; i<ocount.size(); i++) {
+ cout << "disk " << i << " has " << ocount[i] << endl;
+ }
+ */
+
+ cout << "collisions: " << c.collisions << endl;
+ cout << "r bumps: " << c.bumps << endl;
+
+
+ float avg = 0.0;
+ for (int i=0; i<ocount.size(); i++)
+ avg += ocount[i];
+ avg /= ocount.size();
+ float var = 0.0;
+ for (int i=0; i<ocount.size(); i++)
+ var += (ocount[i] - avg) * (ocount[i] - avg);
+ var /= ocount.size();
+
+ cout << "avg " << avg << " var " << var << " sd " << sqrt(var) << endl;
+
+ tvar += var;
+ tvarnum++;
+ }
+
+ tvar /= tvarnum;
+
+ cout << "total variance " << tvar << endl;
+
+
+}
diff --git a/src/test/old/testfilepath.cc b/src/test/old/testfilepath.cc
new file mode 100644
index 00000000000..ac21e106963
--- /dev/null
+++ b/src/test/old/testfilepath.cc
@@ -0,0 +1,22 @@
+
+#include "include/filepath.h"
+#include <iostream>
+using namespace std;
+
+int print(string s) {
+ filepath fp = s;
+ cout << "s = " << s << " filepath = " << fp << endl;
+ cout << " depth " << fp.depth() << endl;
+ for (int i=0; i<fp.depth(); i++) {
+ cout << "\t" << i << " " << fp[i] << endl;
+ }
+}
+
+int main() {
+ filepath p;
+ print("/home/sage");
+ print("a/b/c");
+ print("/a/b/c");
+ print("/a/b/c/");
+ print("/a/b/../d");
+}
diff --git a/src/test/old/testmpi.cc b/src/test/old/testmpi.cc
new file mode 100644
index 00000000000..3d0125992d2
--- /dev/null
+++ b/src/test/old/testmpi.cc
@@ -0,0 +1,53 @@
+#include <sys/stat.h>
+#include <iostream>
+#include <string>
+using namespace std;
+
+#include "config.h"
+#include "messages/MPing.h"
+#include "common/Mutex.h"
+
+#include "msg/MPIMessenger.h"
+
+class Pinger : public Dispatcher {
+public:
+ Messenger *messenger;
+ Pinger(Messenger *m) : messenger(m) {
+ m->set_dispatcher(this);
+ }
+ void dispatch(Message *m) {
+ //dout(1) << "got incoming " << m << endl;
+ delete m;
+
+ }
+};
+
+int main(int argc, char **argv) {
+ int num = 1000;
+
+ int myrank = mpimessenger_init(argc, argv);
+ int world = mpimessenger_world();
+
+ Pinger *p = new Pinger( new MPIMessenger(myrank) );
+
+ mpimessenger_start();
+
+ //while (1) {
+ for (int i=0; i<10000; i++) {
+
+ // ping random nodes
+ int d = rand() % world;
+ if (d != myrank) {
+ //cout << "sending " << i << " to " << d << endl;
+ p->messenger->send_message(new MPing(), d);
+ }
+
+ }
+
+
+ //cout << "shutting down" << endl;
+ //p->messenger->shutdown();
+
+ mpimessenger_wait();
+ mpimessenger_shutdown(); // shutdown MPI
+}
diff --git a/src/test/old/testnewbuffers.cc b/src/test/old/testnewbuffers.cc
new file mode 100644
index 00000000000..0fea7571a45
--- /dev/null
+++ b/src/test/old/testnewbuffers.cc
@@ -0,0 +1,91 @@
+
+#include <list>
+#include <iostream>
+using namespace std;
+
+
+#include "include/newbuffer.h"
+//#include "include/bufferlist.h"
+
+#include "common/Thread.h"
+
+
+ class Th : public Thread {
+ public:
+ bufferlist bl;
+ Th(bufferlist& o) : bl(o) { }
+
+ void *entry() {
+ //cout << "start" << endl;
+ // thrash it a bit.
+ for (int n=0; n<10000; n++) {
+ bufferlist bl2;
+ unsigned off = rand() % (bl.length() -1);
+ unsigned len = 1 + rand() % (bl.length() - off - 1);
+ bl2.substr_of(bl, off, len);
+ bufferlist bl3;
+ bl3.append(bl);
+ bl3.append(bl2);
+ //cout << bl3 << endl;
+ bl2.clear();
+ bl3.clear();
+ }
+ //cout << "end" << endl;
+ }
+ };
+
+int main()
+{
+
+ bufferptr p1 = buffer::copy("123456",7);
+ //bufferptr p1 = new buffer("123456",7);
+ bufferptr p2 = p1;
+
+ cout << "p1 is '" << p1.c_str() << "'" << " " << p1 << endl;
+ cout << "p2 is '" << p2.c_str() << "'" << " " << p2 << endl;
+
+ bufferptr p3 = buffer::copy("abcdef",7);
+ //bufferptr p3 = new buffer("abcdef",7);
+
+ cout << "p3 is " << p3.c_str() << " " << p3 << endl;
+
+ bufferlist bl;
+ bl.push_back(p2);
+ bl.push_back(p1);
+ bl.push_back(p3);
+
+ cout << "bl is " << bl << endl;
+
+ bufferlist took;
+ bl.splice(10,4,&took);
+
+ cout << "took out " << took << ", leftover is " << bl << endl;
+ //cout << "len is " << bl.length() << endl;
+
+ bufferlist bl2;
+ bl2.substr_of(bl, 3, 5);
+ cout << "bl2 is " << bl2 << endl;
+
+
+ cout << "bl before " << bl << endl;
+
+ list<Th*> ls;
+ for (int t=0; t<40; t++) {
+ Th *t = new Th(bl);
+ cout << "create" << endl;
+ t->create();
+ ls.push_back(t);
+ }
+
+ bl.clear();
+
+ while (!ls.empty()) {
+ cout << "join" << endl;
+ ls.front()->join();
+ delete ls.front();
+ ls.pop_front();
+ }
+
+ cout << "bl after " << bl << endl;
+
+}
diff --git a/src/test/old/testos.cc b/src/test/old/testos.cc
new file mode 100644
index 00000000000..24c81590d89
--- /dev/null
+++ b/src/test/old/testos.cc
@@ -0,0 +1,343 @@
+/* testos.cc -- simple ObjectStore test harness.
+ Copyright (C) 2007 Casey Marshall <csm@soe.ucsc.edu>
+
+Ceph - scalable distributed file system
+
+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 "osd/ObjectStore.h"
+#include "ebofs/Ebofs.h"
+#include "osbdb/OSBDB.h"
+#include "include/buffer.h"
+
+#include <iostream>
+#include <cerrno>
+#include <vector>
+
+#include <fcntl.h>
+#include <sys/mount.h>
+
+using namespace std;
+
+static inline unsigned long long
+to_usec (struct timeval &time)
+{
+ return (((unsigned long long) time.tv_sec * 1000000)
+ + ((unsigned long long) time.tv_usec));
+}
+
+static inline unsigned long long
+to_msec (struct timeval &time)
+{
+ return (((unsigned long long) time.tv_sec * 1000)
+ + ((unsigned long long) time.tv_usec / 1000));
+}
+
+int main (int argc, char **argv)
+{
+ vector<char *> args;
+ char *osd_name = "ebofs";
+ unsigned object_size = 1024;
+ unsigned object_count = 1024;
+ unsigned write_iter = 64;
+ unsigned random_seed = ::time(NULL);
+ char *device = "/tmp/testos";
+ char *mountcmd = "mount /tmp/testos";
+ char *umountcmd = "umount /tmp/testos";
+
+ bool ebofs_raw_device = false;
+ bool inhibit_remount = (getenv("TESTOS_INHIBIT_REMOUNT") != NULL);
+
+ if (argc > 1
+ && (strcmp (argv[1], "-h") == 0
+ || strcmp (argv[1], "-help") == 0
+ || strcmp (argv[1], "--help") == 0))
+ {
+ cout << "usage: " << argv[0] << " [store [object-size [object-count [iterations [seed]]]]]" << endl;
+ cout << endl;
+ cout << "Where the arguments are:" << endl << endl;
+ cout << " store -- store type; default \"ebofs\"" << endl;
+ cout << " object-size -- size of objects; default 1024" << endl;
+ cout << " object-count -- number of objects to write; default 1024"
+ << endl;
+ cout << " iterations -- write the objects that many times; default 5"
+ << endl;
+ cout << " seed -- random seed; default current time" << endl;
+ exit (0);
+ }
+
+ argv_to_vec (argc, argv, args);
+ for (vector<char*>::iterator it = args.begin(); it != args.end();
+ it++)
+ cout << *it << " ";
+ cout << endl;
+ parse_config_options (args);
+ for (vector<char*>::iterator it = args.begin(); it != args.end();
+ it++)
+ cout << *it << " ";
+ cout << endl;
+
+ argc = args.size();
+ if (argc > 0)
+ osd_name = args[0];
+ if (argc > 1)
+ object_size = (unsigned) atol (args[1]);
+ if (argc > 2)
+ object_count = (unsigned) atol (args[2]);
+ if (argc > 3)
+ write_iter = (unsigned) atol (args[3]);
+ if (argc > 4)
+ random_seed = (unsigned) atol (args[4]);
+
+ // algin object size to 'long'
+ object_size = ((object_size + (sizeof (long) - 1)) / sizeof (long)) * sizeof (long);
+
+ char *osd_file = new char[32];
+ strcpy (osd_file, "/tmp/testos/testos.XXXXXX");
+ mktemp (osd_file);
+
+ if (strcasecmp (osd_name, "ebofs") == 0)
+ {
+ char *dev_env = getenv ("TESTOS_EBOFS_DEV");
+ if (dev_env != NULL)
+ {
+ // Assume it is a true device.
+ strncpy (osd_file, dev_env, 32);
+ inhibit_remount = true;
+ ebofs_raw_device = true;
+ }
+ }
+
+ if (!inhibit_remount)
+ {
+ if (system (mountcmd) != 0)
+ {
+ cerr << "mount failed" << endl;
+ exit (1);
+ }
+ }
+
+ ObjectStore *os = NULL;
+ if (strcasecmp (osd_name, "ebofs") == 0)
+ {
+ if (!ebofs_raw_device)
+ {
+ FILE *f = fopen (osd_file, "w");
+ if (f == NULL)
+ {
+ cerr << "failed to open " << osd_file << ": " << strerror (errno)
+ << endl;
+ exit (1);
+ }
+ // 1G file.
+ fseek (f, 1024 * 1024 * 1024, SEEK_SET);
+ fputc ('\0', f);
+ fclose (f);
+ }
+ os = new Ebofs (osd_file);
+ }
+ else if (strcasecmp (osd_name, "osbdb") == 0)
+ {
+ os = new OSBDB (osd_file);
+ }
+ else if (strcasecmp (osd_name, "osbdb-btree") == 0)
+ {
+ g_conf.bdbstore_btree = true;
+ os = new OSBDB (osd_file);
+ }
+ else
+ {
+ cerr << "I don't know about object store \"" << osd_name << "\""
+ << endl;
+ exit (1);
+ }
+
+ cout << "Writing " << object_count << " objects of size "
+ << object_size << " to " << osd_name << endl;
+
+ char *val = (char *) malloc (object_size);
+ char *val2 = (char *) malloc (object_size);
+ auto_ptr<char> valptr (val);
+ auto_ptr<char> valptr2(val2);
+ if (getenv ("TESTOS_UNALIGNED") != NULL)
+ {
+ val = val + 1;
+ val2 = val2 + 1;
+ }
+
+ for (unsigned i = 0; i < object_size; i++)
+ {
+ val[i] = (char) i;
+ val2[i] = (char) i;
+ }
+ object_t *oids = new object_t[object_count];
+
+ utime_t writes[write_iter];
+ utime_t total_write;
+ utime_t reads[write_iter];
+ utime_t total_read;
+ for (unsigned i = 0; i < write_iter; i++)
+ {
+ cerr << "Iteration " << i << endl;
+
+ int ret = os->mkfs();
+ if (ret != 0)
+ {
+ cerr << "mkfs(" << osd_file << "): " << strerror (-ret) << endl;
+ exit (1);
+ }
+ ret = os->mount();
+ if (ret != 0)
+ {
+ cerr << "mount(): " << strerror (-ret) << endl;
+ exit (1);
+ }
+
+ srandom (random_seed + i);
+
+ for (unsigned j = 0; j < object_count; j++)
+ {
+ oids[j].ino = (uint64_t) random() << 32 | random();
+ oids[j].bno = random();
+ }
+
+ utime_t begin = g_clock.now();
+ for (unsigned o = 0; o < object_count; o++)
+ {
+ bufferptr bp (val, object_size);
+ bufferlist bl;
+ bl.push_back (bp);
+ int ret;
+ if ((ret = os->write (oids[o], 0L, object_size, bl, NULL)) < 0)
+ cerr << "write " << oids[o] << " failed: "
+ << strerror (-ret) << endl;
+ }
+ os->sync();
+
+ utime_t end = g_clock.now() - begin;
+
+ cerr << "Write finished in " << end << endl;
+ total_write += end;
+ writes[i] = end;
+
+ os->umount();
+ sync();
+
+ if (!inhibit_remount)
+ {
+ if (system (umountcmd) != 0)
+ {
+ cerr << "umount failed" << endl;
+ exit (1);
+ }
+
+ if (system (mountcmd) != 0)
+ {
+ cerr << "mount(2) failed" << endl;
+ exit (1);
+ }
+ }
+
+ os->mount();
+
+ // Shuffle the OIDs.
+ for (int j = 0; j < object_count; j++)
+ {
+ int x = random() % object_count;
+ if (x < 0)
+ x = -x;
+ object_t o = oids[j];
+ oids[j] = oids[x];
+ oids[x] = o;
+ }
+
+ begin = g_clock.now();
+ for (unsigned o = 0; o < object_count; o++)
+ {
+ bufferptr bp (val2, object_size);
+ bufferlist bl;
+ bl.push_back (bp);
+
+ if (os->read (oids[o], 0L, object_size, bl) < 0)
+ {
+ cerr << "object " << oids[o] << " not found!" << endl;
+ }
+ }
+ end = g_clock.now() - begin;
+
+ cerr << "Read finished in " << end << endl;
+ total_read += end;
+ reads[i] = end;
+
+ os->umount();
+ sync();
+
+ if (!inhibit_remount)
+ {
+ if (system (umountcmd) != 0)
+ {
+ cerr << "umount(2) failed" << endl;
+ exit (1);
+ }
+
+ if (system (mountcmd) != 0)
+ {
+ cerr << "mount(3) failed" << endl;
+ exit (1);
+ }
+ }
+ }
+
+ cerr << "Finished in " << (total_write + total_read) << endl;
+
+ double write_mean = ((double) total_write) / ((double) write_iter);
+ double write_sd = 0.0;
+ for (unsigned i = 0; i < write_iter; i++)
+ {
+ double x = ((double) writes[i]) - write_mean;
+ write_sd += x * x;
+ }
+ write_sd = sqrt (write_sd / ((double) write_iter));
+
+ double read_mean = ((double) total_read) / ((double) write_iter);
+ double read_sd = 0.0;
+ for (unsigned i = 0; i < write_iter; i++)
+ {
+ double x = ((double) reads[i]) - read_mean;
+ write_sd += x * x;
+ }
+ read_sd = sqrt (read_sd / ((double) write_iter));
+
+ cout << "TESTOS: write " << osd_name << ":" << object_size << ":"
+ << object_count << ":" << write_iter << ":" << random_seed
+ << " -- " << write_mean << " " << write_sd << endl;
+
+ cout << "TESTOS: write.raw -- ";
+ for (int i = 0; i < write_iter; i++)
+ cout << ((double) writes[i]) << " ";
+ cout << endl;
+
+ cout << "TESTOS: read " << osd_name << ":" << object_size << ":"
+ << object_count << ":" << write_iter << ":" << random_seed
+ << " -- " << read_mean << " " << read_sd << endl;
+
+ cout << "TESTOS: read.raw -- ";
+ for (int i = 0; i < write_iter; i++)
+ cout << ((double) reads[i]) << " ";
+ cout << endl;
+
+ unlink (osd_file);
+ if (!inhibit_remount)
+ {
+ if (system (umountcmd) != 0)
+ {
+ cerr << "umount(3) failed" << endl;
+ exit (1);
+ }
+ }
+ exit (0);
+}
diff --git a/src/test/old/testosbdb.cc b/src/test/old/testosbdb.cc
new file mode 100644
index 00000000000..19268e75875
--- /dev/null
+++ b/src/test/old/testosbdb.cc
@@ -0,0 +1,347 @@
+/* testosbdb.cc -- test OSBDB.
+ Copyright (C) 2007 Casey Marshall <csm@soe.ucsc.edu> */
+
+
+#include <iostream>
+#include "osbdb/OSBDB.h"
+
+using namespace std;
+
+int
+main (int argc, char **argv)
+{
+ vector<char *> args;
+ argv_to_vec (argc, argv, args);
+ parse_config_options (args);
+
+ g_conf.debug_bdbstore = 10;
+ //g_conf.bdbstore_btree = true;
+ char dbfile[256];
+ strncpy (dbfile, "/tmp/testosbdb/db.XXXXXX", 256);
+ mktemp (dbfile);
+ OSBDB *os = new OSBDB(dbfile);
+ auto_ptr<OSBDB> osPtr (os);
+ os->mkfs();
+ os->mount();
+
+ // Put an object.
+ object_t oid (0xDEADBEEF00000000ULL, 0xFEEDFACE);
+
+ cout << "sizeof oid_t is " << sizeof (oid_t) << endl;
+ cout << "offsetof oid_t.id " << offsetof (oid_t, id) << endl;
+
+ cout << sizeof (object_t) << endl;
+ cout << sizeof (oid.ino) << endl;
+ cout << sizeof (oid.bno) << endl;
+ cout << sizeof (oid.rev) << endl;
+
+ // Shouldn't be there.
+ if (os->exists (oid))
+ {
+ cout << "FAIL: oid shouldn't be there " << oid << endl;
+ }
+
+ // Write an object.
+ char *x = (char *) malloc (1024);
+ memset(x, 0xaa, 1024);
+ bufferptr bp (x, 1024);
+ bufferlist bl;
+ bl.push_back (bp);
+
+ if (os->write (oid, 0L, 1024, bl, NULL) != 1024)
+ {
+ cout << "FAIL: writing object" << endl;
+ }
+
+ os->sync();
+
+ // Should be there.
+ if (!os->exists (oid))
+ {
+ cout << "FAIL: oid should be there: " << oid << endl;
+ }
+
+ memset(x, 0, 1024);
+ if (os->read (oid, 0, 1024, bl) != 1024)
+ {
+ cout << "FAIL: reading object" << endl;
+ }
+
+ for (int i = 0; i < 1024; i++)
+ {
+ if ((x[i] & 0xFF) != 0xaa)
+ {
+ cout << "FAIL: data read out is different" << endl;
+ break;
+ }
+ }
+
+ // Set some attributes
+ if (os->setattr (oid, "alpha", "value", strlen ("value")) != 0)
+ {
+ cout << "FAIL: set attribute" << endl;
+ }
+ if (os->setattr (oid, "beta", "value", strlen ("value")) != 0)
+ {
+ cout << "FAIL: set attribute" << endl;
+ }
+ if (os->setattr (oid, "gamma", "value", strlen ("value")) != 0)
+ {
+ cout << "FAIL: set attribute" << endl;
+ }
+ if (os->setattr (oid, "fred", "value", strlen ("value")) != 0)
+ {
+ cout << "FAIL: set attribute" << endl;
+ }
+
+ char *attrs = (char *) malloc (1024);
+ if (os->listattr (oid, attrs, 1024) != 0)
+ {
+ cout << "FAIL: listing attributes" << endl;
+ }
+ else
+ {
+ char *p = attrs;
+ if (strcmp (p, "alpha") != 0)
+ {
+ cout << "FAIL: should be \"alpha:\" \"" << p << "\"" << endl;
+ }
+ p = p + strlen (p) + 1;
+ if (strcmp (p, "beta") != 0)
+ {
+ cout << "FAIL: should be \"beta:\" \"" << p << "\"" << endl;
+ }
+ p = p + strlen (p) + 1;
+ if (strcmp (p, "fred") != 0)
+ {
+ cout << "FAIL: should be \"fred:\" \"" << p << "\"" << endl;
+ }
+ p = p + strlen (p) + 1;
+ if (strcmp (p, "gamma") != 0)
+ {
+ cout << "FAIL: should be \"gamma:\" \"" << p << "\"" << endl;
+ }
+ }
+
+ char attrvalue[256];
+ memset(attrvalue, 0, sizeof (attrvalue));
+ if (os->getattr (oid, "alpha", attrvalue, sizeof(attrvalue)) < 0)
+ {
+ cout << "FAIL: getattr alpha" << endl;
+ }
+ else if (strncmp ("value", attrvalue, strlen("value")) != 0)
+ {
+ cout << "FAIL: read attribute value differs" << endl;
+ }
+ memset(attrvalue, 0, sizeof (attrvalue));
+ if (os->getattr (oid, "fred", attrvalue, sizeof(attrvalue)) < 0)
+ {
+ cout << "FAIL: getattr fred" << endl;
+ }
+ else if (strncmp ("value", attrvalue, strlen("value")) != 0)
+ {
+ cout << "FAIL: read attribute value differs" << endl;
+ }
+ memset(attrvalue, 0, sizeof (attrvalue));
+ if (os->getattr (oid, "beta", attrvalue, sizeof(attrvalue)) < 0)
+ {
+ cout << "FAIL: getattr beta" << endl;
+ }
+ else if (strncmp ("value", attrvalue, strlen("value")) != 0)
+ {
+ cout << "FAIL: read attribute value differs" << endl;
+ }
+ memset(attrvalue, 0, sizeof (attrvalue));
+ if (os->getattr (oid, "gamma", attrvalue, sizeof(attrvalue)) < 0)
+ {
+ cout << "FAIL: getattr gamma" << endl;
+ }
+ else if (strncmp ("value", attrvalue, strlen("value")) != 0)
+ {
+ cout << "FAIL: read attribute value differs" << endl;
+ }
+
+ if (os->setattr (oid, "alpha", "different", strlen("different")) != 0)
+ cout << "FAIL: setattr overwrite" << endl;
+ memset(attrvalue, 0, sizeof (attrvalue));
+ if (os->getattr (oid, "alpha", attrvalue, sizeof(attrvalue)) < 0)
+ {
+ cout << "FAIL: getattr alpha" << endl;
+ }
+ else if (strncmp ("different", attrvalue, strlen("different")) != 0)
+ {
+ cout << "FAIL: read attribute value differs" << endl;
+ }
+
+ if (os->rmattr (oid, "alpha") != 0)
+ {
+ cout << "FAIL: rmattr alpha" << endl;
+ }
+ if (os->rmattr (oid, "fred") != 0)
+ {
+ cout << "FAIL: rmattr fred" << endl;
+ }
+ if (os->rmattr (oid, "beta") != 0)
+ {
+ cout << "FAIL: rmattr beta" << endl;
+ }
+ if (os->rmattr (oid, "gamma") != 0)
+ {
+ cout << "FAIL: rmattr gamma" << endl;
+ }
+
+ coll_t cid = 0xCAFEBABE;
+ if (os->create_collection (cid) != 0)
+ {
+ cout << "FAIL: create_collection" << endl;
+ }
+ if (os->create_collection (cid + 10) != 0)
+ {
+ cout << "FAIL: create_collection" << endl;
+ }
+ if (os->create_collection (cid + 5) != 0)
+ {
+ cout << "FAIL: create_collection" << endl;
+ }
+ if (os->create_collection (42) != 0)
+ {
+ cout << "FAIL: create_collection" << endl;
+ }
+
+ if (os->collection_add (cid, oid) != 0)
+ {
+ cout << "FAIL: collection_add" << endl;
+ }
+
+ list<coll_t> ls;
+ if (os->list_collections (ls) < 0)
+ {
+ cout << "FAIL: list_collections" << endl;
+ }
+ cout << "collections: ";
+ for (list<coll_t>::iterator it = ls.begin(); it != ls.end(); it++)
+ {
+ cout << *it << ", ";
+ }
+ cout << endl;
+
+ if (os->destroy_collection (0xCAFEBABE + 10) != 0)
+ {
+ cout << "FAIL: destroy_collection" << endl;
+ }
+
+ if (os->destroy_collection (0xCAFEBADE + 10) == 0)
+ {
+ cout << "FAIL: destroy_collection" << endl;
+ }
+
+ object_t oid2 (12345, 12345);
+ for (int i = 0; i < 8; i++)
+ {
+ oid2.rev++;
+ if (os->collection_add (cid, oid2) != 0)
+ {
+ cout << "FAIL: collection_add" << endl;
+ }
+ }
+ for (int i = 0; i < 8; i++)
+ {
+ if (os->collection_remove (cid, oid2) != 0)
+ {
+ cout << "FAIL: collection_remove" << endl;
+ }
+ oid2.rev--;
+ }
+
+ if (os->collection_setattr (cid, "alpha", "value", 5) != 0)
+ cout << "FAIL: collection_setattr" << endl;
+ if (os->collection_setattr (cid, "beta", "value", 5) != 0)
+ cout << "FAIL: collection_setattr" << endl;
+ if (os->collection_setattr (cid, "gamma", "value", 5) != 0)
+ cout << "FAIL: collection_setattr" << endl;
+ if (os->collection_setattr (cid, "fred", "value", 5) != 0)
+ cout << "FAIL: collection_setattr" << endl;
+
+ memset (attrvalue, 0, sizeof (attrvalue));
+ if (os->collection_getattr (cid, "alpha", attrvalue, sizeof (attrvalue)) < 0)
+ cout << "FAIL: collection_getattr" << endl;
+ else if (strncmp (attrvalue, "value", 5) != 0)
+ cout << "FAIL: collection attribute value different" << endl;
+ memset (attrvalue, 0, sizeof (attrvalue));
+ if (os->collection_getattr (cid, "beta", attrvalue, sizeof (attrvalue)) < 0)
+ cout << "FAIL: collection_getattr" << endl;
+ else if (strncmp (attrvalue, "value", 5) != 0)
+ cout << "FAIL: collection attribute value different" << endl;
+ memset (attrvalue, 0, sizeof (attrvalue));
+ if (os->collection_getattr (cid, "gamma", attrvalue, sizeof (attrvalue)) < 0)
+ cout << "FAIL: collection_getattr" << endl;
+ else if (strncmp (attrvalue, "value", 5) != 0)
+ cout << "FAIL: collection attribute value different" << endl;
+ memset (attrvalue, 0, sizeof (attrvalue));
+ if (os->collection_getattr (cid, "fred", attrvalue, sizeof (attrvalue)) < 0)
+ cout << "FAIL: collection_getattr" << endl;
+ else if (strncmp (attrvalue, "value", 5) != 0)
+ cout << "FAIL: collection attribute value different" << endl;
+
+ if (os->collection_setattr (cid, "alpha", "eulavvalue", 10) != 0)
+ cout << "FAIL: collection setattr overwrite" << endl;
+ memset (attrvalue, 0, sizeof (attrvalue));
+ if (os->collection_getattr (cid, "alpha", attrvalue, sizeof (attrvalue)) < 0)
+ cout << "FAIL: collection_getattr" << endl;
+ else if (strncmp (attrvalue, "eulavvalue", 10) != 0)
+ cout << "FAIL: collection attribute value different" << endl;
+ memset (attrvalue, 0, sizeof (attrvalue));
+ if (os->collection_getattr (cid, "beta", attrvalue, sizeof (attrvalue)) < 0)
+ cout << "FAIL: collection_getattr" << endl;
+ else if (strncmp (attrvalue, "value", 5) != 0)
+ cout << "FAIL: collection attribute value different" << endl;
+ memset (attrvalue, 0, sizeof (attrvalue));
+ if (os->collection_getattr (cid, "gamma", attrvalue, sizeof (attrvalue)) < 0)
+ cout << "FAIL: collection_getattr" << endl;
+ else if (strncmp (attrvalue, "value", 5) != 0)
+ cout << "FAIL: collection attribute value different" << endl;
+ memset (attrvalue, 0, sizeof (attrvalue));
+ if (os->collection_getattr (cid, "fred", attrvalue, sizeof (attrvalue)) < 0)
+ cout << "FAIL: collection_getattr" << endl;
+ else if (strncmp (attrvalue, "value", 5) != 0)
+ cout << "FAIL: collection attribute value different" << endl;
+
+ if (os->collection_rmattr (cid, "alpha") != 0)
+ cout << "FAIL: collection_rmattr" << endl;
+ if (os->collection_rmattr (cid, "fred") != 0)
+ cout << "FAIL: collection_rmattr" << endl;
+ if (os->collection_rmattr (cid, "beta") != 0)
+ cout << "FAIL: collection_rmattr" << endl;
+ if (os->collection_rmattr (cid, "gamma") != 0)
+ cout << "FAIL: collection_rmattr" << endl;
+
+ if (os->collection_rmattr (cid, "alpha") == 0)
+ cout << "FAIL: collection_rmattr (nonexistent)" << endl;
+
+ // Truncate the object.
+ if (os->truncate (oid, 512, NULL) != 0)
+ {
+ cout << "FAIL: truncate" << endl;
+ }
+
+ // Expand the object.
+ if (os->truncate (oid, 1200, NULL) != 0)
+ {
+ cout << "FAIL: expand" << endl;
+ }
+
+ // Delete the object.
+ if (os->remove (oid) != 0)
+ {
+ cout << "FAIL: could not remove object" << endl;
+ }
+
+ // Shouldn't be there
+ if (os->exists (oid))
+ {
+ cout << "FAIL: should not be there" << endl;
+ }
+
+ os->sync();
+ exit (0);
+}
diff --git a/src/test/old/testtree.cc b/src/test/old/testtree.cc
new file mode 100644
index 00000000000..2c21bcbe52e
--- /dev/null
+++ b/src/test/old/testtree.cc
@@ -0,0 +1,46 @@
+
+
+#include "../crush/BinaryTree.h"
+using namespace crush;
+
+#include <iostream>
+#include <vector>
+using namespace std;
+
+int main()
+{
+ BinaryTree t;
+
+ vector<int> nodes;
+
+ for (int i=0; i<30; i++) {
+ cout << "adding " << i << endl;
+ int n = t.add_node(1);
+ nodes.push_back(n);
+ //cout << t << endl;
+ }
+ cout << t << endl;
+
+ for (int k=0; k<10000; k++) {
+ if (rand() % 2) {
+ cout << "adding" << endl;
+ nodes.push_back( t.add_node(1) );
+ } else {
+ if (!nodes.empty()) {
+ //for (int i=0; i<nodes.size(); i++) {
+ int p = rand() % nodes.size();
+ int n = nodes[p];
+ assert (t.exists(n));
+ cout << "removing " << n << endl;
+ t.remove_node(n);
+
+ for (int j=p; j<nodes.size(); j++)
+ nodes[j] = nodes[j+1];
+ nodes.pop_back();
+ }
+ }
+ cout << t << endl;
+ }
+
+
+}
diff --git a/src/test/old/testxattr.cc b/src/test/old/testxattr.cc
new file mode 100644
index 00000000000..65bb4b114e1
--- /dev/null
+++ b/src/test/old/testxattr.cc
@@ -0,0 +1,30 @@
+
+#include <iostream>
+using namespace std;
+
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/file.h>
+#include <iostream>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/xattr.h>
+
+int main(int argc, char**argv)
+{
+ int a = 1;
+ int b = 2;
+
+ mknod("test", 0600, 0);
+
+ cout << "setxattr " << setxattr("test", "asdf", &a, sizeof(a), 0) << endl;
+ cout << "errno " << errno << " " << strerror(errno) << endl;
+ cout << "getxattr " << getxattr("test", "asdf", &b, sizeof(b)) << endl;
+ cout << "errno " << errno << " " << strerror(errno) << endl;
+ cout << "a is " << a << " and b is " << b << endl;
+ return 0;
+}