summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2008-04-14 21:52:55 -0400
committerBrian Cully <github.20.shmit@spamgourmet.com>2008-04-14 21:52:55 -0400
commit6ba98a9f9f48e13738d9736cba9c45b5e94f42f2 (patch)
tree86d7c281bcdbf67eb53cee064aa905e740ec5ccf /tests
downloadnastd-6ba98a9f9f48e13738d9736cba9c45b5e94f42f2.tar.gz
nastd-6ba98a9f9f48e13738d9736cba9c45b5e94f42f2.zip
Initial import
Diffstat (limited to 'tests')
-rw-r--r--tests/.cvsignore14
-rw-r--r--tests/.pure0
-rw-r--r--tests/.svn/README.txt2
-rw-r--r--tests/.svn/empty-file0
-rw-r--r--tests/.svn/entries121
-rw-r--r--tests/.svn/format1
-rw-r--r--tests/.svn/prop-base/.cvsignore.svn-base1
-rw-r--r--tests/.svn/prop-base/.pure.svn-base1
-rw-r--r--tests/.svn/prop-base/Makefile.svn-base1
-rw-r--r--tests/.svn/prop-base/getass.c.svn-base1
-rw-r--r--tests/.svn/prop-base/getnast.c.svn-base1
-rw-r--r--tests/.svn/prop-base/killnast.c.svn-base1
-rw-r--r--tests/.svn/prop-base/mtstressass.c.svn-base1
-rw-r--r--tests/.svn/prop-base/mtstressnast.c.svn-base1
-rw-r--r--tests/.svn/prop-base/randnast.c.svn-base1
-rw-r--r--tests/.svn/prop-base/statnast.c.svn-base1
-rw-r--r--tests/.svn/prop-base/stressnast.c.svn-base1
-rw-r--r--tests/.svn/prop-base/updnast.c.svn-base1
-rw-r--r--tests/.svn/props/.cvsignore.svn-work1
-rw-r--r--tests/.svn/props/.pure.svn-work1
-rw-r--r--tests/.svn/props/Makefile.svn-work1
-rw-r--r--tests/.svn/props/getass.c.svn-work1
-rw-r--r--tests/.svn/props/getnast.c.svn-work1
-rw-r--r--tests/.svn/props/killnast.c.svn-work1
-rw-r--r--tests/.svn/props/mtstressass.c.svn-work1
-rw-r--r--tests/.svn/props/mtstressnast.c.svn-work1
-rw-r--r--tests/.svn/props/randnast.c.svn-work1
-rw-r--r--tests/.svn/props/statnast.c.svn-work1
-rw-r--r--tests/.svn/props/stressnast.c.svn-work1
-rw-r--r--tests/.svn/props/updnast.c.svn-work1
-rw-r--r--tests/.svn/text-base/.cvsignore.svn-base14
-rw-r--r--tests/.svn/text-base/.pure.svn-base0
-rw-r--r--tests/.svn/text-base/Makefile.svn-base46
-rw-r--r--tests/.svn/text-base/getass.c.svn-base59
-rw-r--r--tests/.svn/text-base/getnast.c.svn-base64
-rw-r--r--tests/.svn/text-base/killnast.c.svn-base39
-rw-r--r--tests/.svn/text-base/mtstressass.c.svn-base95
-rw-r--r--tests/.svn/text-base/mtstressnast.c.svn-base77
-rw-r--r--tests/.svn/text-base/randnast.c.svn-base69
-rw-r--r--tests/.svn/text-base/statnast.c.svn-base39
-rw-r--r--tests/.svn/text-base/stressnast.c.svn-base60
-rw-r--r--tests/.svn/text-base/updnast.c.svn-base80
-rw-r--r--tests/Makefile46
-rw-r--r--tests/getass.c59
-rw-r--r--tests/getnast.c64
-rw-r--r--tests/killnast.c39
-rw-r--r--tests/mtstressass.c95
-rw-r--r--tests/mtstressnast.c77
-rw-r--r--tests/randnast.c69
-rw-r--r--tests/statnast.c39
-rw-r--r--tests/stressnast.c60
-rw-r--r--tests/updnast.c80
52 files changed, 1432 insertions, 0 deletions
diff --git a/tests/.cvsignore b/tests/.cvsignore
new file mode 100644
index 0000000..0d898eb
--- /dev/null
+++ b/tests/.cvsignore
@@ -0,0 +1,14 @@
+getnast
+killnast
+randnast
+statnast
+stressnast
+mtstressnast
+updnast
+.pure
+*.o
+*.so
+*.a
+*.core
+*.gmon
+tags
diff --git a/tests/.pure b/tests/.pure
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/.pure
diff --git a/tests/.svn/README.txt b/tests/.svn/README.txt
new file mode 100644
index 0000000..271a8ce
--- /dev/null
+++ b/tests/.svn/README.txt
@@ -0,0 +1,2 @@
+This is a Subversion working copy administrative directory.
+Visit http://subversion.tigris.org/ for more information.
diff --git a/tests/.svn/empty-file b/tests/.svn/empty-file
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/.svn/empty-file
diff --git a/tests/.svn/entries b/tests/.svn/entries
new file mode 100644
index 0000000..01b7881
--- /dev/null
+++ b/tests/.svn/entries
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wc-entries
+ xmlns="svn:">
+<entry
+ committed-rev="1"
+ name=""
+ committed-date="2005-12-08T17:32:07.572093Z"
+ url="svn+ssh://coleridge/svn/nastd/trunk/tests"
+ last-author="bjc"
+ kind="dir"
+ uuid="2641c99b-6c07-0410-920d-927397d2d5d0"
+ revision="8"/>
+<entry
+ committed-rev="1"
+ name="updnast.c"
+ text-time="2005-12-24T00:00:46.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="ec289f72dcd13681439581954425d2d7"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:45.000000Z"/>
+<entry
+ committed-rev="1"
+ name="killnast.c"
+ text-time="2005-12-24T00:00:46.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="13334e900d0e0f5d00ecf81e44a822b8"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:45.000000Z"/>
+<entry
+ committed-rev="1"
+ name="statnast.c"
+ text-time="2005-12-24T00:00:46.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="13334e900d0e0f5d00ecf81e44a822b8"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:45.000000Z"/>
+<entry
+ committed-rev="1"
+ name="getnast.c"
+ text-time="2005-12-24T00:00:46.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="ae2b450a4fa8d55def3e7d3d07371a2d"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:45.000000Z"/>
+<entry
+ committed-rev="1"
+ name="getass.c"
+ text-time="2005-12-24T00:00:46.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="9f8a0bb66ec1fa1c1666da52970b7a9e"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:45.000000Z"/>
+<entry
+ committed-rev="1"
+ name=".pure"
+ text-time="2005-12-24T00:00:46.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="d41d8cd98f00b204e9800998ecf8427e"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:45.000000Z"/>
+<entry
+ committed-rev="1"
+ name="stressnast.c"
+ text-time="2005-12-24T00:00:47.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="643dd30bf90282dca1ed92de6907c514"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:45.000000Z"/>
+<entry
+ committed-rev="1"
+ name="mtstressnast.c"
+ text-time="2005-12-24T00:00:47.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="f71ab9f13fcc9bed6839e266a6e9244a"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:45.000000Z"/>
+<entry
+ committed-rev="1"
+ name="randnast.c"
+ text-time="2005-12-24T00:00:47.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="a33465d2e807e9d630a323e5bde5609a"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:45.000000Z"/>
+<entry
+ committed-rev="1"
+ name="mtstressass.c"
+ text-time="2005-12-24T00:00:47.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="771bd88ed8a02cdd13dbd88fdf522e81"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:46.000000Z"/>
+<entry
+ committed-rev="1"
+ name=".cvsignore"
+ text-time="2005-12-24T00:00:47.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="98e1fd021c8da0a3b45a423374a6c51c"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:46.000000Z"/>
+<entry
+ committed-rev="1"
+ name="Makefile"
+ text-time="2005-12-24T00:00:47.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="905fa6a41631a2e8c01087a110ec4518"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:46.000000Z"/>
+</wc-entries>
diff --git a/tests/.svn/format b/tests/.svn/format
new file mode 100644
index 0000000..b8626c4
--- /dev/null
+++ b/tests/.svn/format
@@ -0,0 +1 @@
+4
diff --git a/tests/.svn/prop-base/.cvsignore.svn-base b/tests/.svn/prop-base/.cvsignore.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/.cvsignore.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/.pure.svn-base b/tests/.svn/prop-base/.pure.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/.pure.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/Makefile.svn-base b/tests/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/getass.c.svn-base b/tests/.svn/prop-base/getass.c.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/getass.c.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/getnast.c.svn-base b/tests/.svn/prop-base/getnast.c.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/getnast.c.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/killnast.c.svn-base b/tests/.svn/prop-base/killnast.c.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/killnast.c.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/mtstressass.c.svn-base b/tests/.svn/prop-base/mtstressass.c.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/mtstressass.c.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/mtstressnast.c.svn-base b/tests/.svn/prop-base/mtstressnast.c.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/mtstressnast.c.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/randnast.c.svn-base b/tests/.svn/prop-base/randnast.c.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/randnast.c.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/statnast.c.svn-base b/tests/.svn/prop-base/statnast.c.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/statnast.c.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/stressnast.c.svn-base b/tests/.svn/prop-base/stressnast.c.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/stressnast.c.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/prop-base/updnast.c.svn-base b/tests/.svn/prop-base/updnast.c.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/prop-base/updnast.c.svn-base
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/.cvsignore.svn-work b/tests/.svn/props/.cvsignore.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/.cvsignore.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/.pure.svn-work b/tests/.svn/props/.pure.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/.pure.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/Makefile.svn-work b/tests/.svn/props/Makefile.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/Makefile.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/getass.c.svn-work b/tests/.svn/props/getass.c.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/getass.c.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/getnast.c.svn-work b/tests/.svn/props/getnast.c.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/getnast.c.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/killnast.c.svn-work b/tests/.svn/props/killnast.c.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/killnast.c.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/mtstressass.c.svn-work b/tests/.svn/props/mtstressass.c.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/mtstressass.c.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/mtstressnast.c.svn-work b/tests/.svn/props/mtstressnast.c.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/mtstressnast.c.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/randnast.c.svn-work b/tests/.svn/props/randnast.c.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/randnast.c.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/statnast.c.svn-work b/tests/.svn/props/statnast.c.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/statnast.c.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/stressnast.c.svn-work b/tests/.svn/props/stressnast.c.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/stressnast.c.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/props/updnast.c.svn-work b/tests/.svn/props/updnast.c.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/tests/.svn/props/updnast.c.svn-work
@@ -0,0 +1 @@
+END
diff --git a/tests/.svn/text-base/.cvsignore.svn-base b/tests/.svn/text-base/.cvsignore.svn-base
new file mode 100644
index 0000000..0d898eb
--- /dev/null
+++ b/tests/.svn/text-base/.cvsignore.svn-base
@@ -0,0 +1,14 @@
+getnast
+killnast
+randnast
+statnast
+stressnast
+mtstressnast
+updnast
+.pure
+*.o
+*.so
+*.a
+*.core
+*.gmon
+tags
diff --git a/tests/.svn/text-base/.pure.svn-base b/tests/.svn/text-base/.pure.svn-base
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/.svn/text-base/.pure.svn-base
diff --git a/tests/.svn/text-base/Makefile.svn-base b/tests/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..8c2cd69
--- /dev/null
+++ b/tests/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,46 @@
+# $Id: Makefile,v 1.15 2000/12/27 06:51:51 shmit Exp $
+
+LIBASS= ../client/libnast.a
+
+tclients: getnast statnast stressnast randnast mtstressnast updnast \
+ killnast
+
+GETOBJS= getnast.o
+getnast: ${GETOBJS}
+ ${PURIFY} ${CC} -o $@ ${GETOBJS} ${LIBASS} ${LIBS}
+
+STATOBJS= statnast.o
+statnast: ${STATOBJS}
+ ${PURIFY} ${CC} -o $@ ${STATOBJS} ${LIBASS} ${LIBS}
+
+STRESSOBJS= stressnast.o
+stressnast: ${STRESSOBJS}
+ ${PURIFY} ${CC} -o $@ ${STRESSOBJS} ${LIBASS} ${LIBS}
+
+RANDOBJS= randnast.o
+randnast: ${RANDOBJS}
+ ${PURIFY} ${CC} -o $@ ${RANDOBJS} ${LIBASS} ${LIBS}
+
+MTSTRESSOBJS= mtstressnast.o
+mtstressnast: ${MTSTRESSOBJS}
+ ${PURIFY} ${CC} -o $@ ${MTSTRESSOBJS} ${LIBASS} ${LIBS}
+
+UPDOBJS= updnast.o
+updnast: ${UPDOBJS}
+ ${PURIFY} ${CC} -o $@ ${UPDOBJS} ${LIBASS} ${LIBS}
+
+KILLOBJS= killnast.o
+killnast: ${KILLOBJS}
+ ${PURIFY} ${CC} -o $@ ${KILLOBJS} ${LIBASS} ${LIBS}
+
+#
+# Dependencies
+#
+getnast.o: ../include/nastd.h
+statnast.o: ../include/nastd.h
+stressnast.o: ../include/nastd.h
+randnast.o: ../include/nastd.h
+mtstressnast.o: ../include/nastd.h
+
+MKDIR= ../Makefiles
+include ${MKDIR}/build
diff --git a/tests/.svn/text-base/getass.c.svn-base b/tests/.svn/text-base/getass.c.svn-base
new file mode 100644
index 0000000..7f81bf8
--- /dev/null
+++ b/tests/.svn/text-base/getass.c.svn-base
@@ -0,0 +1,59 @@
+#include <assd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ assh *asshole;
+ ass_array *aa;
+ ass_options opts;
+ int i, rc;
+
+ if (argc != 2) {
+ printf("Usage: %s query\n", argv[0]);
+ return 1;
+ }
+
+ asshole = ass_sphincter_new();
+ if (asshole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to asshole.\n");
+ return 2;
+ }
+
+ /* Get the default options. */
+ rc = ass_options_get(asshole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get options: %s.\n",
+ ass_errmsg(asshole));
+ ass_sphincter_close(asshole);
+ return 2;
+ }
+
+ /* Add more fallthrough threads. */
+ opts.fallthrough_threads = 5;
+ rc = ass_options_set(asshole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't set options: %s.\n",
+ ass_errmsg(asshole));
+ ass_sphincter_close(asshole);
+ return 2;
+ }
+
+ rc = ass_get(asshole, argv[1]);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't perform query: %s.\n",
+ ass_errmsg(asshole));
+ ass_sphincter_close(asshole);
+ return 2;
+ }
+
+ aa = ass_get_result(asshole);
+ for (i = 0; i < aa->nitems; i++)
+ printf("Result[%d]: `%s'\n", i, aa->items[i]->strdata);
+ ass_free_result(aa);
+
+ ass_sphincter_close(asshole);
+ return 0;
+}
diff --git a/tests/.svn/text-base/getnast.c.svn-base b/tests/.svn/text-base/getnast.c.svn-base
new file mode 100644
index 0000000..904c01f
--- /dev/null
+++ b/tests/.svn/text-base/getnast.c.svn-base
@@ -0,0 +1,64 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+
+char *progname;
+
+void
+usage()
+{
+ fprintf(stderr, "Usage: %s [-s socket] query\n", progname);
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char *sock_n;
+ nasth *nasthole;
+ nast_array *aa;
+ char ch;
+ int i, rc;
+
+ progname = strrchr(argv[0], '/');
+ if (!progname)
+ progname = argv[0];
+ else
+ progname++;
+
+ sock_n = NULL;
+ while ((ch = getopt(argc, argv, "s:")) != -1) {
+ switch (ch) {
+ case 's':
+ sock_n = optarg;
+ break;
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ }
+
+ nasthole = nast_sphincter_new(sock_n);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ rc = nast_get(nasthole, argv[argc-1]);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't perform query: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ aa = nast_get_result(nasthole);
+ for (i = 0; i < aa->nitems; i++)
+ printf("Result[%d]: `%s'\n", i, aa->items[i]->strdata);
+ nast_free_result(aa);
+
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/.svn/text-base/killnast.c.svn-base b/tests/.svn/text-base/killnast.c.svn-base
new file mode 100644
index 0000000..7c06dee
--- /dev/null
+++ b/tests/.svn/text-base/killnast.c.svn-base
@@ -0,0 +1,39 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ nasth *nasthole;
+ nast_array *aa;
+ int i, rc;
+
+ if (argc != 1) {
+ printf("Usage: %s\n", argv[0]);
+ return 1;
+ }
+
+ nasthole = nast_sphincter_new(NULL);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ rc = nast_stats(nasthole);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get stats: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ aa = nast_get_result(nasthole);
+ for (i = 0; i < aa->nitems; i++)
+ printf("%s\n", aa->items[i]->strdata);
+ nast_free_result(aa);
+
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/.svn/text-base/mtstressass.c.svn-base b/tests/.svn/text-base/mtstressass.c.svn-base
new file mode 100644
index 0000000..1a4c2e1
--- /dev/null
+++ b/tests/.svn/text-base/mtstressass.c.svn-base
@@ -0,0 +1,95 @@
+#include <assd.h>
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define NTHREADS 10
+
+assh *asshole;
+char *username;
+
+void *
+io_looper(void *arg)
+{
+ struct timeval before, after;
+ ass_options opts;
+ int i, rc;
+
+ for (;;) {
+ /* Get the default options. */
+ rc = ass_options_get(asshole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get options: %s.\n",
+ ass_errmsg(asshole));
+ return NULL;
+ }
+
+ /* Add more fallthrough threads. */
+ opts.fallthrough_threads = 5;
+ rc = ass_options_set(asshole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't set options: %s.\n",
+ ass_errmsg(asshole));
+ return NULL;
+ }
+
+ for (i = 0; i < 10; i++) {
+ gettimeofday(&before, NULL);
+ rc = ass_get(asshole, username);
+ gettimeofday(&after, NULL);
+ if (rc == -1) {
+ if (ass_geterr(asshole) == ASS_TIMEDOUT) {
+ fprintf(stderr,
+ "ERROR: response timed out.\n");
+ continue;
+ }
+ fprintf(stderr,
+ "ERROR: Couldn't perform query: %s.\n",
+ ass_errmsg(asshole));
+ return NULL;
+ }
+
+ after.tv_sec -= before.tv_sec;
+ after.tv_usec -= before.tv_usec;
+ if (after.tv_usec < 0) {
+ after.tv_sec--;
+ after.tv_usec += 1000000;
+ }
+ fprintf(stderr, "Request time: %2ld.%06ld seconds.\n",
+ after.tv_sec, after.tv_usec);
+ }
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ pthread_t tids[NTHREADS];
+ int i;
+
+ if (argc != 2) {
+ printf("Usage: %s query\n", argv[0]);
+ return 1;
+ }
+ username = argv[1];
+
+ asshole = ass_sphincter_new();
+ if (asshole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to asshole.\n");
+ return 2;
+ }
+
+ for (i = 0; i < NTHREADS; i++)
+ pthread_create(&tids[i], NULL, io_looper, NULL);
+
+ for (i = 0; i < NTHREADS; i++)
+ pthread_join(tids[i], NULL);
+
+ ass_sphincter_close(asshole);
+ return 0;
+}
diff --git a/tests/.svn/text-base/mtstressnast.c.svn-base b/tests/.svn/text-base/mtstressnast.c.svn-base
new file mode 100644
index 0000000..913312e
--- /dev/null
+++ b/tests/.svn/text-base/mtstressnast.c.svn-base
@@ -0,0 +1,77 @@
+#include <nastd.h>
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define NTHREADS 10
+
+nasth *nasthole;
+char *username;
+
+void *
+io_looper(void *arg)
+{
+ struct timeval before, after;
+ int i, rc;
+
+ for (;;) {
+ for (i = 0; i < 10; i++) {
+ gettimeofday(&before, NULL);
+ rc = nast_get(nasthole, username);
+ gettimeofday(&after, NULL);
+ if (rc == -1) {
+ if (nast_geterr(nasthole) == NAST_TIMEDOUT) {
+ fprintf(stderr,
+ "ERROR: response timed out.\n");
+ continue;
+ }
+ fprintf(stderr,
+ "ERROR: Couldn't perform query: %s.\n",
+ nast_errmsg(nasthole));
+ return NULL;
+ }
+
+ after.tv_sec -= before.tv_sec;
+ after.tv_usec -= before.tv_usec;
+ if (after.tv_usec < 0) {
+ after.tv_sec--;
+ after.tv_usec += 1000000;
+ }
+ fprintf(stderr, "Request time: %2ld.%06ld seconds.\n",
+ after.tv_sec, after.tv_usec);
+ }
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ pthread_t tids[NTHREADS];
+ int i;
+
+ if (argc != 2) {
+ printf("Usage: %s query\n", argv[0]);
+ return 1;
+ }
+ username = argv[1];
+
+ nasthole = nast_sphincter_new(NULL);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ for (i = 0; i < NTHREADS; i++)
+ pthread_create(&tids[i], NULL, io_looper, NULL);
+
+ for (i = 0; i < NTHREADS; i++)
+ pthread_join(tids[i], NULL);
+
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/.svn/text-base/randnast.c.svn-base b/tests/.svn/text-base/randnast.c.svn-base
new file mode 100644
index 0000000..dd39fc6
--- /dev/null
+++ b/tests/.svn/text-base/randnast.c.svn-base
@@ -0,0 +1,69 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+
+char letters[] = "abcdefghijklmnopqrstuvwxyz0123456789-_.";
+
+int
+main(int argc, char *argv[])
+{
+ nasth *nasthole;
+ struct timeval before, after;
+ nast_options opts;
+ int i, rc;
+
+ nasthole = nast_sphincter_new(NULL);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ srand(time(NULL));
+
+ for (;;) {
+ /* Get the default options. */
+ rc = nast_options_get(nasthole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get options: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ for (i = 0; i < 10; i++) {
+ char uname[32];
+ int i, maxlen;
+
+ maxlen = rand() % sizeof(uname);
+ for (i = 0; i < maxlen-1; i++)
+ uname[i] = letters[rand() % sizeof(letters)];
+ uname[maxlen] = '\0';
+
+ gettimeofday(&before, NULL);
+ rc = nast_get(nasthole, uname);
+ gettimeofday(&after, NULL);
+ if (rc == -1) {
+ fprintf(stderr,
+ "ERROR: Couldn't perform query: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ after.tv_sec -= before.tv_sec;
+ after.tv_usec -= before.tv_usec;
+ if (after.tv_usec < 0) {
+ after.tv_sec--;
+ after.tv_usec += 1000000;
+ }
+ fprintf(stderr, "Request time: %2ld.%06ld seconds.\n",
+ after.tv_sec, after.tv_usec);
+ }
+ }
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/.svn/text-base/statnast.c.svn-base b/tests/.svn/text-base/statnast.c.svn-base
new file mode 100644
index 0000000..7c06dee
--- /dev/null
+++ b/tests/.svn/text-base/statnast.c.svn-base
@@ -0,0 +1,39 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ nasth *nasthole;
+ nast_array *aa;
+ int i, rc;
+
+ if (argc != 1) {
+ printf("Usage: %s\n", argv[0]);
+ return 1;
+ }
+
+ nasthole = nast_sphincter_new(NULL);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ rc = nast_stats(nasthole);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get stats: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ aa = nast_get_result(nasthole);
+ for (i = 0; i < aa->nitems; i++)
+ printf("%s\n", aa->items[i]->strdata);
+ nast_free_result(aa);
+
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/.svn/text-base/stressnast.c.svn-base b/tests/.svn/text-base/stressnast.c.svn-base
new file mode 100644
index 0000000..ad17a51
--- /dev/null
+++ b/tests/.svn/text-base/stressnast.c.svn-base
@@ -0,0 +1,60 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+int
+main(int argc, char *argv[])
+{
+ nasth *nasthole;
+ struct timeval before, after;
+ nast_options opts;
+ int i, rc;
+
+ if (argc != 2) {
+ printf("Usage: %s query\n", argv[0]);
+ return 1;
+ }
+
+ nasthole = nast_sphincter_new(NULL);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ for (;;) {
+ /* Get the default options. */
+ rc = nast_options_get(nasthole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get options: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ for (i = 0; i < 10; i++) {
+ gettimeofday(&before, NULL);
+ rc = nast_get(nasthole, argv[1]);
+ gettimeofday(&after, NULL);
+ if (rc == -1) {
+ fprintf(stderr,
+ "ERROR: Couldn't perform query: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ after.tv_sec -= before.tv_sec;
+ after.tv_usec -= before.tv_usec;
+ if (after.tv_usec < 0) {
+ after.tv_sec--;
+ after.tv_usec += 1000000;
+ }
+ fprintf(stderr, "Request time: %2ld.%06ld seconds.\n",
+ after.tv_sec, after.tv_usec);
+ }
+ }
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/.svn/text-base/updnast.c.svn-base b/tests/.svn/text-base/updnast.c.svn-base
new file mode 100644
index 0000000..9acef66
--- /dev/null
+++ b/tests/.svn/text-base/updnast.c.svn-base
@@ -0,0 +1,80 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+
+char *progname;
+
+void
+usage()
+{
+ fprintf(stderr, "Usage: %s [-s socket] query\n", progname);
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char *sock_n;
+ nasth *nasthole;
+ nast_array *aa;
+ char ch;
+ int i, rc;
+
+ progname = strrchr(argv[0], '/');
+ if (!progname)
+ progname = argv[0];
+ else
+ progname++;
+
+ sock_n = NULL;
+ while ((ch = getopt(argc, argv, "s:")) != -1) {
+ switch (ch) {
+ case 's':
+ sock_n = optarg;
+ break;
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ }
+
+ nasthole = nast_sphincter_new(sock_n);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ aa = nast_array_new();
+ if (aa == NULL) {
+ fprintf(stderr, "ERROR: Couldn't create array.\n");
+ return 3;
+ }
+
+ for (i = optind+1; i < argc; i++)
+ nast_array_add(aa, strlen(argv[i]), argv[i]);
+
+ rc = nast_upd(nasthole, argv[optind], aa);
+ nast_array_delete(aa);
+
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't perform update: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ aa = nast_get_result(nasthole);
+ if (aa->nitems == 0 || (aa->nitems == 1 &&
+ aa->items[0]->strlen == 0))
+ printf("Update for %s succeeded.\n", argv[optind]);
+ else {
+ for (i = 0; i < aa->nitems; i++)
+ printf("Result[%d]: `%s'\n", i, aa->items[i]->strdata);
+ }
+ nast_free_result(aa);
+
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..8c2cd69
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,46 @@
+# $Id: Makefile,v 1.15 2000/12/27 06:51:51 shmit Exp $
+
+LIBASS= ../client/libnast.a
+
+tclients: getnast statnast stressnast randnast mtstressnast updnast \
+ killnast
+
+GETOBJS= getnast.o
+getnast: ${GETOBJS}
+ ${PURIFY} ${CC} -o $@ ${GETOBJS} ${LIBASS} ${LIBS}
+
+STATOBJS= statnast.o
+statnast: ${STATOBJS}
+ ${PURIFY} ${CC} -o $@ ${STATOBJS} ${LIBASS} ${LIBS}
+
+STRESSOBJS= stressnast.o
+stressnast: ${STRESSOBJS}
+ ${PURIFY} ${CC} -o $@ ${STRESSOBJS} ${LIBASS} ${LIBS}
+
+RANDOBJS= randnast.o
+randnast: ${RANDOBJS}
+ ${PURIFY} ${CC} -o $@ ${RANDOBJS} ${LIBASS} ${LIBS}
+
+MTSTRESSOBJS= mtstressnast.o
+mtstressnast: ${MTSTRESSOBJS}
+ ${PURIFY} ${CC} -o $@ ${MTSTRESSOBJS} ${LIBASS} ${LIBS}
+
+UPDOBJS= updnast.o
+updnast: ${UPDOBJS}
+ ${PURIFY} ${CC} -o $@ ${UPDOBJS} ${LIBASS} ${LIBS}
+
+KILLOBJS= killnast.o
+killnast: ${KILLOBJS}
+ ${PURIFY} ${CC} -o $@ ${KILLOBJS} ${LIBASS} ${LIBS}
+
+#
+# Dependencies
+#
+getnast.o: ../include/nastd.h
+statnast.o: ../include/nastd.h
+stressnast.o: ../include/nastd.h
+randnast.o: ../include/nastd.h
+mtstressnast.o: ../include/nastd.h
+
+MKDIR= ../Makefiles
+include ${MKDIR}/build
diff --git a/tests/getass.c b/tests/getass.c
new file mode 100644
index 0000000..7f81bf8
--- /dev/null
+++ b/tests/getass.c
@@ -0,0 +1,59 @@
+#include <assd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ assh *asshole;
+ ass_array *aa;
+ ass_options opts;
+ int i, rc;
+
+ if (argc != 2) {
+ printf("Usage: %s query\n", argv[0]);
+ return 1;
+ }
+
+ asshole = ass_sphincter_new();
+ if (asshole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to asshole.\n");
+ return 2;
+ }
+
+ /* Get the default options. */
+ rc = ass_options_get(asshole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get options: %s.\n",
+ ass_errmsg(asshole));
+ ass_sphincter_close(asshole);
+ return 2;
+ }
+
+ /* Add more fallthrough threads. */
+ opts.fallthrough_threads = 5;
+ rc = ass_options_set(asshole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't set options: %s.\n",
+ ass_errmsg(asshole));
+ ass_sphincter_close(asshole);
+ return 2;
+ }
+
+ rc = ass_get(asshole, argv[1]);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't perform query: %s.\n",
+ ass_errmsg(asshole));
+ ass_sphincter_close(asshole);
+ return 2;
+ }
+
+ aa = ass_get_result(asshole);
+ for (i = 0; i < aa->nitems; i++)
+ printf("Result[%d]: `%s'\n", i, aa->items[i]->strdata);
+ ass_free_result(aa);
+
+ ass_sphincter_close(asshole);
+ return 0;
+}
diff --git a/tests/getnast.c b/tests/getnast.c
new file mode 100644
index 0000000..904c01f
--- /dev/null
+++ b/tests/getnast.c
@@ -0,0 +1,64 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+
+char *progname;
+
+void
+usage()
+{
+ fprintf(stderr, "Usage: %s [-s socket] query\n", progname);
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char *sock_n;
+ nasth *nasthole;
+ nast_array *aa;
+ char ch;
+ int i, rc;
+
+ progname = strrchr(argv[0], '/');
+ if (!progname)
+ progname = argv[0];
+ else
+ progname++;
+
+ sock_n = NULL;
+ while ((ch = getopt(argc, argv, "s:")) != -1) {
+ switch (ch) {
+ case 's':
+ sock_n = optarg;
+ break;
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ }
+
+ nasthole = nast_sphincter_new(sock_n);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ rc = nast_get(nasthole, argv[argc-1]);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't perform query: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ aa = nast_get_result(nasthole);
+ for (i = 0; i < aa->nitems; i++)
+ printf("Result[%d]: `%s'\n", i, aa->items[i]->strdata);
+ nast_free_result(aa);
+
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/killnast.c b/tests/killnast.c
new file mode 100644
index 0000000..7c06dee
--- /dev/null
+++ b/tests/killnast.c
@@ -0,0 +1,39 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ nasth *nasthole;
+ nast_array *aa;
+ int i, rc;
+
+ if (argc != 1) {
+ printf("Usage: %s\n", argv[0]);
+ return 1;
+ }
+
+ nasthole = nast_sphincter_new(NULL);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ rc = nast_stats(nasthole);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get stats: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ aa = nast_get_result(nasthole);
+ for (i = 0; i < aa->nitems; i++)
+ printf("%s\n", aa->items[i]->strdata);
+ nast_free_result(aa);
+
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/mtstressass.c b/tests/mtstressass.c
new file mode 100644
index 0000000..1a4c2e1
--- /dev/null
+++ b/tests/mtstressass.c
@@ -0,0 +1,95 @@
+#include <assd.h>
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define NTHREADS 10
+
+assh *asshole;
+char *username;
+
+void *
+io_looper(void *arg)
+{
+ struct timeval before, after;
+ ass_options opts;
+ int i, rc;
+
+ for (;;) {
+ /* Get the default options. */
+ rc = ass_options_get(asshole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get options: %s.\n",
+ ass_errmsg(asshole));
+ return NULL;
+ }
+
+ /* Add more fallthrough threads. */
+ opts.fallthrough_threads = 5;
+ rc = ass_options_set(asshole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't set options: %s.\n",
+ ass_errmsg(asshole));
+ return NULL;
+ }
+
+ for (i = 0; i < 10; i++) {
+ gettimeofday(&before, NULL);
+ rc = ass_get(asshole, username);
+ gettimeofday(&after, NULL);
+ if (rc == -1) {
+ if (ass_geterr(asshole) == ASS_TIMEDOUT) {
+ fprintf(stderr,
+ "ERROR: response timed out.\n");
+ continue;
+ }
+ fprintf(stderr,
+ "ERROR: Couldn't perform query: %s.\n",
+ ass_errmsg(asshole));
+ return NULL;
+ }
+
+ after.tv_sec -= before.tv_sec;
+ after.tv_usec -= before.tv_usec;
+ if (after.tv_usec < 0) {
+ after.tv_sec--;
+ after.tv_usec += 1000000;
+ }
+ fprintf(stderr, "Request time: %2ld.%06ld seconds.\n",
+ after.tv_sec, after.tv_usec);
+ }
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ pthread_t tids[NTHREADS];
+ int i;
+
+ if (argc != 2) {
+ printf("Usage: %s query\n", argv[0]);
+ return 1;
+ }
+ username = argv[1];
+
+ asshole = ass_sphincter_new();
+ if (asshole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to asshole.\n");
+ return 2;
+ }
+
+ for (i = 0; i < NTHREADS; i++)
+ pthread_create(&tids[i], NULL, io_looper, NULL);
+
+ for (i = 0; i < NTHREADS; i++)
+ pthread_join(tids[i], NULL);
+
+ ass_sphincter_close(asshole);
+ return 0;
+}
diff --git a/tests/mtstressnast.c b/tests/mtstressnast.c
new file mode 100644
index 0000000..913312e
--- /dev/null
+++ b/tests/mtstressnast.c
@@ -0,0 +1,77 @@
+#include <nastd.h>
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define NTHREADS 10
+
+nasth *nasthole;
+char *username;
+
+void *
+io_looper(void *arg)
+{
+ struct timeval before, after;
+ int i, rc;
+
+ for (;;) {
+ for (i = 0; i < 10; i++) {
+ gettimeofday(&before, NULL);
+ rc = nast_get(nasthole, username);
+ gettimeofday(&after, NULL);
+ if (rc == -1) {
+ if (nast_geterr(nasthole) == NAST_TIMEDOUT) {
+ fprintf(stderr,
+ "ERROR: response timed out.\n");
+ continue;
+ }
+ fprintf(stderr,
+ "ERROR: Couldn't perform query: %s.\n",
+ nast_errmsg(nasthole));
+ return NULL;
+ }
+
+ after.tv_sec -= before.tv_sec;
+ after.tv_usec -= before.tv_usec;
+ if (after.tv_usec < 0) {
+ after.tv_sec--;
+ after.tv_usec += 1000000;
+ }
+ fprintf(stderr, "Request time: %2ld.%06ld seconds.\n",
+ after.tv_sec, after.tv_usec);
+ }
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ pthread_t tids[NTHREADS];
+ int i;
+
+ if (argc != 2) {
+ printf("Usage: %s query\n", argv[0]);
+ return 1;
+ }
+ username = argv[1];
+
+ nasthole = nast_sphincter_new(NULL);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ for (i = 0; i < NTHREADS; i++)
+ pthread_create(&tids[i], NULL, io_looper, NULL);
+
+ for (i = 0; i < NTHREADS; i++)
+ pthread_join(tids[i], NULL);
+
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/randnast.c b/tests/randnast.c
new file mode 100644
index 0000000..dd39fc6
--- /dev/null
+++ b/tests/randnast.c
@@ -0,0 +1,69 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+
+char letters[] = "abcdefghijklmnopqrstuvwxyz0123456789-_.";
+
+int
+main(int argc, char *argv[])
+{
+ nasth *nasthole;
+ struct timeval before, after;
+ nast_options opts;
+ int i, rc;
+
+ nasthole = nast_sphincter_new(NULL);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ srand(time(NULL));
+
+ for (;;) {
+ /* Get the default options. */
+ rc = nast_options_get(nasthole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get options: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ for (i = 0; i < 10; i++) {
+ char uname[32];
+ int i, maxlen;
+
+ maxlen = rand() % sizeof(uname);
+ for (i = 0; i < maxlen-1; i++)
+ uname[i] = letters[rand() % sizeof(letters)];
+ uname[maxlen] = '\0';
+
+ gettimeofday(&before, NULL);
+ rc = nast_get(nasthole, uname);
+ gettimeofday(&after, NULL);
+ if (rc == -1) {
+ fprintf(stderr,
+ "ERROR: Couldn't perform query: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ after.tv_sec -= before.tv_sec;
+ after.tv_usec -= before.tv_usec;
+ if (after.tv_usec < 0) {
+ after.tv_sec--;
+ after.tv_usec += 1000000;
+ }
+ fprintf(stderr, "Request time: %2ld.%06ld seconds.\n",
+ after.tv_sec, after.tv_usec);
+ }
+ }
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/statnast.c b/tests/statnast.c
new file mode 100644
index 0000000..7c06dee
--- /dev/null
+++ b/tests/statnast.c
@@ -0,0 +1,39 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ nasth *nasthole;
+ nast_array *aa;
+ int i, rc;
+
+ if (argc != 1) {
+ printf("Usage: %s\n", argv[0]);
+ return 1;
+ }
+
+ nasthole = nast_sphincter_new(NULL);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ rc = nast_stats(nasthole);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get stats: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ aa = nast_get_result(nasthole);
+ for (i = 0; i < aa->nitems; i++)
+ printf("%s\n", aa->items[i]->strdata);
+ nast_free_result(aa);
+
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/stressnast.c b/tests/stressnast.c
new file mode 100644
index 0000000..ad17a51
--- /dev/null
+++ b/tests/stressnast.c
@@ -0,0 +1,60 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+int
+main(int argc, char *argv[])
+{
+ nasth *nasthole;
+ struct timeval before, after;
+ nast_options opts;
+ int i, rc;
+
+ if (argc != 2) {
+ printf("Usage: %s query\n", argv[0]);
+ return 1;
+ }
+
+ nasthole = nast_sphincter_new(NULL);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ for (;;) {
+ /* Get the default options. */
+ rc = nast_options_get(nasthole, &opts);
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't get options: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ for (i = 0; i < 10; i++) {
+ gettimeofday(&before, NULL);
+ rc = nast_get(nasthole, argv[1]);
+ gettimeofday(&after, NULL);
+ if (rc == -1) {
+ fprintf(stderr,
+ "ERROR: Couldn't perform query: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ after.tv_sec -= before.tv_sec;
+ after.tv_usec -= before.tv_usec;
+ if (after.tv_usec < 0) {
+ after.tv_sec--;
+ after.tv_usec += 1000000;
+ }
+ fprintf(stderr, "Request time: %2ld.%06ld seconds.\n",
+ after.tv_sec, after.tv_usec);
+ }
+ }
+ nast_sphincter_close(nasthole);
+ return 0;
+}
diff --git a/tests/updnast.c b/tests/updnast.c
new file mode 100644
index 0000000..9acef66
--- /dev/null
+++ b/tests/updnast.c
@@ -0,0 +1,80 @@
+#include <nastd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+
+char *progname;
+
+void
+usage()
+{
+ fprintf(stderr, "Usage: %s [-s socket] query\n", progname);
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char *sock_n;
+ nasth *nasthole;
+ nast_array *aa;
+ char ch;
+ int i, rc;
+
+ progname = strrchr(argv[0], '/');
+ if (!progname)
+ progname = argv[0];
+ else
+ progname++;
+
+ sock_n = NULL;
+ while ((ch = getopt(argc, argv, "s:")) != -1) {
+ switch (ch) {
+ case 's':
+ sock_n = optarg;
+ break;
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ }
+
+ nasthole = nast_sphincter_new(sock_n);
+ if (nasthole == NULL) {
+ fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n");
+ return 2;
+ }
+
+ aa = nast_array_new();
+ if (aa == NULL) {
+ fprintf(stderr, "ERROR: Couldn't create array.\n");
+ return 3;
+ }
+
+ for (i = optind+1; i < argc; i++)
+ nast_array_add(aa, strlen(argv[i]), argv[i]);
+
+ rc = nast_upd(nasthole, argv[optind], aa);
+ nast_array_delete(aa);
+
+ if (rc == -1) {
+ fprintf(stderr, "ERROR: Couldn't perform update: %s.\n",
+ nast_errmsg(nasthole));
+ nast_sphincter_close(nasthole);
+ return 2;
+ }
+
+ aa = nast_get_result(nasthole);
+ if (aa->nitems == 0 || (aa->nitems == 1 &&
+ aa->items[0]->strlen == 0))
+ printf("Update for %s succeeded.\n", argv[optind]);
+ else {
+ for (i = 0; i < aa->nitems; i++)
+ printf("Result[%d]: `%s'\n", i, aa->items[i]->strdata);
+ }
+ nast_free_result(aa);
+
+ nast_sphincter_close(nasthole);
+ return 0;
+}