$Id: TODO,v 1.5 2003/09/14 04:41:45 vlg Exp $

Here you find various test-related notes.

There are tree kinds of tests:

	- simple tests
	- client/server tests
	- performance tests

================================================================================
General notes 
================================================================================

For every class in ASSA tested, the file name dependency is:

Class....... : NAME
Test........ : NAME_test.cpp
Shell script : NAME.test

Every test should at the minimum:

1) Write all of your messages to sdtout like this:

	enum { TEST = USR1 };
	...
    m_debug_mask = TEST;
    m_log_file = "/dev/null";
	m_log_stdout_flag = true;
    ...
	DL((TEST,"... message here ... =\n"));

2) Announce test name with:

	DL((TEST,"= Running NAME_test Test =\n"));

3)  Log minimum status information and return the right 
	return value (0: success, 1: error) depending
	on the outcome of the testing. If you disable trace() in the calling
	function (processServer()), you don't need newline to separate 
	messages, i.e.:

	DL((TEST,"Testing comment match ... "));
	...
	if (condition occured) {
		DL((TEST," failed to match valid section!\n"));
		...
	}
	DL((TEST,"ok\n"));

	The output might look like:

	Testing comment match ... ok

	
4) New shell scripts are created by copying TEST_TEMPLAT file.

================================================================================
Client-server tests require --build-dir option.
================================================================================

For the client-server tests, client typically spans off its server side
at some point during the test. The executables of both client and server
are in ${topbuild_dir}/tests. The test script, however, changes directory
to the subdirectory ${topbuild_dir}/tests/testSubDir for the duration of
the test. The implication of this is that the client side has to 
know where the executables are and specify the full path to them.
The test script supplies build directory path to the client via
{--build-dir STRING} command-line argument. If abscent, the client code
assumes that the current directory is where the executables are.

===============
= Client side =
===============

client --build-dir STRING

"     --build-dir STRING  - Directory where executables are located.         \n"

#include "assa/CommonUtils.h"

class Client {
public:
	string get_build_dir () const { return m_build_dir; }

private:
	string m_build_dir;
};

Client::Client () 
{
	add_opt (0, "build-dir", &m_build_dir);
}

void Client::initServer ()
{
	if (m_build_dir.length () == 0) {
		m_build_dir = CommonUtils::get_cwd_name ();
	}
	DL((APP,"build-dir = \"%s\"\n", m_build_dir.c_str ()));
}	

void Client::processServer ()
{
	// ... somewhere in the test ...

	std::string exec_name;
	exec_name = CLIENT->get_build_dir () + "/server-side-name";
	Fork f (Fork::KILL_ON_EXIT);
	if (f.isChild ()) {
		ret = execlp (exec_name.c_str (),
					  exec_name.c_str (),
					  "--log-file=server-side-name.log", "--mask=0x2", 
					  NULL);
		// point of no return
		if (ret == -1) {
			EL((ERROR,"execlp(\"server-side-name\") failed\n"));
		}
		Assert_exit (false);	
	}
}

======================
= <test>.test script =
======================

RUNTEST="${top_builddir}/tests/client-name --build-dir=${top_builddir}/tests"



================================================================================
List of all test programs and their completion status
================================================================================

[x] autoptr
[x] glops
[x] commonutils_test
[x] connector_test
[x] fdset_test
[x] idset_test
[x] fork_test
[x] genserver_test
[x] inet_address_test
[x] logger_test
[x] memdump_test
[x] pidflock_test
[x] pq_test
[x] semaphore_test
[x] timeval_test
[x] rt_test
[x] sighand_test
[x] sighands_test
[x] timer_queue_test
[x] reactor_test
[x] regexp_test
[x] inifile_test

====================
Client/Server tests:
====================
[x] echoxdr_testc
[x] echoxdr_tests

[x] pipe_test
[x] smoker

[x] bufio_testc <-- still timing problem. When started with no
[x] bufio_tests     logging enabled, always fails.

==================
Performance tests:
==================
[x] ttcp_assa
[x] ttcp

==================
Need investigation
==================

[ ] uncon_udp_socket_test -	compiles, but doesn't receive UDP frame.
