Regress Modifications: Support Javascript-Enabled Display
Newsgroup: mozilla.dev.tech.cryptoTechnical contact: Bob Relyea
Yell at the manager: Bob Lord
Overview
The HTML output produced by Regress is currently in tabular format. This format has the following disadvantages:
- When entries get above 8000, the Browser will often crash due to difficulties in drawing the table for such a large number of entries.
- When there are too many entries, it is difficult to go to a specific test and look at the results.
- There is no mechanism in which to look at only fail entries or only pass entries given a page containing a mix of both types
Changes to regress usage
Regress may be set to output its test result data in either the old Table format or the new JavaScript format by specifying at the command line:
regress specfile=[specfilename]
style=table // for the old table format
or
regress specfile=[specfilename]
style=javascript // for the new javascript format
If style is not specified at the command line,
then the default is the new javascript format
Alternatively, Regress users can specify in their
regress specfile under [General] header, an additional field
style=[table|javascript]
NOTE: The value set at the command line will overwrite any style options set in the specfile.
Here is an example of the JavaScript Interface.
Notes about the Code
(You should read the following only if you intend to make changes to
the JavaScript interface)
The heart of the Javascript generation code is a collection of functions
which I have defined in genjs.c and genjs.h. These two
files are built by a Perl script makeGenJS.pl. The basic
idea is that the makeGenJS.pl script takes a Javascript template genjs_template.html
and extracts portions of the code to generate genjs.c and genjs.h.
Using this methodology, one can easily make changes to the JavaScript template
in terms of code or display layout modifications without ever looking at
the C code. Below is a list of functions created in genjs.c
by makeGenJS.pl, and a brief description of their purpose/behavior:
Function Name | Description |
genJS_Top(PRFileDesc*) | Every output page generated by Regress will have a general static region (actually 2) of JavaScript code which does not change depending on the test run. This function prints out the static JavaScript portion up to the data insertion section (marked by "//data init") (see below for template layout) |
genJS_Bottom(PRFileDesc*) | This function outputs the static Javascript code from after the data initialization region to the very end of the template. |
genJS_Header(PRFileDesc*, char*) | Generates the appropriate header <TITLE>[name of page]</TITLE> for the test being run. The second argument is the string containing the page title |
genJS_InsertVars(....) | Inserts variable initialization statements for JavaScript variables:
mutdesc, mutversion, rundate and platform. Takes as argument the values these four variables are to be initialized to, and outputs the following text to the output file: var mutdesc = <mutdesc value>;
|
genJS_SummaryVars(...) | The same idea as with InsertVars, but outputs initialization statements for Summary Table related variables: numPass, numFail, numKnownFail, and numMalFormed. |
genJS_DeclareData(PRFileDesc*, char* length) | Outputs the Data array declaration string:
var Data = new Array(<length>); |
genJS_InsertData(...) | Outputs the initialization expressions for each Data element.
(This function is called for each test combination).
Hence will produce the following for [Test-n] Data[<n>] = new TestData( < arguments that initializes test object n >); |
genJS_PutColor(char* string, char* colorCode) | A simple HTML utility that wraps a <FONT COLOR="<colorCode">
</FONT> around the given string. Does the same thing as
GENHTML_PutColor, but produces escaped quotes in the output.
For example: genJS_PutColor will generate
<FONT COLOR=\"<colorCode>\">....</FONT> whereas GENHTML_PutColor will generate <FONT COLOR="<colorCode>"...</FONT> The escaped quotes around <colorCode> is necessary because what is generated by genJS_PutColor must be reinterpreted by JavaScript (in essence we are outputting code, so quotes in strings must be escaped.) |
How the Java Script template is organized
<HTML>
<HEAD>....
<SCRIPT language=JavaScript> <==== genJS_Header
generates this portion
....
<==== All the code up to this point goes into genJS_Top
//data init
<==== genJS_InsertVars, genJS_SummaryVar, genJS_DeclareData, and
genJS_InsertData are called here to initialize Java script variables
...
</SCRIPT>
</HTML>
JavaScript Data Organization:
Basically, in place of Table elements, all the data collected by Regress for each test is turned into a Data[] array element initialization statement. Each Data[] element current contains the following Fields:
testno // a number representing the 'n' in [Test-n].
// The
testno is not guaranteed to have one to one correspondence with
// Data[]'s index.
passOrFail // A flag to indicate pass or fail status of a test
1 is a Pass, 0 is a Fail
// The following fields are simply strings that correspond to the original
// table columns which they belonged in
filename
description
starttime
endtime
result
Each Data[] element is initialized in the following manner:
Data[<n>] = new TestData(<testno>, <passOrFail>, "<filename>", "<description>", "<starttime>", "<endtime>", "<result>")
Each test has its own Data[] initialization statement.
Making Changes:
When making changes to the JavaScript template the following guidelines should be followed
- Avoid escaped characters when possible. Although I have programmed into the Perl script to check for escaped characters and replace them with escaped escaped characters (because we are generating code that generate code), there may be holes which I have not fully checked for. If you require to print a "\n" (new line) character use the javascript function writeln instead.
- Use the variables defined for summary and general variables (as described above for genJS_SummaryVars and genJS_InsertVars) do not invent new ones.
The following is a brief description of JavaScript
functions that generate HTML, these functions can be modified in order
to change the appearance of the output interface.
JavaScript Function | Description |
generateTable() | contains the code that produces the HTML (Table) in the middle frame |
createControlPanel() | contains the code that produces the interface in the bottom frame. |
createHeader() | generates the HTML in the first frame. Which has the module under test description and the Summary data. |
A Note on Building genjs.c and genjs.h
After making modifications to either the genjs_template.html,
or makeGenJS.pl (the Perl script that generates the C code). Invoke
makeGenJS.pl (make sure you are using at least
version 4 Perl). This will rebuild the above genjs source
files. Then, simply follow general Regress building instructions.