LCOV - code coverage report
Current view: top level - src/ctlib/unittests - ct_diagserver.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 15 19 78.9 %
Date: 2025-01-18 11:50:39 Functions: 1 1 100.0 %

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

Generated by: LCOV version 1.13