Line data Source code
1 : #include "common.h"
2 :
3 : /* Testing: Server messages limit */
4 10 : TEST_MAIN()
5 : {
6 : CS_CONTEXT *ctx;
7 : CS_CONNECTION *conn;
8 : CS_COMMAND *cmd;
9 10 : int verbose = 0;
10 : int i;
11 : CS_INT num_msgs, totMsgs;
12 : CS_SERVERMSG server_message;
13 :
14 : if (verbose) {
15 : printf("Trying login\n");
16 : }
17 10 : check_call(try_ctlogin, (&ctx, &conn, &cmd, verbose));
18 :
19 10 : check_call(ct_diag, (conn, CS_INIT, CS_UNUSED, CS_UNUSED, NULL));
20 :
21 10 : totMsgs = 4;
22 :
23 10 : check_call(ct_diag, (conn, CS_MSGLIMIT, CS_SERVERMSG_TYPE, CS_UNUSED, &totMsgs));
24 :
25 10 : printf("Maximum message limit is set to %d.\n", totMsgs);
26 :
27 10 : check_call(ct_diag, (conn, CS_STATUS, CS_SERVERMSG_TYPE, CS_UNUSED, &num_msgs));
28 :
29 10 : printf("Number of messages returned: %d\n", num_msgs);
30 :
31 10 : for (i = 0; i < num_msgs; i++) {
32 :
33 0 : check_call(ct_diag, (conn, CS_GET, CS_SERVERMSG_TYPE, i + 1, &server_message));
34 :
35 0 : servermsg_cb(ctx, conn, &server_message);
36 :
37 : }
38 :
39 10 : check_call(ct_diag, (conn, CS_CLEAR, CS_SERVERMSG_TYPE, CS_UNUSED, NULL));
40 :
41 10 : check_call(ct_diag, (conn, CS_STATUS, CS_SERVERMSG_TYPE, CS_UNUSED, &num_msgs));
42 10 : if (num_msgs != 0) {
43 0 : fprintf(stderr, "cs_diag(CS_CLEAR) failed there are still %d messages on queue\n", num_msgs);
44 0 : return 1;
45 : }
46 :
47 10 : check_call(try_ctlogout, (ctx, conn, cmd, verbose));
48 :
49 10 : return 0;
50 : }
|