1#!/bin/bash
2#
3# @echo off
4#
5# The test suite command dispatcher
6#
7# Available commands:
8#
9#     0 - Make and install AML tests
10#     1 - Run specified set of tests in all enabled modes
11#     2 - Compare two multi-results of two runs of tests
12#     3 - Print out the names of all the available test cases
13#     4 - Calculate the current state of all bugs and report the summary
14#         tables
15#     5 - Prepare bdemo summary files of one multi-results directory for all
16#         modes
17#     6 - Concatenate bdemo summary files of two multi-results
18#
19# Notations:
20#
21#     ASL      - iASL compiler
22#     acpiexec - AcpiExec utility
23#     acpibin  - AcpiBin utility
24#     ASLTSDIR - pathname of root directory of aslts test suite
25#
26# External definitions required for particular command:
27#
28#     0 - ASLTSDIR, ASL
29#     1 - ASLTSDIR, acpiexec, acpibin
30#     2 - ASLTSDIR
31#     3 - none
32#     4 - ASLTSDIR
33#     5 - ASLTSDIR
34#     6 - ASLTSDIR
35#
36# Other:
37#   Make sure that "." (current directory) is in your default search path.
38#   If necessary, convert all scripts in the aslts/bin directory to unix
39#   line endings:
40#       d2u aslts/bin/*
41#
42# Concepts:
43#
44#     run -   execution of the specified set of tests
45#             for one particular enabled mode
46#
47#     multi-run - execution of the specified set of tests
48#                 for all the enabled modes
49#
50#     multi-result (directory) - directory in RESULTS one containing
51#                                all results of one multi-run
52#
53#     root directory of results - aslts/tmp/RESULTS
54#     root directory of aslts - aslts
55#
56# REMEMBER (To-Be-Done items)
57#
58#  1. Don't forget to add testing of aml/nopt mode.
59#  2. Do make-install till the first error automatically
60#  3. Not implemented yet though announced in Usage:
61#     - "Do 1 [n32 [n64 [s32 [s64]]]] [<test_case_name> [<test_case_name> [...]]]"
62#     - "Make-install all the test cases of the specified test collections"
63#     - ...
64#  4. Add checking of presence of "Large reference count" message in logs
65#
66
67STR_BDEMOSSUM="prepare bdemo summary files of one multi-results directory for all modes"
68STR_CONCBDEMOS="concatenate bdemo summary files of two multi-results"
69STR_BDEMOSTABS="calculate the current state of all bugs and report the summary tables"
70
71usage()
72{
73	echo "Usage:"
74	echo "   print out usage:"
75	echo "     Do"
76	echo "   make and install AML tests:"
77	echo "     Do $ASLCOMPILE [ASLTS|aslts]"
78	echo "     Do $ASLCOMPILE <test_case_name> [<test_case_name> [...]]"
79	echo "     Do $ASLCOMPILE [ALL|all] [functional[complex[exceptions[bdemo[service[mt[Identity2MS]]]]]]]"
80	echo "   run specified set of tests in all enabled modes:"
81	echo "     Do $RUNTESTS"
82	echo "     Do $RUNTESTS [n32 [n64 [o32 [o64]]]] [<test_case_name> [<test_case_name> [...]]]"
83	echo "   compare two multi-results of two runs of tests:"
84	echo "     Do $DIFFRESULTS"
85	echo "     Do $DIFFRESULTS <multi-result directory>"
86	echo "     Do $DIFFRESULTS <new multi-result directory> <old multi-result directory>"
87	echo "   print out names of all the available test cases:"
88	echo "     Do $PRINTTESTCASES"
89	echo "   $STR_BDEMOSTABS:"
90	echo "     Do $BDEMOSTABS <new multi-result directory> <old multi-result directory> <ALLBUGS Description File>"
91	echo "                     <kernel bugzilla Bug List file> <local bugzilla Bug List file>"
92	echo "   $STR_BDEMOSSUM:"
93	echo "     Do $BDEMOSSUM <multi-result directory>"
94	echo "   $STR_CONCBDEMOS:"
95	echo "     Do $CONCBDEMOS <new multi-result directory> <old multi-result directory>"
96}
97
98# Report message
99msg()
100{
101	prog_name=`basename "$0"`
102	echo "$prog_name: $1"
103}
104
105# Report error message
106msgE()
107{
108	prog_name=`basename "$0"`
109	echo "$prog_name[ERROR]: $1"
110}
111
112# Exit the program
113# agr1 - 0 success, non-zero - fail
114do_exit()
115{
116	if [ $1 -eq 0 ]; then
117		if [ "$2" != "" ]; then
118			msg "$2"
119		fi
120		exit 0
121	else
122		msgE "$2"
123		exit 1
124	fi
125}
126
127# Abort program when arg1 is not a directory
128# arg1 - path name of directory
129check_dir()
130{
131	if [ ! -d "$1" ]; then
132		do_exit 1 "Not a directory: $1"
133	fi
134}
135
136# Return the string-description of compare command
137# arg1 - opcode of compare command
138cmp_cmd_string()
139{
140	local msg
141
142	case $1 in
143		1) msg="Compare the last multi-result against the previous one:";;
144		2) msg="Compare the last multi-result against the specified one:";;
145		3) msg="Compare the first(new) specified multi-result against the second(old):";;
146		*) msg="?"
147	esac
148
149	echo "$msg"
150}
151
152# Compare the last multi-result against the previous one
153# arg1 - root directory of results
154do_cmp1()
155{
156	local x previous last DIR0 DIR1
157
158	x=`get_two_last_dirs "$1"`
159	last=`echo "$x" | awk -F: '{ print $2}'`
160	previous=`echo "$x" | awk -F: '{ print $3}'`
161
162	if [ -n "$previous" -a -n "$last" ]; then
163
164		DIR0="$1/$previous"
165		DIR1="$1/$last"
166
167		echo "  root directory of results : $1"
168		echo "  the last multi-result     : $last"
169		echo "  against previous one      : $previous"
170		echo ""
171
172		asltsdiffres "$DIR0" "$DIR1"
173
174	elif [ -n "$last" ]; then
175		echo "There is the only component of root directory of results: $last"
176		echo "root directory of results: $1"
177	else
178		echo "No one component in the root directory of results: $1"
179	fi
180}
181
182# Compare the last multi-result against the specified one
183# arg1 - root directory of results
184# arg2 - second multi-result directory
185do_cmp2()
186{
187	local x last DIR0 DIR1
188
189	x=`get_two_last_dirs "$1"`
190	last=`echo "$x" | awk -F: '{ print $2}'`
191
192	if [ -n "$last" ]; then
193
194		DIR0="$2"
195		DIR1="$1/$last"
196
197		echo "  root directory of results : $1"
198		echo "  the last multi-result     : $DIR1"
199		echo "  against the specified one : $DIR0"
200		echo ""
201
202		asltsdiffres "$DIR0" "$DIR1"
203
204	else
205		echo "No one component in the root directory of results: $1"
206	fi
207}
208
209# Compare the first specified multi-result against the second one
210# arg1 - first multi-result directory
211# arg2 - second multi-result directory
212do_cmp3()
213{
214	local DIR0 DIR1
215
216	DIR0="$2"
217	DIR1="$1"
218
219	echo "  First  (new) specified multi-result : $DIR1"
220	echo "  Second (old) specified multi-result : $DIR0"
221
222	asltsdiffres "$DIR0" "$DIR1"
223}
224
225# Compare two multi-results
226# arg1 - the number of parameters passed to Do utility
227# arg2 - first multi-result directory
228# arg3 - second multi-result directory
229# arg4 - root directory of results
230do_cmp()
231{
232	cmp_cmd_string $1
233
234	if [ $1 == 1 ]; then
235		do_cmp1 "$4"
236	elif [ $1 == 2 ]; then
237		do_cmp2 "$4" "$3"
238	elif [ $1 == 3 ]; then
239		do_cmp3 "$2" "$3"
240	else
241		do_exit 1 "Invalid usage"
242	fi
243}
244
245
246# Summary files of bdemos
247
248do_bdemo_sums()
249{
250	dir="$2"
251
252	echo "$STR_BDEMOSSUM:"
253	echo "  the multi-result  : $dir"
254
255	bdemossum "$dir"
256}
257
258# Concatenate summary files of bdemos
259
260concatenate_bdemo_sums()
261{
262	local DIR0 DIR1
263
264	DIR0="$2"
265	DIR1="$3"
266
267	echo "$STR_CONCBDEMOS:"
268
269	echo "  the first multi-result  : $DIR0"
270	echo "  the second multi-result : $DIR1"
271
272	bdemosconc "$DIR0" "$DIR1"
273}
274
275# Summary table of bdemos
276
277do_bdemo_table()
278{
279	local DIR0 DIR1
280
281	DIR0="$2"
282	DIR1="$3"
283	ALLBUGS="$4"
284	KBSUM="$5"
285	LBSUM="$6"
286
287	echo "$STR_BDEMOSTABS:"
288
289	echo "  the first multi-result        : $DIR0"
290	echo "  the second multi-result       : $DIR1"
291	echo "  ALLBUGS Description File      : $ALLBUGS"
292	echo "  kernel bugzilla Bug List file : $KBSUM"
293	echo "  local bugzilla Bug List file  : $LBSUM"
294	echo "  BUG_STATE_DIR                 : $BUG_STATE_DIR"
295
296	bdemostabs "$DIR0" "$DIR1" "$ALLBUGS" "$KBSUM" "$LBSUM" "$BUG_STATE_DIR"
297}
298
299make_target()
300{
301	local dir restore_dir mode options aslversion
302
303	restore_dir=$PWD
304	target=$1
305	dir="$2"
306	mode=$3
307	aslversion=`get_iasl_version`
308
309	cd "$dir"
310
311	echo "Running make $target from $dir"
312	options="ASLTS_VER=$aslversion"
313	if [ ! -z $mode ]; then
314		options="$options ASLTS_MODE=$mode"
315	fi
316	make $target $options > /dev/null
317	res=$?
318
319	cd "$restore_dir"
320	return $res
321}
322
323
324binary_compare()
325{
326	mode=$1
327	aslversion=`get_iasl_version`
328
329	disasm_compile_dir="$ASLTSDIR/tmp/aml/$aslversion/$mode"
330	normal_compile_dir="$ASLTSDIR/tmp/aml/$aslversion/nopt/64"
331
332	echo "Performing binary comparison of AML files within"
333	echo "    $normal_compile_dir"
334	echo "    $disasm_compile_dir"
335
336	if [ ! -d $disasm_compile_dir ]; then
337		echo "  $dism_compile_dir does not exist. Aborting binary compare"
338		return;
339	fi
340	if [ ! -d $normal_compile_dir ]; then
341		echo "  $normal_compile_dir does not exist. Aborting binary compare"
342		return;
343	fi
344	for f in $disasm_compile_dir/*
345	do
346		filename=`basename $f`
347                if [ ! -f "$normal_compile_dir/$filename" ]; then
348			echo "  binary compare $mode the following file does not exist: $normal_compile_dir/$filename"
349		else
350			$acpibin -a "$f" "$normal_compile_dir/$filename" > /dev/null
351			if [ $? -ne 0 ]; then
352				echo " [[ Error: $mode Binary compare for $filename failed ]]"
353			else
354				echo "  $mode Binary compare for $filename passed"
355			fi
356		fi
357	done
358}
359
360make_install()
361{
362	local res=0 nres=0
363	execonly=$2
364
365	if [ $ENABLENORM32 != 0 ]; then
366		echo "Make n32"
367		make_target install "$1" "n32"
368		nres=$?
369		if [ $nres -ne 0 ]; then
370			res=$nres
371		fi
372	fi
373	if [ $ENABLENORM64 != 0 ]; then
374		echo "Make n64"
375		make_target install "$1" "n64"
376		nres=$?
377		if [ $nres -ne 0 ]; then
378			res=$nres
379		fi
380	fi
381	if [ $ENABLEOPT32 != 0 ]; then
382		echo "Make s32"
383		make_target install "$1" "o32"
384		nres=$?
385		if [ $nres -ne 0 ]; then
386			res=$nres
387		fi
388	fi
389	if [ $ENABLEOPT64 != 0 ]; then
390		echo "Make s64"
391		make_target install "$1" "o64"
392		nres=$?
393		if [ $nres -ne 0 ]; then
394			res=$nres
395		fi
396	fi
397	if [ "x$execonly" = "xno" ]; then
398		# for binary compare, we need to compare with normal 64 bit aml
399                # files build n64 mode normal 64 bit aml files build n64 mode
400		# if this test run does not include it.
401		if [ $ENABLENORM64 -eq 0 ]; then
402			echo "Make n64"
403			make_target install "$1" "n64"
404			nres=$?
405			if [ $nres -ne 0 ]; then
406				res=$nres
407			fi
408		fi
409		echo "Make ASL convert"
410		make_target install "$1" "aslconvert"
411		find . -type f -name *.dsl -delete
412		nres=$?
413		binary_compare "aslconvert"
414		nres=$(($nres+ $?))
415		if [ $nres -ne 0 ]; then
416			res=$(($res + $nres))
417		fi
418
419		echo "Make ASL plus"
420		make_target install "$1" "aslplus"
421		nres=$?
422		binary_compare "aslplus"
423		nres=$(($nres+ $?))
424		if [ $nres -ne 0 ]; then
425			res=$nres
426		fi
427		echo "Make ASL minus"
428		make_target install "$1" "aslminus"
429		nres=$?
430		binary_compare "aslminus"
431		nres=$(($nres+ $?))
432		if [ $nres -ne 0 ]; then
433			res=$(($res + $nres))
434		fi
435	fi
436
437	return $res
438}
439
440# Make-install all the provided test cases
441# (make install from aslts directory)
442# arg1 - root directory of aslts
443make_install_1()
444{
445	make_install "$1" "$2"
446	if [ $? -ne 0 ]; then
447		do_exit 1 "make install error"
448	fi
449}
450
451# Check parameters to be the names of test
452# cases and run make install for each of them
453# if specified.
454# arg1 - root directory of aslts
455# arg2 - all the lexem here must be the names of test cases
456# arg3 - either to actually run make install
457do_test_cases_make_install()
458{
459	local errors=0 dir restore_dir execonly
460
461	restore_dir=$PWD
462	execonly=$4
463
464	for filename in $2
465	do
466		get_collection_opcode "$filename"
467		ret=$?
468		if [ $ret -eq $COLLS_NUM ]; then
469			do_exit 1 "Not the name of any test case: $filename"
470		fi
471
472		dir="`get_test_case_dir "$1" $ret $filename`"
473		check_dir "$dir"
474
475		if [ $3 != 0 ]; then
476			make_install "$dir" "$execonly"
477			if [ $? -ne 0 ]; then
478				errors=1
479			fi
480		fi
481	done
482
483	cd "$restore_dir"
484}
485
486# Make-install a list of specified test cases
487# arg1 - root directory of aslts
488# arg2 - all the lexem here must be the names of test cases
489make_install_2()
490{
491	# Check only all parameters are correct
492	# (abort when something is wrong)
493
494	do_test_cases_make_install "$1" "$2" 0
495
496	# Run actual work
497
498	do_test_cases_make_install "$1" "$2" 1 "$3"
499}
500
501# Check parameters to be the names of test
502# collections and run make install for each
503# of them, if specified.
504# arg1 - root directory of aslts
505# arg2 - all the lexem here must be the names of test collections
506# arg3 - either to actually run make install
507do_collections_make_install()
508{
509	local errors=0 dir restore_dir execonly
510
511	restore_dir=$PWD
512	execonly=$4
513
514	for filename in $2
515	do
516		is_collection_name "$filename"
517		if [ $? -ne 0 ]; then
518			do_exit 1 "Not the name of any test collection: $filename"
519		fi
520
521		dir="`get_collections_root_dir "$1"`/$filename"
522		check_dir "$dir"
523
524		if [ $3 != 0 ]; then
525			make_install "$dir" "$execonly"
526			if [ $? -ne 0 ]; then
527				errors=1
528			fi
529		fi
530	done
531
532	cd "$restore_dir"
533
534	return $errors
535}
536
537# Make-install all the test cases of the specified test collections
538# arg1 - root directory of aslts
539# arg2 - all the lexem here must be the names of test collections
540make_install_3()
541{
542	# Check only all parameters are correct
543	# (abort when something is wrong)
544
545	do_collections_make_install "$1" "$2" 0
546
547	# Run actual work
548
549	do_collections_make_install "$1" "$2" 1 "$3"
550}
551
552# Make-install the test case(s).
553#
554# Parameters:
555#
556# 1. Make-install all the provided test cases:
557#
558#    aslts
559#
560# 2. Make-install a list of specified test cases:
561#
562#    test_case_name [test_case_name...]
563#
564# 3. Make-install all the test cases of the specified test collections:
565#
566#    [ALL|all] [functional[complex[exceptions[bdemo[service[mt[Identity2MS]]]]]]]
567#
568# arg1 - root directory of aslts
569# arg2 - number of parameters passed to Do utility
570# arg3 - all parameters passed to Do utility
571run_asl_compiler()
572{
573	local list="$2" execonly=$3
574	local action=100
575
576	# It's better to split this function into a special 'asltscomp'
577	# script. For now, still uses it as an inline function.
578	RESET_SETTINGS
579	INIT_ALL_AVAILABLE_CASES
580	INIT_ALL_AVAILABLE_MODES
581	INIT_SET_OF_TEST_CASES
582	INIT_SET_OF_TEST_MODES
583	INIT_LOG_RESULTS
584	INIT_MEM_STAT
585
586	if [ $list == ASLTS -o $list == aslts ]; then
587		action=1
588	elif [ $list == ALL -o $list == all ]; then
589		list=`echo "$3" | cut -c 7-`
590		action=3
591	else
592		action=2
593	fi
594
595	echo "list of testcases: $list"
596
597	if [ $action == 1 ]; then
598		echo "Make-install all the provided test cases"
599		make_install_1 "$1" "$execonly"
600	elif [ $action == 2 ]; then
601		echo "Make-install a list of specified test cases: $list"
602		make_install_2 "$1" "$list" "$execonly"
603	elif [ $action == 3 ]; then
604		echo "Make-install all the test cases of the specified test collections: $list"
605		make_install_3 "$1" "$list" "$execonly"
606	else
607		do_exit 1 "Bad parameters 2"
608	fi
609}
610
611get_iasl_version()
612{
613	local x version
614
615	if [ ! -f $ASL ]; then
616		do_exit 1 "Bad iASL 1: <$ASL> does not exist"
617	else
618		x=`$ASL -version | grep "Compiler/Disassembler version"`
619		if [ x"$x" == x ]; then
620			version=00000000
621			do_exit 1 "Bad iASL 2: bad signon <$ASL>"
622		else
623			version=`echo "$x" | awk -F" " '{print $5}'`
624			if [ x"$version" == x ]; then
625				do_exit 1 "Bad iASL 3: could not get version <$ASL>"
626			else
627				echo "$version"
628			fi
629		fi
630	fi
631}
632
633get_aslts_bin_line()
634{
635	echo "$1" | awk -F: '{ for (i=1; i<=NF; i++) { print $i}}' |\
636	while [ 1 ]
637	do
638		read line
639		if [ $? -ne 0 ]; then
640			break
641		fi
642		if [[ "$line" == *aslts/bin ]]; then
643			echo "$line"
644		fi
645	done
646}
647
648# ############################## MAIN ###############################
649
650# Init variables of utility
651
652# Available commands
653
654CMD=$1
655NPARAM=$#
656ASLCOMPILE=0
657RUNTESTS=1
658DIFFRESULTS=2
659PRINTTESTCASES=3
660BDEMOSTABS=4
661BDEMOSSUM=5
662CONCBDEMOS=6
663EXECONLY=$3
664
665# Set defaults
666
667RESULTDIR=
668
669# ################################################################## #
670# ATTENTION: don't use yet here any common stuff till the next remark #
671# ################################################################## #
672
673# Only report USAGE
674
675if [ $NPARAM == 0 ]; then
676	usage
677	do_exit 0 ""
678fi
679
680# Determine the working directory and take precautions (last name should be aslts)
681
682if [ ! -d "$ASLTSDIR" ]; then
683	do_exit 1 "Undefined ASLTSDIR variable! Set it to pathname of root directory of aslts test suite."
684fi
685
686x=`basename "$ASLTSDIR"`
687if [ "$x" != aslts ]; then
688	do_exit 1 "The last name in ASLTSDIR should be 'aslts', but it is $x!"
689fi
690
691check_dir "$ASLTSDIR"
692
693# Set up the additional environment
694
695x=`echo $PATH | grep "aslts/bin"`
696if [ "$x" == "" ]; then
697	PATH=$PATH:$ASLTSDIR/bin
698fi
699
700x=`echo $PATH | grep "aslts/bin"`
701if [ "$x" == "" ]; then
702	do_exit 1 "Failed to set up aslts/bin to PATH!"
703fi
704
705# The simple below doesn't work on Cygwin:
706#	BUG_STATE_DIR=$ASLTSDIR/bin/bugstate
707# Basing on grep will not work in abnormal case
708# when there are several "aslts/bin" in PATH, so
709# detailed calculation of line with "aslts/bin":
710x=`get_aslts_bin_line "$PATH"`
711if [ x"$x" == x ]; then
712	do_exit 1 "No aslts/bin in PATH!"
713fi
714
715BUG_STATE_DIR="$x/bugstate"
716PATH=$PATH:$BUG_STATE_DIR
717
718
719# Add the common use stuff
720
721. common
722. settings
723
724# ###################################################### #
725# ATTENTION: can use the common stuff starting from here #
726# ###################################################### #
727
728# Init available tests
729
730RESET_SETTINGS
731INIT_ALL_AVAILABLE_CASES
732INIT_ALL_AVAILABLE_MODES
733
734# Only report available test cases
735
736if [ $CMD == $PRINTTESTCASES ]; then
737	echo_available_test_cases
738	do_exit 0 ""
739fi
740
741# Command execution
742
743if [ $CMD == $ASLCOMPILE ]; then
744
745	# Check access to iASL compiler
746
747	if [ ! -f "$ASL" ]; then
748		do_exit 1 "Undefined ASL variable! Set it to pathname of ASL compiler."
749	fi
750
751	shift 1
752	ENABLED_TMODES=
753	while :
754	do
755		check_mode_id $1
756		if [ $? -eq 1 ]; then
757			break
758		fi
759		ENABLED_TMODES="$1 $ENABLED_TMODES"
760		shift 1
761	done
762	export ENABLED_TMODES
763
764	#NPARAM counts the number of enabled test cases
765	NPARAM=0
766	ENABLED_TCASES=
767	while :
768	do
769		get_collection_opcode $1
770		if [ $? -eq $COLLS_NUM ]; then
771			break
772		fi
773		ENABLED_TCASES="$1 $ENABLED_TCASES"
774		shift 1
775		NPARAM=$(($NPARAM + 1))
776	done
777	export ENABLED_TCASES
778
779	if [ "x$ENABLED_TCASES" == "x" ]; then
780		x=aslts
781		NPARAM=$(($NPARAM + 1))
782	else
783		x="$ENABLED_TCASES"
784	fi
785
786	if [ $NPARAM -le 0 ]; then
787		usage
788		do_exit 1 "Bad parameters 0"
789	elif [ $x == ASLTS -o $x == aslts ]; then
790		if [ $NPARAM != 1 ]; then
791			usage
792			do_exit 1 "Bad parameters 1"
793		fi
794	elif [ $x == ALL -o $x == all ]; then
795		if [ $NPARAM -le 0 ]; then
796			usage
797			do_exit 1 "Bad parameters 2"
798		fi
799	fi
800
801
802	EXECONLY=$1
803	run_asl_compiler "$ASLTSDIR" "$x" "$EXECONLY"
804
805elif [ $CMD == $RUNTESTS ]; then
806
807	# Check access to AcpiExec utility
808
809	if [ ! -f "$acpiexec" ]; then
810		do_exit 1 "Undefined acpiexec variable! Set it to pathname of AcpiExec utility."
811	fi
812
813	# Check access to AcpiBin utility
814
815	if [ ! -f "$acpibin" ]; then
816		do_exit 1 "Undefined acpibin variable! Set it to pathname of AcpiBin utility."
817	fi
818
819	shift 1
820	ASLTSRUN_PARAMS=
821
822	ENABLED_TMODES=
823	while :
824	do
825		check_mode_id $1
826		if [ $? -eq 1 ]; then
827			break
828		fi
829		ENABLED_TMODES="$1 $ENABLED_TMODES"
830		shift 1
831	done
832	export ENABLED_TMODES
833
834	export ENABLED_TCASES="$@"
835
836	asltsrun
837
838elif [ $CMD == $DIFFRESULTS ]; then
839
840	RESULTDIR="$ASLTSDIR/tmp/RESULTS"
841	check_dir "$RESULTDIR"
842	if [ $NPARAM == 1 ]; then
843		do_cmp $NPARAM 0 0 "$RESULTDIR"
844	elif [ $NPARAM == 2 ]; then
845		do_cmp $NPARAM 0 "$2" "$RESULTDIR"
846	elif [ $NPARAM == 3 ]; then
847		do_cmp $NPARAM "$2" "$3" "$RESULTDIR"
848	else
849		bad_param_number $CMD $NPARAM "not more than 3"
850	fi
851
852elif [ $CMD == $BDEMOSSUM ]; then
853
854	if [ $NPARAM == 2 ]; then
855		do_bdemo_sums "$NPARAM" "$2"
856	else
857		bad_param_number $CMD $NPARAM "2"
858	fi
859
860elif [ $CMD == $CONCBDEMOS ]; then
861
862	if [ $NPARAM == 3 ]; then
863		concatenate_bdemo_sums $NPARAM "$2" "$3"
864	else
865		bad_param_number $CMD $NPARAM "3"
866	fi
867
868elif [ $CMD == $BDEMOSTABS ]; then
869
870	if [ $NPARAM == 6 ]; then
871		do_bdemo_table $NPARAM "$2" "$3" "$4" "$5" "$6"
872	else
873		bad_param_number $CMD $NPARAM "6"
874	fi
875
876else
877	do_exit 1 "Bad parameters 3"
878fi
879