LCOV - code coverage report
Current view: top level - tools - mk-tdata.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 20 20 100.0 %
Date: 2015-11-05 17:10:59 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* mk-tdata.c -  Create some simple random testdata
       2             :  * Copyright (C) 1998, 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
       3             :  *
       4             :  * This file is free software; as a special exception the author gives
       5             :  * unlimited permission to copy and/or distribute it, with or without
       6             :  * modifications, as long as this notice is preserved.
       7             :  *
       8             :  * This program is distributed in the hope that it will be useful, but
       9             :  * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
      10             :  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      11             :  */
      12             : 
      13             : #ifdef HAVE_CONFIG_H
      14             : #include <config.h>
      15             : #endif
      16             : #include <stdio.h>
      17             : #include <stdlib.h>
      18             : #include <string.h>
      19             : #include <unistd.h>
      20             : 
      21             : 
      22             : #ifndef RAND_MAX   /* for SunOS */
      23             : #define RAND_MAX 32767
      24             : #endif
      25             : 
      26             : int
      27           7 : main(int argc, char **argv)
      28             : {
      29           7 :   int i, c = 0;
      30           7 :   int limit =0;
      31           7 :   int char_mode = 0;
      32             : 
      33           7 :   if (argc)
      34             :     {
      35           7 :       argc--;
      36           7 :       argv++;
      37             :     }
      38             : 
      39             :   /* Check for option --char N */
      40           7 :   if (argc > 1 && !strcmp (argv[0], "--char"))
      41             :     {
      42           2 :       char_mode = 1;
      43           2 :       c = strtol (argv[1], NULL, 0);
      44           2 :       argc -= 2;
      45           2 :       argv += 2;
      46             :     }
      47             : 
      48           7 :   limit = argc ? atoi(argv[0]) : 0;
      49             : 
      50           7 :   srand(getpid());
      51             : 
      52      122235 :   for (i=0; !limit || i < limit; i++ )
      53             :     {
      54      122228 :       if (char_mode)
      55             :         {
      56         128 :           putchar (c);
      57             :         }
      58             :       else
      59             :         {
      60             : #ifdef HAVE_RAND
      61      122100 :           c = ((unsigned)(1 + (int) (256.0*rand()/(RAND_MAX+1.0)))-1);
      62             : #else
      63             :           c = ((unsigned)(1 + (int) (256.0*random()/(RAND_MAX+1.0)))-1);
      64             : #endif
      65      122100 :           putchar (c);
      66             :         }
      67             :     }
      68           7 :   return 0;
      69             : }

Generated by: LCOV version 1.11