LCOV - code coverage report
Current view: top level - core/test - run-time-utils.c (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 26 26 100.0 %
Date: 2024-01-02 21:04:04 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
       2                 :            : /*
       3                 :            :  * Copyright 2015-2017 IBM Corp.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include <config.h>
       7                 :            : #include <stdlib.h>
       8                 :            : #include <string.h>
       9                 :            : #include <assert.h>
      10                 :            : #include <stdarg.h>
      11                 :            : #include <stdio.h>
      12                 :            : 
      13                 :            : #define __TEST__
      14                 :            : 
      15                 :            : #include "../time-utils.c"
      16                 :            : 
      17                 :          1 : int main(void)
      18                 :            : {
      19                 :          1 :         struct tm *t = malloc(sizeof(struct tm));
      20                 :          1 :         uint32_t *ymd = malloc(sizeof(uint32_t));
      21                 :          1 :         uint64_t *hms = malloc(sizeof(uint64_t));
      22                 :            : 
      23                 :          1 :         t->tm_year = 1982;
      24                 :          1 :         t->tm_mon = 0;
      25                 :          1 :         t->tm_mday = 29;
      26                 :          1 :         t->tm_hour = 7;
      27                 :          1 :         t->tm_min = 42;
      28                 :          1 :         t->tm_sec = 24;
      29                 :            : 
      30                 :          1 :         tm_to_datetime(t, ymd, hms);
      31                 :            : 
      32                 :          1 :         assert(*ymd == 0x19820129);
      33                 :          1 :         assert(*hms == 0x742240000000000ULL);
      34                 :            : 
      35                 :          1 :         memset(t, 0, sizeof(struct tm));
      36                 :            : 
      37                 :          1 :         *ymd = 0x19760412;
      38                 :            : 
      39                 :          1 :         datetime_to_tm(*ymd, *hms, t);
      40                 :          1 :         assert(t->tm_year == 1976);
      41                 :          1 :         assert(t->tm_mon == 03);
      42                 :          1 :         assert(t->tm_mday == 12);
      43                 :          1 :         assert(t->tm_hour == 7);
      44                 :          1 :         assert(t->tm_min == 42);
      45                 :          1 :         assert(t->tm_sec == 24);
      46                 :            : 
      47                 :          1 :         free(t);
      48                 :          1 :         free(ymd);
      49                 :          1 :         free(hms);
      50                 :          1 :         return 0;
      51                 :            : }
      52                 :            : 

Generated by: LCOV version 1.14