global srcdir subdir

catch "glob -nocomplain $srcdir/$subdir/../../tests/*.exp" srcfiles
verbose "srcfiles are $srcfiles"

set prefix ""
foreach x $srcfiles {
    regsub "\\.exp$" $x "" prefix
    set bname [file tail $prefix]
    set args ""
    if [file exists $srcdir/$subdir/${bname}.arg] {
	set id [open "$srcdir/$subdir/${bname}.arg" r];
	set args [read -nonewline $id];
	close $id;
    }
    if [file exists $srcdir/$subdir/${bname}.xpo] {
	set resfile "$srcdir/$subdir/${bname}.xpo"
	set options "regexp_match"
    } else {
	set resfile "${prefix}.exp"
	set options ""
    }

    if [file exists ${prefix}.inp] {
	set inpfile ${prefix}.inp
    } else {
	set inpfile ""
    }

    verbose "inpfile is $inpfile"

    test_libstdc++ $options "${prefix}.cc" "" $inpfile $resfile $args
    test_libstdc++ $options "${prefix}.cc" "-O" $inpfile $resfile $args
}
