LCOV - code coverage report
Current view: top level - tests - strtonum-tests.c (source / functions) Hit Total Coverage
Test: .coverage.total Lines: 296 299 99.0 %
Date: 2015-10-19 Functions: 28 28 100.0 %

          Line data    Source code
       1             : /*
       2             :    SSSD
       3             : 
       4             :    InfoPipe
       5             : 
       6             :    Copyright (C) Stephen Gallagher <sgallagh@redhat.com>  2009
       7             : 
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include <stdlib.h>
      23             : #include <check.h>
      24             : #include <errno.h>
      25             : #include <popt.h>
      26             : #include "util/util.h"
      27             : #include "util/strtonum.h"
      28             : #include "tests/common.h"
      29             : 
      30             : /********************
      31             :  * Utility routines *
      32             :  ********************/
      33             : #define EXPECT_UNSET_ERRNO(error) \
      34             :     do { \
      35             :         fail_unless(error == 0, "errno unexpectedly set to %d[%s]", \
      36             :                                 error, strerror(error)); \
      37             :     } while(0)
      38             : 
      39             : #define CHECK_RESULT(expected, actual) \
      40             :     do { \
      41             :         fail_unless(actual == expected, "Expected %ld, got %ld", \
      42             :                                         expected, actual); \
      43             :     } while(0)
      44             : 
      45             : #define CHECK_ERRNO(expected, actual) \
      46             :     do { \
      47             :         fail_unless(actual == expected, "Expected errno %d[%s], got %d[%s]", \
      48             :                                         expected, strerror(expected), \
      49             :                                         actual, strerror(actual)); \
      50             :     } while(0)
      51             : 
      52             : #define CHECK_ENDPTR(expected, actual) \
      53             :     do { \
      54             :         fail_unless(actual == expected, "Expected endptr %p, got %p", \
      55             :                                          expected, actual); \
      56             :     } while(0)
      57             : 
      58             : #define CHECK_ZERO_ENDPTR(endptr) \
      59             :     do { \
      60             :         fail_unless(endptr && *endptr == '\0', "Invalid endptr"); \
      61             :     } while(0)
      62             : 
      63             : /******************
      64             :  * strtoint tests *
      65             :  ******************/
      66             : 
      67             : /* Base-10 */
      68           1 : START_TEST (test_strtoint32_pos_integer_base_10)
      69             : {
      70             :     int32_t result;
      71           1 :     const char *input = "123";
      72           1 :     int32_t expected = 123;
      73             :     char *endptr;
      74             :     errno_t error;
      75             : 
      76           1 :     result = strtoint32(input, &endptr, 10);
      77           1 :     error = errno;
      78             : 
      79           1 :     EXPECT_UNSET_ERRNO(error);
      80           1 :     CHECK_ZERO_ENDPTR(endptr);
      81           2 :     CHECK_RESULT(expected, result);
      82             : }
      83           1 : END_TEST
      84             : 
      85           1 : START_TEST (test_strtoint32_neg_integer_base_10)
      86             : {
      87             :     int32_t result;
      88           1 :     const char *input = "-123";
      89           1 :     int32_t expected = -123;
      90             :     char *endptr;
      91             :     errno_t error;
      92             : 
      93           1 :     result = strtoint32(input, &endptr, 10);
      94           1 :     error = errno;
      95             : 
      96           1 :     EXPECT_UNSET_ERRNO(error);
      97           1 :     CHECK_ZERO_ENDPTR(endptr);
      98           2 :     CHECK_RESULT(expected, result);
      99             : }
     100           1 : END_TEST
     101             : 
     102           1 : START_TEST (test_strtoint32_pos_integer_intmax_base_10)
     103             : {
     104             :     int32_t result;
     105           1 :     const char *input = "2147483647";
     106           1 :     int32_t expected = INT32_MAX;
     107             :     char *endptr;
     108             :     errno_t error;
     109             : 
     110           1 :     result = strtoint32(input, &endptr, 10);
     111           1 :     error = errno;
     112             : 
     113           1 :     EXPECT_UNSET_ERRNO(error);
     114           1 :     CHECK_ZERO_ENDPTR(endptr);
     115           2 :     CHECK_RESULT(expected, result);
     116             : }
     117           1 : END_TEST
     118             : 
     119           1 : START_TEST (test_strtoint32_neg_integer_intmin_base_10)
     120             : {
     121             :     int32_t result;
     122           1 :     const char *input = "-2147483648";
     123           1 :     int32_t expected = INT32_MIN;
     124             :     char *endptr;
     125             :     errno_t error;
     126             : 
     127           1 :     result = strtoint32(input, &endptr, 10);
     128           1 :     error = errno;
     129             : 
     130           1 :     EXPECT_UNSET_ERRNO(error);
     131           1 :     CHECK_ZERO_ENDPTR(endptr);
     132           2 :     CHECK_RESULT(expected, result);
     133             : }
     134           1 : END_TEST
     135             : 
     136           1 : START_TEST (test_strtoint32_pos_integer_overflow_base_10)
     137             : {
     138             :     int32_t result;
     139           1 :     const char *input = "8589934592";
     140           1 :     int32_t expected = INT32_MAX;
     141             :     char *endptr;
     142             :     errno_t error;
     143             : 
     144           1 :     result = strtoint32(input, &endptr, 10);
     145           1 :     error = errno;
     146             : 
     147           1 :     CHECK_ERRNO(ERANGE, error);
     148           1 :     CHECK_ZERO_ENDPTR(endptr);
     149           2 :     CHECK_RESULT(expected, result);
     150             : }
     151           1 : END_TEST
     152             : 
     153           1 : START_TEST (test_strtoint32_pos_integer_underflow_base_10)
     154             : {
     155             :     int32_t result;
     156           1 :     const char *input = "-8589934592";
     157           1 :     int32_t expected = INT32_MIN;
     158             :     char *endptr;
     159             :     errno_t error;
     160             : 
     161           1 :     result = strtoint32(input, &endptr, 10);
     162           1 :     error = errno;
     163             : 
     164           1 :     CHECK_ERRNO(ERANGE, error);
     165           1 :     CHECK_ZERO_ENDPTR(endptr);
     166           2 :     CHECK_RESULT(expected, result);
     167             : }
     168           1 : END_TEST
     169             : 
     170           1 : START_TEST (test_strtoint32_mixed_alphanumeric_base_10)
     171             : {
     172             :     int32_t result;
     173           1 :     const char *input = "12b13";
     174           1 :     int32_t expected = 12;
     175             :     char *endptr;
     176           1 :     const char *expected_endptr = input+2;
     177             :     errno_t error;
     178             : 
     179           1 :     result = strtoint32(input, &endptr, 10);
     180           1 :     error = errno;
     181             : 
     182           1 :     EXPECT_UNSET_ERRNO(error);
     183           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     184           1 :     CHECK_RESULT(expected, result);
     185             : }
     186           1 : END_TEST
     187             : 
     188           1 : START_TEST (test_strtoint32_alphaonly_base_10)
     189             : {
     190             :     int32_t result;
     191           1 :     const char *input = "alpha";
     192           1 :     int32_t expected = 0;
     193             :     char *endptr;
     194           1 :     const char *expected_endptr = input;
     195             :     errno_t error;
     196             : 
     197           1 :     result = strtoint32(input, &endptr, 10);
     198           1 :     error = errno;
     199             : 
     200           1 :     EXPECT_UNSET_ERRNO(error);
     201           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     202           1 :     CHECK_RESULT(expected, result);
     203             : }
     204           1 : END_TEST
     205             : 
     206           1 : START_TEST (test_strtoint32_alphastart_base_10)
     207             : {
     208             :     int32_t result;
     209           1 :     const char *input = "alpha12345";
     210           1 :     int32_t expected = 0;
     211             :     char *endptr;
     212           1 :     const char *expected_endptr = input;
     213             :     errno_t error;
     214             : 
     215           1 :     result = strtoint32(input, &endptr, 10);
     216           1 :     error = errno;
     217             : 
     218           1 :     EXPECT_UNSET_ERRNO(error);
     219           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     220           1 :     CHECK_RESULT(expected, result);
     221             : }
     222           1 : END_TEST
     223             : 
     224           1 : START_TEST (test_strtoint32_emptystring_base_10)
     225             : {
     226             :     int32_t result;
     227           1 :     const char *input = "";
     228           1 :     int32_t expected = 0;
     229             :     char *endptr;
     230           1 :     const char *expected_endptr = input;
     231             :     errno_t error;
     232             : 
     233           1 :     result = strtoint32(input, &endptr, 10);
     234           1 :     error = errno;
     235             : 
     236           1 :     EXPECT_UNSET_ERRNO(error);
     237           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     238           1 :     CHECK_RESULT(expected, result);
     239             : }
     240           1 : END_TEST
     241             : 
     242             : /*******************
     243             :  * strtouint tests *
     244             :  *******************/
     245             : 
     246             : /* Base-10 */
     247           1 : START_TEST (test_strtouint32_pos_integer_base_10)
     248             : {
     249             :     uint32_t result;
     250           1 :     const char *input = "123";
     251           1 :     uint32_t expected = 123;
     252             :     char *endptr;
     253             :     errno_t error;
     254             : 
     255           1 :     result = strtouint32(input, &endptr, 10);
     256           1 :     error = errno;
     257             : 
     258           1 :     EXPECT_UNSET_ERRNO(error);
     259           1 :     CHECK_ZERO_ENDPTR(endptr);
     260           2 :     CHECK_RESULT(expected, result);
     261             : }
     262           1 : END_TEST
     263             : 
     264           1 : START_TEST (test_strtouint32_neg_integer_base_10)
     265             : {
     266             :     uint32_t result;
     267           1 :     const char *input = "-123";
     268           1 :     uint32_t expected = UINT32_MAX;
     269             :     char *endptr;
     270             :     errno_t error;
     271             : 
     272           1 :     result = strtouint32(input, &endptr, 10);
     273           1 :     error = errno;
     274             : 
     275           1 :     CHECK_ERRNO(ERANGE, error);
     276           1 :     CHECK_ZERO_ENDPTR(endptr);
     277           2 :     CHECK_RESULT(expected, result);
     278             : }
     279           1 : END_TEST
     280             : 
     281           1 : START_TEST (test_strtouint32_pos_integer_uintmax_base_10)
     282             : {
     283             :     uint32_t result;
     284           1 :     const char *input = "4294967295";
     285           1 :     uint32_t expected = UINT32_MAX;
     286             :     char *endptr;
     287             :     errno_t error;
     288             : 
     289           1 :     result = strtouint32(input, &endptr, 10);
     290           1 :     error = errno;
     291             : 
     292           1 :     EXPECT_UNSET_ERRNO(error);
     293           1 :     CHECK_ZERO_ENDPTR(endptr);
     294           2 :     CHECK_RESULT(expected, result);
     295             : }
     296           1 : END_TEST
     297             : 
     298             : 
     299           1 : START_TEST (test_strtouint32_pos_integer_overflow_base_10)
     300             : {
     301             :     uint32_t result;
     302           1 :     const char *input = "8589934592";
     303           1 :     uint32_t expected = UINT32_MAX;
     304             :     char *endptr;
     305             :     errno_t error;
     306             : 
     307           1 :     result = strtouint32(input, &endptr, 10);
     308           1 :     error = errno;
     309             : 
     310           1 :     CHECK_ERRNO(ERANGE, error);
     311           1 :     CHECK_ZERO_ENDPTR(endptr);
     312           2 :     CHECK_RESULT(expected, result);
     313             : }
     314           1 : END_TEST
     315             : 
     316           1 : START_TEST (test_strtouint32_mixed_alphanumeric_base_10)
     317             : {
     318             :     uint32_t result;
     319           1 :     const char *input = "12b13";
     320           1 :     uint32_t expected = 12;
     321             :     char *endptr;
     322           1 :     const char *expected_endptr = input+2;
     323             :     errno_t error;
     324             : 
     325           1 :     result = strtouint32(input, &endptr, 10);
     326           1 :     error = errno;
     327             : 
     328           1 :     EXPECT_UNSET_ERRNO(error);
     329           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     330           1 :     CHECK_RESULT(expected, result);
     331             : }
     332           1 : END_TEST
     333             : 
     334           1 : START_TEST (test_strtouint32_alphaonly_base_10)
     335             : {
     336             :     uint32_t result;
     337           1 :     const char *input = "alpha";
     338           1 :     uint32_t expected = 0;
     339             :     char *endptr;
     340           1 :     const char *expected_endptr = input;
     341             :     errno_t error;
     342             : 
     343           1 :     result = strtouint32(input, &endptr, 10);
     344           1 :     error = errno;
     345             : 
     346           1 :     EXPECT_UNSET_ERRNO(error);
     347           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     348           1 :     CHECK_RESULT(expected, result);
     349             : }
     350           1 : END_TEST
     351             : 
     352           1 : START_TEST (test_strtouint32_alphastart_base_10)
     353             : {
     354             :     uint32_t result;
     355           1 :     const char *input = "alpha12345";
     356           1 :     uint32_t expected = 0;
     357             :     char *endptr;
     358           1 :     const char *expected_endptr = input;
     359             :     errno_t error;
     360             : 
     361           1 :     result = strtouint32(input, &endptr, 10);
     362           1 :     error = errno;
     363             : 
     364           1 :     EXPECT_UNSET_ERRNO(error);
     365           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     366           1 :     CHECK_RESULT(expected, result);
     367             : }
     368           1 : END_TEST
     369             : 
     370           1 : START_TEST (test_strtouint32_emptystring_base_10)
     371             : {
     372             :     uint32_t result;
     373           1 :     const char *input = "";
     374           1 :     uint32_t expected = 0;
     375             :     char *endptr;
     376           1 :     const char *expected_endptr = input;
     377             :     errno_t error;
     378             : 
     379           1 :     result = strtouint32(input, &endptr, 10);
     380           1 :     error = errno;
     381             : 
     382           1 :     EXPECT_UNSET_ERRNO(error);
     383           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     384           1 :     CHECK_RESULT(expected, result);
     385             : }
     386           1 : END_TEST
     387             : 
     388             : /* Base-10 */
     389           1 : START_TEST (test_strtouint16_pos_integer_base_10)
     390             : {
     391             :     uint16_t result;
     392           1 :     const char *input = "123";
     393           1 :     uint16_t expected = 123;
     394             :     char *endptr;
     395             :     errno_t error;
     396             : 
     397           1 :     result = strtouint16(input, &endptr, 10);
     398           1 :     error = errno;
     399             : 
     400           1 :     EXPECT_UNSET_ERRNO(error);
     401           1 :     CHECK_ZERO_ENDPTR(endptr);
     402           2 :     CHECK_RESULT(expected, result);
     403             : }
     404           1 : END_TEST
     405             : 
     406           1 : START_TEST (test_strtouint16_neg_integer_base_10)
     407             : {
     408             :     uint32_t result;
     409           1 :     const char *input = "-123";
     410           1 :     uint32_t expected = UINT16_MAX;
     411             :     char *endptr;
     412             :     errno_t error;
     413             : 
     414           1 :     result = strtouint16(input, &endptr, 10);
     415           1 :     error = errno;
     416             : 
     417           1 :     CHECK_ERRNO(ERANGE, error);
     418           1 :     CHECK_ZERO_ENDPTR(endptr);
     419           2 :     CHECK_RESULT(expected, result);
     420             : }
     421           1 : END_TEST
     422             : 
     423           1 : START_TEST (test_strtouint16_pos_integer_uintmax_base_10)
     424             : {
     425             :     uint32_t result;
     426           1 :     const char *input = "65535";
     427           1 :     uint32_t expected = UINT16_MAX;
     428             :     char *endptr;
     429             :     errno_t error;
     430             : 
     431           1 :     result = strtouint16(input, &endptr, 10);
     432           1 :     error = errno;
     433             : 
     434           1 :     EXPECT_UNSET_ERRNO(error);
     435           1 :     CHECK_ZERO_ENDPTR(endptr);
     436           2 :     CHECK_RESULT(expected, result);
     437             : }
     438           1 : END_TEST
     439             : 
     440             : 
     441           1 : START_TEST (test_strtouint16_pos_integer_overflow_base_10)
     442             : {
     443             :     uint32_t result;
     444           1 :     const char *input = "131072";
     445           1 :     uint32_t expected = UINT16_MAX;
     446             :     char *endptr;
     447             :     errno_t error;
     448             : 
     449           1 :     result = strtouint16(input, &endptr, 10);
     450           1 :     error = errno;
     451             : 
     452           1 :     CHECK_ERRNO(ERANGE, error);
     453           1 :     CHECK_ZERO_ENDPTR(endptr);
     454           2 :     CHECK_RESULT(expected, result);
     455             : }
     456           1 : END_TEST
     457             : 
     458           1 : START_TEST (test_strtouint16_mixed_alphanumeric_base_10)
     459             : {
     460             :     uint32_t result;
     461           1 :     const char *input = "12b13";
     462           1 :     uint32_t expected = 12;
     463             :     char *endptr;
     464           1 :     const char *expected_endptr = input+2;
     465             :     errno_t error;
     466             : 
     467           1 :     result = strtouint16(input, &endptr, 10);
     468           1 :     error = errno;
     469             : 
     470           1 :     EXPECT_UNSET_ERRNO(error);
     471           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     472           1 :     CHECK_RESULT(expected, result);
     473             : }
     474           1 : END_TEST
     475             : 
     476           1 : START_TEST (test_strtouint16_alphaonly_base_10)
     477             : {
     478             :     uint32_t result;
     479           1 :     const char *input = "alpha";
     480           1 :     uint32_t expected = 0;
     481             :     char *endptr;
     482           1 :     const char *expected_endptr = input;
     483             :     errno_t error;
     484             : 
     485           1 :     result = strtouint16(input, &endptr, 10);
     486           1 :     error = errno;
     487             : 
     488           1 :     EXPECT_UNSET_ERRNO(error);
     489           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     490           1 :     CHECK_RESULT(expected, result);
     491             : }
     492           1 : END_TEST
     493             : 
     494           1 : START_TEST (test_strtouint16_alphastart_base_10)
     495             : {
     496             :     uint32_t result;
     497           1 :     const char *input = "alpha12345";
     498           1 :     uint32_t expected = 0;
     499             :     char *endptr;
     500           1 :     const char *expected_endptr = input;
     501             :     errno_t error;
     502             : 
     503           1 :     result = strtouint16(input, &endptr, 10);
     504           1 :     error = errno;
     505             : 
     506           1 :     EXPECT_UNSET_ERRNO(error);
     507           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     508           1 :     CHECK_RESULT(expected, result);
     509             : }
     510           1 : END_TEST
     511             : 
     512           1 : START_TEST (test_strtouint16_emptystring_base_10)
     513             : {
     514             :     uint32_t result;
     515           1 :     const char *input = "";
     516           1 :     uint32_t expected = 0;
     517             :     char *endptr;
     518           1 :     const char *expected_endptr = input;
     519             :     errno_t error;
     520             : 
     521           1 :     result = strtouint16(input, &endptr, 10);
     522           1 :     error = errno;
     523             : 
     524           1 :     EXPECT_UNSET_ERRNO(error);
     525           1 :     CHECK_ENDPTR(expected_endptr, endptr);
     526           1 :     CHECK_RESULT(expected, result);
     527             : }
     528           1 : END_TEST
     529             : 
     530             : 
     531           1 : Suite *create_strtonum_suite(void)
     532             : {
     533           1 :     Suite *s = suite_create("strtonum");
     534             : 
     535           1 :     TCase *tc_strtoint32 = tcase_create("strtoint32 Tests");
     536           1 :     tcase_add_test(tc_strtoint32, test_strtoint32_pos_integer_base_10);
     537           1 :     tcase_add_test(tc_strtoint32, test_strtoint32_neg_integer_base_10);
     538           1 :     tcase_add_test(tc_strtoint32, test_strtoint32_pos_integer_intmax_base_10);
     539           1 :     tcase_add_test(tc_strtoint32, test_strtoint32_neg_integer_intmin_base_10);
     540           1 :     tcase_add_test(tc_strtoint32, test_strtoint32_pos_integer_overflow_base_10);
     541           1 :     tcase_add_test(tc_strtoint32, test_strtoint32_pos_integer_underflow_base_10);
     542           1 :     tcase_add_test(tc_strtoint32, test_strtoint32_mixed_alphanumeric_base_10);
     543           1 :     tcase_add_test(tc_strtoint32, test_strtoint32_alphaonly_base_10);
     544           1 :     tcase_add_test(tc_strtoint32, test_strtoint32_alphastart_base_10);
     545           1 :     tcase_add_test(tc_strtoint32, test_strtoint32_emptystring_base_10);
     546             : 
     547           1 :     TCase *tc_strtouint32 = tcase_create("strtouint32 Tests");
     548           1 :     tcase_add_test(tc_strtouint32, test_strtouint32_pos_integer_base_10);
     549           1 :     tcase_add_test(tc_strtouint32, test_strtouint32_neg_integer_base_10);
     550           1 :     tcase_add_test(tc_strtouint32, test_strtouint32_pos_integer_uintmax_base_10);
     551           1 :     tcase_add_test(tc_strtouint32, test_strtouint32_pos_integer_overflow_base_10);
     552           1 :     tcase_add_test(tc_strtouint32, test_strtouint32_mixed_alphanumeric_base_10);
     553           1 :     tcase_add_test(tc_strtouint32, test_strtouint32_alphaonly_base_10);
     554           1 :     tcase_add_test(tc_strtouint32, test_strtouint32_alphastart_base_10);
     555           1 :     tcase_add_test(tc_strtouint32, test_strtouint32_emptystring_base_10);
     556             : 
     557           1 :     TCase *tc_strtouint16 = tcase_create("strtouint16 Tests");
     558           1 :     tcase_add_test(tc_strtouint16, test_strtouint16_pos_integer_base_10);
     559           1 :     tcase_add_test(tc_strtouint16, test_strtouint16_neg_integer_base_10);
     560           1 :     tcase_add_test(tc_strtouint16, test_strtouint16_pos_integer_uintmax_base_10);
     561           1 :     tcase_add_test(tc_strtouint16, test_strtouint16_pos_integer_overflow_base_10);
     562           1 :     tcase_add_test(tc_strtouint16, test_strtouint16_mixed_alphanumeric_base_10);
     563           1 :     tcase_add_test(tc_strtouint16, test_strtouint16_alphaonly_base_10);
     564           1 :     tcase_add_test(tc_strtouint16, test_strtouint16_alphastart_base_10);
     565           1 :     tcase_add_test(tc_strtouint16, test_strtouint16_emptystring_base_10);
     566             : 
     567             :     /* Add all test cases to the suite */
     568           1 :     suite_add_tcase(s, tc_strtoint32);
     569           1 :     suite_add_tcase(s, tc_strtouint32);
     570           1 :     suite_add_tcase(s, tc_strtouint16);
     571             : 
     572           1 :     return s;
     573             : }
     574             : 
     575             : 
     576           1 : int main(int argc, const char *argv[]) {
     577             :     int opt;
     578             :     poptContext pc;
     579             :     int failure_count;
     580             :     Suite *strtonum_suite;
     581             :     SRunner *sr;
     582             : 
     583           6 :     struct poptOption long_options[] = {
     584             :         POPT_AUTOHELP
     585           5 :         SSSD_MAIN_OPTS
     586             :         POPT_TABLEEND
     587             :     };
     588             : 
     589             :     /* Set debug level to invalid value so we can deside if -d 0 was used. */
     590           1 :     debug_level = SSSDBG_INVALID;
     591             : 
     592           1 :     pc = poptGetContext(argv[0], argc, argv, long_options, 0);
     593           1 :     while((opt = poptGetNextOpt(pc)) != -1) {
     594             :         switch(opt) {
     595             :         default:
     596           0 :             fprintf(stderr, "\nInvalid option %s: %s\n\n",
     597             :                     poptBadOption(pc, 0), poptStrerror(opt));
     598           0 :             poptPrintUsage(pc, stderr, 0);
     599           0 :             return 1;
     600             :         }
     601             :     }
     602           1 :     poptFreeContext(pc);
     603             : 
     604           1 :     DEBUG_CLI_INIT(debug_level);
     605             : 
     606           1 :     tests_set_cwd();
     607             : 
     608           1 :     strtonum_suite = create_strtonum_suite();
     609           1 :     sr = srunner_create(strtonum_suite);
     610             :     /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
     611           1 :     srunner_run_all(sr, CK_ENV);
     612           1 :     failure_count = srunner_ntests_failed(sr);
     613           1 :     srunner_free(sr);
     614           1 :     return (failure_count==0 ? EXIT_SUCCESS : EXIT_FAILURE);
     615             : }

Generated by: LCOV version 1.10