LCOV - code coverage report
Current view: top level - test - test-dissect-image.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 0 24 0.0 %
Date: 2019-08-23 13:36:53 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 18 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include <fcntl.h>
       4                 :            : #include <stdio.h>
       5                 :            : 
       6                 :            : #include "dissect-image.h"
       7                 :            : #include "log.h"
       8                 :            : #include "loop-util.h"
       9                 :            : #include "string-util.h"
      10                 :            : #include "tests.h"
      11                 :            : 
      12                 :          0 : int main(int argc, char *argv[]) {
      13                 :          0 :         _cleanup_(loop_device_unrefp) LoopDevice *d = NULL;
      14                 :          0 :         _cleanup_(dissected_image_unrefp) DissectedImage *m = NULL;
      15                 :            :         int r, i;
      16                 :            : 
      17                 :          0 :         test_setup_logging(LOG_DEBUG);
      18                 :            : 
      19         [ #  # ]:          0 :         if (argc < 2) {
      20         [ #  # ]:          0 :                 log_error("Requires one command line argument.");
      21                 :          0 :                 return EXIT_FAILURE;
      22                 :            :         }
      23                 :            : 
      24                 :          0 :         r = loop_device_make_by_path(argv[1], O_RDONLY, &d);
      25         [ #  # ]:          0 :         if (r < 0) {
      26         [ #  # ]:          0 :                 log_error_errno(r, "Failed to set up loopback device: %m");
      27                 :          0 :                 return EXIT_FAILURE;
      28                 :            :         }
      29                 :            : 
      30                 :          0 :         r = dissect_image(d->fd, NULL, 0, DISSECT_IMAGE_REQUIRE_ROOT, &m);
      31         [ #  # ]:          0 :         if (r < 0) {
      32         [ #  # ]:          0 :                 log_error_errno(r, "Failed to dissect image: %m");
      33                 :          0 :                 return EXIT_FAILURE;
      34                 :            :         }
      35                 :            : 
      36         [ #  # ]:          0 :         for (i = 0; i < _PARTITION_DESIGNATOR_MAX; i++) {
      37                 :            : 
      38         [ #  # ]:          0 :                 if (!m->partitions[i].found)
      39                 :          0 :                         continue;
      40                 :            : 
      41                 :          0 :                 printf("Found %s partition, %s of type %s at #%i (%s)\n",
      42                 :            :                        partition_designator_to_string(i),
      43         [ #  # ]:          0 :                        m->partitions[i].rw ? "writable" : "read-only",
      44                 :          0 :                        strna(m->partitions[i].fstype),
      45                 :          0 :                        m->partitions[i].partno,
      46                 :          0 :                        strna(m->partitions[i].node));
      47                 :            :         }
      48                 :            : 
      49                 :          0 :         return EXIT_SUCCESS;
      50                 :            : }

Generated by: LCOV version 1.14