aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-02-03 23:24:24 -0500
committerrsiddharth <s@ricketyspace.net>2020-04-17 20:56:36 -0400
commit688f7c449ce1b9dbb49580100817108c49434775 (patch)
tree119dd1529dc62b069d0803fecbdae5a95fcee71e
parentaacbbb88ab9adade60b3b2c18be191add9a1c065 (diff)
downloadnserver-688f7c449ce1b9dbb49580100817108c49434775.tar.gz
nserver-688f7c449ce1b9dbb49580100817108c49434775.tar.bz2
nserver-688f7c449ce1b9dbb49580100817108c49434775.tar.xz
nserver-688f7c449ce1b9dbb49580100817108c49434775.zip
nserver/src/protocol.c: Update sssample.
* nserver/src/protocol.c (sssample): Call ssample_parent on key. * nserver/tests/protocol_tests.c (test_sscreate, test_sssample): Update tests to test ssample_parent.
-rw-r--r--nserver/src/protocol.c6
-rw-r--r--nserver/tests/protocol_tests.c9
2 files changed, 14 insertions, 1 deletions
diff --git a/nserver/src/protocol.c b/nserver/src/protocol.c
index 213179a..733611b 100644
--- a/nserver/src/protocol.c
+++ b/nserver/src/protocol.c
@@ -110,7 +110,11 @@ double sssample(char *key, double s)
// 2. Sample!
Stats_sample(rec->st, s);
- // 3. Get mean.
+ // 3. Sample parent!
+ int rc = ssample_parent(key, s);
+ check(rc >= 0, "sampling parent failed");
+
+ // 4. Get mean.
double m = Stats_mean(rec->st);
return m;
diff --git a/nserver/tests/protocol_tests.c b/nserver/tests/protocol_tests.c
index afb3906..6e03816 100644
--- a/nserver/tests/protocol_tests.c
+++ b/nserver/tests/protocol_tests.c
@@ -14,6 +14,9 @@ char *test_sscreate()
rc = sscreate("/crimson");
mu_assert(rc == 1, "sscreate failed 2");
+ rc = sscreate("/crimson/sky");
+ mu_assert(rc == 0, "sscreate failed 3");
+
return NULL;
}
@@ -42,6 +45,12 @@ char *test_sssample()
mean = sssample("/ruby", 48);
mu_assert(mean == -1, "sssample failed 6");
+ mean = sssample("/crimson/sky", 42);
+ mu_assert(mean == 42.0, "sssample failed 7");
+
+ mean = sssample("/crimson", 10);
+ mu_assert(mean == 15.20, "sssample failed 8");
+
return NULL;
}