ctdb-tests: Add reqid wrapping test
authorAmitay Isaacs <amitay@gmail.com>
Tue, 7 May 2019 06:29:54 +0000 (16:29 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 13 May 2019 07:27:24 +0000 (07:27 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13930

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tests/src/reqid_test.c

index ec0c4a5..39f1fbd 100644 (file)
@@ -66,6 +66,22 @@ int main(void)
        talloc_free(reqid_ctx);
        assert(talloc_get_size(mem_ctx) == 0);
 
+       ret = reqid_init(mem_ctx, INT_MAX-1, &reqid_ctx);
+       assert(ret == 0);
+
+       reqid = reqid_new(reqid_ctx, data);
+       assert(reqid == INT_MAX);
+
+       reqid = reqid_new(reqid_ctx, data);
+       assert(reqid == 0);
+
+       reqid_remove(reqid_ctx, 0);
+
+       reqid = reqid_new(reqid_ctx, data);
+       assert(reqid == 1);
+
+       talloc_free(reqid_ctx);
+
        talloc_free(mem_ctx);
 
        return 0;