
CTest - Perl extension for testing local 'C' routines

use CTest;

This module consists of various test routines to exercise the subroutines in the the 'C' pieces for dnsbls
input: program name
-d
-f etc... see readme
output: number of arguments passed
set the signal handler. test routine should issue SIGINT to child and catch resulting text
set the value of "parent" return the previous value
set the value of "qflag" return the previous value
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
input: none output: pid found in pid file see t_chk4pid below
input: path to pid file output: none saves the pid of the current process in the pid file (path2pidfile)
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".
input: none output: current pidpath/file
input: dbhome
db file name
secondary db file name (optional)
output: 0 or error code
input: 0 = primary db
nz = secondary db
output: 0 or error code
prints database to STDOUT in the format
dot.quad.addr => timestamp
input: none output: none close the database files and environment
input: 0 = primary db
nz = secondary db
output: data (long)
or undef if not there
input: none output: short host name
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
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
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
input: zone serial number pair
returns: 0 s1 = s2
-1 s1 < s2
1 s1 > s2
>1 undefined
input: buffer of characters/numbers
returns: integer offset from begining
of buffer past dn names
Set parent pid value
input: new value returns: old value
Set qflag value
input: new value returns: old value
returns: one or more of zonefile
response values aa,ab,ac,ad
as returned by inet_ntoa
Initialize ip address nibbles, text responses, A responses, origin level ah..dz txa..txd aa..ad org to zero
Set org value
input: new value returns: old value
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
Returns one of mybuffer, txa, txb, txc, txd as selected by which (0,1,2,3,4) respectively.
Set dbhome to 'path'
input: /some/path
Tab justify to 3 tabs, the name and type => 'mybuffer' which can be retrieved with t_mybuffer(0)
mybuffer = 'name A '
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.
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
Print A record line and conditionally TXT line depending on the Zflag
input: File handle,
name fragment,
response code (ascii)
text string
Flush the adress nibbles and related codes and text to the output stream 'F'
input: file handle
Load the address, response, text record into process stack.
input: netaddr => ah, am, al, az
resp => aa
text => txa
Conditionally print process stack based on the zonefile host address nibbles.
input: file handle
Return the zone name
input: none returns: zone name or undef
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
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

None

Michael Robinton <michael@bizsystems.com>
