LCOV - code coverage report
Current view: top level - lib/cmdline - cmdline_socket.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 13 13 100.0 %
Date: 2025-05-01 17:49:45 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 8 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2010-2014 Intel Corporation.
       3                 :            :  * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
       4                 :            :  * All rights reserved.
       5                 :            :  */
       6                 :            : 
       7                 :            : #include <stdio.h>
       8                 :            : #include <unistd.h>
       9                 :            : #include <fcntl.h>
      10                 :            : 
      11                 :            : #include "cmdline.h"
      12                 :            : #include "cmdline_private.h"
      13                 :            : #include "cmdline_socket.h"
      14                 :            : 
      15                 :            : #include <eal_export.h>
      16                 :            : 
      17                 :            : RTE_EXPORT_SYMBOL(cmdline_file_new)
      18                 :            : struct cmdline *
      19                 :          5 : cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path)
      20                 :            : {
      21                 :            :         int fd;
      22                 :            : 
      23                 :            :         /* everything else is checked in cmdline_new() */
      24         [ +  + ]:          5 :         if (!path)
      25                 :            :                 return NULL;
      26                 :            : 
      27                 :            :         fd = open(path, O_RDONLY, 0);
      28         [ +  + ]:          4 :         if (fd < 0) {
      29                 :            :                 dprintf("open() failed\n");
      30                 :            :                 return NULL;
      31                 :            :         }
      32                 :          3 :         return cmdline_new(ctx, prompt, fd, -1);
      33                 :            : }
      34                 :            : 
      35                 :            : RTE_EXPORT_SYMBOL(cmdline_stdin_new)
      36                 :            : struct cmdline *
      37                 :          3 : cmdline_stdin_new(cmdline_parse_ctx_t *ctx, const char *prompt)
      38                 :            : {
      39                 :            :         struct cmdline *cl;
      40                 :            : 
      41                 :          3 :         cl = cmdline_new(ctx, prompt, 0, 1);
      42                 :            : 
      43         [ +  + ]:          3 :         if (cl != NULL)
      44                 :          1 :                 terminal_adjust(cl);
      45                 :            : 
      46                 :          3 :         return cl;
      47                 :            : }
      48                 :            : 
      49                 :            : RTE_EXPORT_SYMBOL(cmdline_stdin_exit)
      50                 :            : void
      51                 :          2 : cmdline_stdin_exit(struct cmdline *cl)
      52                 :            : {
      53         [ +  + ]:          2 :         if (cl == NULL)
      54                 :            :                 return;
      55                 :            : 
      56                 :          1 :         terminal_restore(cl);
      57                 :          1 :         cmdline_free(cl);
      58                 :            : }

Generated by: LCOV version 1.14