The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CTest - Perl extension for testing local 'C' routines

SYNOPSIS

  use CTest;

DESCRIPTION

This module consists of various test routines to exercise the subroutines in the the 'C' pieces for dnsbls

  • $rv=t_main(qw(program_name args, arg2,..., argN);

      input:        program name
                    -d
                    -f etc... see readme
      output:       number of arguments passed
  • t_setsig();

      set the signal handler. 
      test routine should issue SIGINT 
      to child and catch resulting text
  • t_set_parent(val);

      set the value of "parent"
      return the previous value
  • t_set_qflag(val);

      set the value of "qflag"
      return the previous value
  • t_set_stop(val);

      set the value of "stop"
      return the previous value
    
      This flag forces 'main' to return(0)
      as soon as it enters the -T print 
      routine BEFORE it issues STDOUT
  • $pid = t_pidrun()

      input:        none
      output:       pid found in pid file
    
      see t_chk4pid below
  • t_savpid(path2pidfile)

      input:        path to pid file
      output:       none
    
      saves the pid of the current process
      in the pid file (path2pidfile)
  • $pidpath = t_chk4pid(path)

      input:        path to pid file
      output:       undef or path to pid file
    
      checks for a process running with the pid
      found in "path". If the process is running
      return undef, otherwise return the "path".
      Always places the "pid" found in pid file
      into the variable "pidrun".
  • $pidpath = t_pidpath();

      input:        none
      output:       current pidpath/file
  • $err = t_init(home,...);

      input:        dbhome
                    db file name
                    secondary db file name (optional)
      output:       0 or error code
  • $err = t_dump(which);

      input:        0  = primary db
                    nz = secondary db
      output:       0 or error code
    
      prints database to STDOUT in the format
            dot.quad.addr => timestamp
  • t_close();

      input:        none
      output:       none
    
      close the database files and environment
  • $data = t_get(which,addr);

      input:        0  = primary db
                    nz = secondary db
      output:       data (long)
                    or undef if not there
  • $short_hostname = t_short();

      input:        none
      output:       short host name
  • $rv = t_munge(fd,bp,msglen,is_tcp)

      input:        handle number, [fileno(FD)]
                    pointer buffer,
                    length of buffer,
                    tcp flag
    
      output:       number of bytes processed,
                    -1 on error
    
      NOTES: is_tcp
      Setting is_tcp true forces TCP mode in the ns.c
      is_tcp tells ns.c how to process the requests 
      (TCP or UDP) and specifically how to process AXFR 
      requests so we can test all of the program branches.
     
      is_tcp  = 0  use UDP
      is_tcp  = 1  use TCP, AXFR in one message if possible
      is_tcp  = 2  use TCP, AXFR in two messages. The first 
                   message contains all overhead records, SOA, 
                   NS, MX and local host stuff. The second 
                   message contains all numeric A & TXT records  
                   or as many as will fit.
      is_tcp >= 3  The first record is the same as is_tcp 2. 
                   Each additional record contains an A + TXT 
                   record pair for a particular numeric record, 
                   with the last record containing only the SOA
  • $rv = t_cmdline(cmd,stuff);

      input:        one of n a b e m L I z c P Z
                    parameter
      output:       true on success else false
    
      SEE:          command line parameters for
                    dnsbls -n -a -b -e -m -L -I -z -c -P -Z

    L sets the name of the local host. If the zone name has been set already then the zoneEQlocal flag is set appropriately. If local host name is already set when the zone name is set, zoneEQlocal will again be set appropriately.

    I sets the IP address of the local host

  • $rv = t_set_resp(seria_rec,stdResp,stdRespBeg);

    Set various internal address registers

      input:        ipaddr for serial record
                    ipaddr for stdResp
                    ipaddr for stdRespBeg
      output:       true on success,
                    else undef
    
      Set the ip address for db access
  • $rv = t_cmp_serial(s1,s2);

      input:        zone serial number pair
      returns:       0      s1 = s2
                    -1      s1 < s2
                     1      s1 > s2
                    >1       undefined
  • $rv = t_name_skip(buf);

      input:        buffer of characters/numbers
      returns:      integer offset from begining
                    of buffer past dn names
  • $rv = t_set_parent(val);

    Set parent pid value

      input:        new value
      returns:      old value
  • $rv = t_set_qflag(val);

    Set qflag value

      input:        new value
      returns:      old value
  • @rv or $rv = t_ret_resp();

      returns:      one or more of zonefile
                    response values aa,ab,ac,ad
                    as returned by inet_ntoa
  • t_initlb();

    Initialize ip address nibbles, text responses, A responses, origin level ah..dz txa..txd aa..ad org to zero

  • $rv = t_set_org(val);

    Set org value

      input:        new value
      returns:      old value
  • @rv or $rv = t_ret_a_nibls();

      returns:      one or more of zonefile
                    nibble groups
                    ah.am.al.az
                    bh.bm.bl.bz
                    ch.cm.cl.cz
                    dh.dm.dl.dz
                    as returned by inet_ntoa
  • $rv = t_mybuffer(which)

    Returns one of mybuffer, txa, txb, txc, txd as selected by which (0,1,2,3,4) respectively.

  • t_set_dbhome(path);

    Set dbhome to 'path'

      input:        /some/path
  • t_tabout(name,type);

    Tab justify to 3 tabs, the name and type => 'mybuffer' which can be retrieved with t_mybuffer(0)

     mybuffer = 'name                       A       '
  • t_add_A_rec(name,ip_response);

    Use 'tabout' to the name, 'A' type plus ip_response code (text) and put it in 'mybuffer' which can be retrieved with t_mybuffer(0)

    The text ip_response code is converted by inet_aton internally for testing.

  • t_ishift();

    Perform shift operation:

            ip address nibbles
        ch->dh cm->dm cl->dl cz->dz
        bh->ch bm->cm bl->cl bz->cz
        ah->bh am->bm al->bl az->bz
            response codes
        ac->ad ab->ac aa->ab
            txt responses
        txc->txd txb->txc txa->txb
  • t_precrd(F,name,resp,text);

    Print A record line and conditionally TXT line depending on the Zflag

      input:  File handle,
              name fragment,
              response code (ascii)
              text string
  • t_oflush(F);

    Flush the adress nibbles and related codes and text to the output stream 'F'

      input:        file handle
  • t_iload(netaddr,resp,text);

    Load the address, response, text record into process stack.

      input:        netaddr => ah, am, al, az
                    resp    => aa
                    text    => txa
  • t_iprint(F);

    Conditionally print process stack based on the zonefile host address nibbles.

      input:        file handle
  • $rv = t_zone_name();

    Return the zone name

      input:        none
      returns:      zone name or undef
  • $rv = t_zonefile(fd);

    Dump a zonefile named 'zonename.tmp' to the db home directory then rename it to 'zonename.in'

      input:     file handle
      returns:   0 on success
                 1 no serial number found
                -1 start/end serial mismatch
  • ($delta,$partsum,$partmax,$charsum) = t_ratelimit( $run, $new_tv_sec, $new_tv_usec, $then_tv_sec, $then_tv_usec, $diskmax, $charsum, $partsum );

      input:        run,    true=normal, false=debug/test
                    struct timeval 'new' sec, usec
                    struct timeval 'then' sec, usec
                    diskmax,        rate limit chars/sec
                    charsum,        characters so far
                    partsum,        partial sum
      returns:      timeval delta,
                    partsum,        new average
                    partmax         initial value
                    charsum         total so far or cleared
    
      If either element of 'then' is undefined then the 
      remaining internal value is used rather than
      being set from the input data

EXPORT

None

AUTHOR

Michael Robinton <michael@bizsystems.com>

See also: files in subdirectory ./t