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: 2024-04-20 12:53:58 Functions: 1 1 100.0 %

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

Generated by: LCOV version 1.13