Creating glue code for the LibWWW



Introduction:

The glue code from C to Tcl of the LibWWW was created to create Tcl scripts to test the Library. The main software tool utilized isDejaGnu. The glue code was created for the testing of individual core functions of the library. With glue code, they became functions in the Tcl interpreter. The Tcl interpreter was altered to include the glue code. Thus, aside from testing, the tcl shell can be used to create small applications using tcl/tk.

Creating Tcl glue code

The glue code itself follows a standard format:


int function_name_tcl(ClientData clientData, Tcl_Interp *interp, 
		      int argc, char **argv) {
    if (argc == 2) {
	char *str    = argv[1];
	
	....variable initialization....
	
	....function calls...

	Tcl_AppendResult(interp, result, NULL);
	return TCL_OK;
    }
    else {
	
	....alert user to improper function call - wrong number of arguments?

	return TCL_ERROR;
    }
}

The tcl function can be broken up into a number of possible parts:

Arguments

Function arguments are treated just like command line arguments for C. To check the function has the right number of parameters, you check argc. Otherwise you return an error statement.

Variable Intialization

All variables in connection to the function need to be initialized. This includes all variables for the function parameters and function outputs. Also, there is also the need to initialize enough Tcl hash table pointers for the number of data structures you have.

Hash Table retrieving

This is only used if there are data structures that can't be represented by the siable in./usr/share/doc/libwww-doc/html/Library/Test/0040755000000000000000000000000007503632551017750 5ustar rootroot./usr/share/doc/libwww-doc/html/Library/Test/User/0040755000000000000000000000000007503632551020666 5ustar rootroot./usr/share/doc/libwww-doc/html/Library/Test/User/running.html0100644000000000000000000000160207503632574023235 0ustar rootroot Testing of the LibWWW

Running the Function Testing

We use the GNU standard setup with Automake and DejaGnu. If you have installed dejagnu into the path, you're set. Otherwise, make sure you set the proper environment variables.

Installing and Running the Tests

  1. Compile the WWW Sample Code Library and wwwtest
  2. Download dejagnu and follow the compiling/install inistructions
  3. Make sure DEJAGNULIBS points to the directory containing runtest
  4. Run 'make check'

If you want to specify a module, edit the makefile and replace the TEST_FILES variable to the specific script.


alian@mit.edu  (neon@w3.org) Alexander Lian. August 20.1996
./usr/share/doc/libwww-doc/html/Library/Test/User/tests.html0100644000000000000000000001157107503632574022725 0ustar rootroot Glue code for the LibWWW to Tcl

Creating glue code for the LibWWW


Introduction

The tests are simply scripts run in the Expect/Tcl language. They rely on the glue code which relys on the library, so changes in the library require twice the number of changes to test the basic functions.
To keep the tests readable, I've kept them in a pretty simple format, and created some standard procedures to run them through their paces.
There are some problems interfacing with Tcl to C, and vice versa. If the function faults, the whole program is liable to crash. I mostly catch all these problems, but I have yet to create initialization scripts to renew all the variables so that the rest of the tests do