diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-08-08 10:24:25 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-09 15:07:40 +0200 |
commit | c07a9fe847f536d1090c6876ed516baa8607b786 (patch) | |
tree | b93b26269148f97493edfda466751e260924435d /tests/auto/shared/util.h | |
parent | 973f54fc75e8dd3ddc132942be55f9d5fabde19c (diff) | |
download | qtscript-c07a9fe847f536d1090c6876ed516baa8607b786.tar.gz |
Move test helper function to separate header file
Makes it possible to use the collectGarbage_helper function in other
autotests too (e.g., tst_qscriptextqobject).
Change-Id: I4fefa36aba13ebf9f931f0e2b90d7ddbc0036a6c
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/shared/util.h')
-rw-r--r-- | tests/auto/shared/util.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/shared/util.h b/tests/auto/shared/util.h new file mode 100644 index 0000000..5ca322d --- /dev/null +++ b/tests/auto/shared/util.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.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 the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSCRIPTTESTUTILS_H +#define QSCRIPTTESTUTILS_H + +// The JavaScriptCore GC marks the C stack. To try to ensure that there is +// no JSObject* left in stack memory by the compiler, we call this function +// to zap some bytes of memory before calling collectGarbage(). +static void zapSomeStack() +{ + char buf[4096]; + memset(buf, 0, sizeof(buf)); +} + +static void collectGarbage_helper(QScriptEngine &eng) +{ + zapSomeStack(); + eng.collectGarbage(); +} + +#endif |