summaryrefslogtreecommitdiffstats
path: root/src/test/old
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/old')
-rw-r--r--src/test/old/test_disk_bw.cc62
-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.cc73
-rw-r--r--src/test/old/testcrush.cc219
-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/testtree.cc46
-rw-r--r--src/test/old/testxattr.cc29
13 files changed, 859 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 00000000..d509a510
--- /dev/null
+++ b/src/test/old/test_disk_bw.cc
@@ -0,0 +1,62 @@
+
+#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 "common/safe_io.h"
+
+#include <iostream>
+using namespace std;
+
+int main(int argc, char **argv)
+{
+ void *buf;
+ int fd, count, loop = 0;
+
+ 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 = ceph_clock_now();
+ while (loop++ < count) {
+ int ret = safe_write(fd, buf, bsize);
+ if (ret)
+ ceph_abort();
+ //if ((loop % 100) == 0)
+ //fprintf(stderr, ".");
+ }
+ ::fsync(fd);
+ ::close(fd);
+ utime_t end = ceph_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 00000000..c63ed34d
--- /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 = ceph_clock_now();
+ for (int i=0; i<count; i++) {
+ off64_t 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 = ceph_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 00000000..d0ad8954
--- /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 00000000..9737025a
--- /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 = ceph_clock_now();
+ lseek64(fd, so, SEEK_SET);
+ r = ::read(fd, buf, blocks*4096);
+ utime_t end = ceph_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 00000000..cf1b095b
--- /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, const 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 00000000..be2298ff
--- /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 00000000..4e40914f
--- /dev/null
+++ b/src/test/old/testcounter.cc
@@ -0,0 +1,73 @@
+
+#include "common/DecayCounter.h"
+
+#include <list>
+
+#include <unistd.h>
+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;
+
+ DecayCounter::time now = DecayCounter::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;
+ }
+
+ usleep(1);
+ now = DecayCounter::clock::now();
+ }
+
+}
diff --git a/src/test/old/testcrush.cc b/src/test/old/testcrush.cc
new file mode 100644
index 00000000..56bb7240
--- /dev/null
+++ b/src/test/old/testcrush.cc
@@ -0,0 +1,219 @@
+#include "../crush/crush.h"
+using namespace crush;
+
+#include <math.h>
+
+#include <iostream>
+#include <vector>
+using namespace std;
+
+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);
+ 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);
+ 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(-4, umb1.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);
+
+ 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, root));
+ rule.steps.push_back(RuleStep(CRUSH_RULE_CHOOSE, 1, 0));
+ rule.steps.push_back(RuleStep(CRUSH_RULE_EMIT));
+ }
+
+ 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++;
+
+ c.do_rule(rule, x, v);
+
+ bool bad = false;
+ for (int i=0; i<numrep; i++) {
+ 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 << "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 00000000..78ecc197
--- /dev/null
+++ b/src/test/old/testfilepath.cc
@@ -0,0 +1,22 @@
+
+#include "include/filepath.h"
+#include <iostream>
+using namespace std;
+
+int print(const 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 00000000..68969b5b
--- /dev/null
+++ b/src/test/old/testmpi.cc
@@ -0,0 +1,53 @@
+#include <sys/stat.h>
+#include <iostream>
+#include <string>
+using namespace std;
+
+#include "common/config.h"
+#include "messages/MPing.h"
+#include "common/Mutex.h"
+
+#include "msg/MPIMessenger.h"
+
+class Pinger : public Dispatcher {
+public:
+ Messenger *messenger;
+ explicit 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 00000000..69e037c7
--- /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;
+ explicit 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/testtree.cc b/src/test/old/testtree.cc
new file mode 100644
index 00000000..2c21bcbe
--- /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 00000000..b1ef126d
--- /dev/null
+++ b/src/test/old/testxattr.cc
@@ -0,0 +1,29 @@
+
+#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 <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;
+}