diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-06-10 11:53:56 +1000 |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-06-10 11:53:56 +1000 |
commit | f02280f464c8bd976221d723a6acac20c971ddd7 (patch) | |
tree | f68a575a09c21c8627049c6629aa446352101b53 | |
parent | df4add062fc7368d9fee7c697405c43422b0af27 (diff) |
Allow v8 autotest to run without Qt
-rw-r--r-- | tests/auto/declarative/v8/Makefile.nonqt | 11 | ||||
-rw-r--r-- | tests/auto/declarative/v8/README.txt | 13 | ||||
-rw-r--r-- | tests/auto/declarative/v8/tst_v8.cpp | 29 | ||||
-rw-r--r-- | tests/auto/declarative/v8/v8.pro | 3 | ||||
-rw-r--r-- | tests/auto/declarative/v8/v8main.cpp | 16 | ||||
-rw-r--r-- | tests/auto/declarative/v8/v8test.cpp | 82 | ||||
-rw-r--r-- | tests/auto/declarative/v8/v8test.h | 50 |
7 files changed, 177 insertions, 27 deletions
diff --git a/tests/auto/declarative/v8/Makefile.nonqt b/tests/auto/declarative/v8/Makefile.nonqt new file mode 100644 index 0000000000..20be72ea9b --- /dev/null +++ b/tests/auto/declarative/v8/Makefile.nonqt @@ -0,0 +1,11 @@ +release-m32: + g++ -o v8test_release_m32 -m32 -O2 v8main.cpp v8test.cpp -L../../../../src/3rdparty/v8/ -lv8 + +debug-m32: + g++ -o v8test_debug_m32 -m32 -g v8main.cpp v8test.cpp -L../../../../src/3rdparty/v8/ -lv8_g + +release: + g++ -o v8test_release -O2 v8main.cpp v8test.cpp -L../../../../src/3rdparty/v8/ -lv8 + +debug: + g++ -o v8test_debug -g v8main.cpp v8test.cpp -L../../../../src/3rdparty/v8/ -lv8_g diff --git a/tests/auto/declarative/v8/README.txt b/tests/auto/declarative/v8/README.txt new file mode 100644 index 0000000000..a5df6201be --- /dev/null +++ b/tests/auto/declarative/v8/README.txt @@ -0,0 +1,13 @@ +The v8 tests are actually implemented in v8test.[h|cpp]. There are also QtTest +(tst_v8.cpp) and non-Qt (v8main.cpp) stubs provided to run these tests. This +is done to allow the tests to be run both in the Qt CI system, and manually +without a build of Qt. The latter is necessary to run them against more exotic +build of V8, like the ARM simulator. + +To build the non-Qt version of the tests, first build a debug or release V8 +library under src/3rdparty/v8 using scons, and then use the Makefile.nonqt +makefile selecting one of the following targets: + release: Build the tests with -O2 and link against libv8 + debug: Build the tests with -g and link against libv8_g + release-m32: Build the tests with -O2 -m32 and link against libv8 + debug-m32: Build the tests with -g -m32 and link against libv8_g diff --git a/tests/auto/declarative/v8/tst_v8.cpp b/tests/auto/declarative/v8/tst_v8.cpp index 740bd8952d..4749da02f0 100644 --- a/tests/auto/declarative/v8/tst_v8.cpp +++ b/tests/auto/declarative/v8/tst_v8.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ #include <qtest.h> -#include "../../../../src/3rdparty/v8/include/v8.h" +#include "v8test.h" using namespace v8; @@ -51,37 +51,14 @@ public: private slots: void initTestCase() {} - void cleanupTestCase(); + void cleanupTestCase() {} void eval(); - -private: - Persistent<Context> context; }; void tst_v8::eval() { - HandleScope handle_scope; - context = Context::New(); - Context::Scope context_scope(context); - - Local<Object> qmlglobal = Object::New(); - qmlglobal->Set(String::New("a"), v8::Integer::New(1922)); - - Local<Script> script = Script::Compile(String::New("eval(\"a\")"), NULL, NULL, - Handle<String>(), Script::QmlMode); - - TryCatch tc; - Local<Value> result = script->Run(qmlglobal); - - QVERIFY(!tc.HasCaught()); - QCOMPARE(result->Int32Value(), 1922); -} - -void tst_v8::cleanupTestCase() -{ - context.Dispose(); - context = Persistent<Context>(); + QVERIFY(v8test_eval()); } int main(int argc, char *argv[]) diff --git a/tests/auto/declarative/v8/v8.pro b/tests/auto/declarative/v8/v8.pro index 0fc27d80b4..1030d174b6 100644 --- a/tests/auto/declarative/v8/v8.pro +++ b/tests/auto/declarative/v8/v8.pro @@ -1,7 +1,8 @@ load(qttest_p4) macx:CONFIG -= app_bundle -SOURCES += tst_v8.cpp +SOURCES += tst_v8.cpp v8test.cpp +HEADERS += v8test.h CONFIG += parallel_test diff --git a/tests/auto/declarative/v8/v8main.cpp b/tests/auto/declarative/v8/v8main.cpp new file mode 100644 index 0000000000..bf37e2d3a5 --- /dev/null +++ b/tests/auto/declarative/v8/v8main.cpp @@ -0,0 +1,16 @@ +#include "v8test.h" +#include <stdio.h> + +#define RUN_TEST(testname) { \ + if (!v8test_ ## testname()) \ + printf ("Test %s FAILED\n", # testname); \ +} + +int main(int argc, char *argv[]) +{ + v8::V8::SetFlagsFromCommandLine(&argc, argv, true); + + RUN_TEST(eval); + + return -1; +} diff --git a/tests/auto/declarative/v8/v8test.cpp b/tests/auto/declarative/v8/v8test.cpp new file mode 100644 index 0000000000..9b80b08550 --- /dev/null +++ b/tests/auto/declarative/v8/v8test.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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$ +** +****************************************************************************/ + +#include "v8test.h" + +using namespace v8; + +#define BEGINTEST() bool _testPassed = true; +#define ENDTEST() return _testPassed; + +#define VERIFY(expr) { \ + if (!(expr)) { \ + _testPassed = false; \ + goto cleanup; \ + } \ +} + + +bool v8test_eval() +{ + BEGINTEST(); + + HandleScope handle_scope; + v8::Persistent<v8::Context> context = Context::New(); + Context::Scope context_scope(context); + + Local<Object> qmlglobal = Object::New(); + qmlglobal->Set(String::New("a"), v8::Integer::New(1922)); + + Local<Script> script = Script::Compile(String::New("eval(\"a\")"), NULL, NULL, + Handle<String>(), Script::QmlMode); + + TryCatch tc; + Local<Value> result = script->Run(qmlglobal); + + VERIFY(!tc.HasCaught()); + VERIFY(result->Int32Value() == 1922); + +cleanup: + context.Dispose(); + + ENDTEST(); +} + diff --git a/tests/auto/declarative/v8/v8test.h b/tests/auto/declarative/v8/v8test.h new file mode 100644 index 0000000000..f8878467ed --- /dev/null +++ b/tests/auto/declarative/v8/v8test.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 V8TEST_H +#define V8TEST_H + +#include "../../../../src/3rdparty/v8/include/v8.h" + +bool v8test_eval(); + +#endif // V8TEST_H + |