#!/bin/sh
# Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
#
# This file is part of the unit-tests of the Qt Toolkit.
#
# This file may be used under the terms of the GNU General Public
# License version 2.0 as published by the Free Software Foundation
# and appearing in the file LICENSE.GPL included in the packaging of
# this file.  Please review the following information to ensure GNU
# General Public Licensing requirements will be met:
# http://trolltech.com/products/qt/licenses/licensing/opensource/
#
# If you are unsure which license is appropriate for your use, please
# review the following information:
# http://trolltech.com/products/qt/licenses/licensing/licensingoverview
# or contact the sales department at sales@trolltech.com.
#
# Trolltech reserves all rights not expressly granted herein.
#
# Trolltech ASA (c) 2007
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

# This script executes each of the Qt tests and concatenates the results
# in one file called "journal.qt"

rm -f ./journal.qt

testHome=$PWD

for testDir in tests/q*; do

    cd $testDir

    basetestname=`basename $testDir`
    if [ ! -x "$basetestname" ]; then
        echo "Unable to find test binary $basetestname in $testDir"
        cd $testHome
    else
        echo $basetestname
        ./$basetestname -v2
 
        cd $testHome

        journal=$testDir/journal.tst_$basetestname
        if [ ! -e "$journal" ]; then
            echo "Unable to find journal file $journal"
        else
            cat $journal >>./journal.qt
            rm $journal
        fi
    fi
done

# now post-process the journal so dtk-manager is happier with it
cp journal.qt journal.qt.org
# drop the extra "0" and "5" records
awk -f fix-qt-journal.awk journal.qt.org > journal.qt
# these initial initTestCase entries with 0's give dtk manager fits
sed -i 's?400|1 0 1?400|1 1 1?g;s?200|1 0?200|1 1?g;s?220|1 0 0?220|1 1 0?g;s?410|1 0 1?410|1 1 1?g' journal.qt
rm -f journal.qt.org

