LCOV - code coverage report
Current view: top level - src/ctlib/unittests - connect_fail.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 16 38 42.1 %
Date: 2024-03-23 09:12:27 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include <config.h>
       2             : 
       3             : #include <stdio.h>
       4             : #include <ctpublic.h>
       5             : #include "common.h"
       6             : 
       7             : int
       8           8 : main(int argc, char **argv)
       9             : {
      10             :         CS_CONTEXT *ctx;
      11             :         CS_CONNECTION *conn;
      12           8 :         int ret = 1;
      13             : 
      14           8 :         read_login_info();
      15             :         
      16           8 :         if (cs_ctx_alloc(CS_VERSION_100, &ctx) != CS_SUCCEED) {
      17           0 :                 fprintf(stderr, "Context Alloc failed!\n");
      18           0 :                 return ret;
      19             :         }
      20           8 :         if (ct_init(ctx, CS_VERSION_100) != CS_SUCCEED) {
      21           0 :                 fprintf(stderr, "Library Init failed!\n");
      22           0 :                 return ret;
      23             :         }
      24           8 :         if (ct_con_alloc(ctx, &conn) != CS_SUCCEED) {
      25           0 :                 fprintf(stderr, "Connect Alloc failed!\n");
      26           0 :                 return ret;
      27             :         }
      28           8 :         if (ct_con_props(conn, CS_SET, CS_USERNAME, (CS_VOID*) "sa", CS_NULLTERM, NULL) != CS_SUCCEED) {
      29           0 :                 fprintf(stderr, "ct_con_props() SET USERNAME failed!\n");
      30           0 :                 return ret;
      31             :         }
      32           8 :         if (ct_con_props(conn, CS_SET, CS_PASSWORD, (CS_VOID*) "invalid", CS_NULLTERM, NULL) != CS_SUCCEED) {
      33           0 :                 fprintf(stderr, "ct_con_props() SET PASSWORD failed!\n");
      34           0 :                 return ret;
      35             :         }
      36           8 :         if (ct_connect(conn, SERVER, CS_NULLTERM) != CS_FAIL) {
      37           0 :                 fprintf(stderr, "Connection succeeded??\n");
      38           0 :                 return ret;
      39             :         }
      40             : 
      41           8 :         if (ct_cancel(conn, NULL, CS_CANCEL_ALL) != CS_SUCCEED) {
      42           0 :                 fprintf(stderr, "ct_cancel() failed!\n");
      43           0 :                 return ret;
      44             :         }
      45           8 :         if (ct_close(conn, CS_UNUSED) != CS_SUCCEED) {
      46           0 :                 fprintf(stderr, "ct_close() failed!\n");
      47           0 :                 return ret;
      48             :         }
      49           8 :         if (ct_con_drop(conn) != CS_SUCCEED) {
      50           0 :                 fprintf(stderr, "ct_con_drop() failed!\n");
      51           0 :                 return ret;
      52             :         }
      53           8 :         if (ct_exit(ctx, CS_UNUSED) != CS_SUCCEED) {
      54           0 :                 fprintf(stderr, "ct_exit() failed!\n");
      55           0 :                 return ret;
      56             :         }
      57           8 :         if (cs_ctx_drop(ctx) != CS_SUCCEED) {
      58           0 :                 fprintf(stderr, "cs_ctx_drop() failed!\n");
      59           0 :                 return ret;
      60             :         }
      61             : 
      62           8 :         printf("Test succeeded\n");
      63           8 :         return 0;
      64             : }

Generated by: LCOV version 1.13