diff options
-rw-r--r-- | nserver/src/protocol.c | 6 | ||||
-rw-r--r-- | nserver/tests/protocol_tests.c | 9 |
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; } |