diff --git a/.github/workflows/es-actions.yml b/.github/workflows/es-actions.yml index e13f6b8ec..bc86aca2d 100644 --- a/.github/workflows/es-actions.yml +++ b/.github/workflows/es-actions.yml @@ -210,7 +210,7 @@ jobs: dpkg -X libicu-dev_70.1-2ubuntu1_i386.deb $GITHUB_WORKSPACE/icu32 - name: Build x86 env: - BUILD_OPTIONS: -DESCARGOT_HOST=linux -DESCARGOT_ARCH=x86 -DESCARGOT_MODE=release -DESCARGOT_LIBICU_SUPPORT_WITH_DLOPEN=OFF -DESCARGOT_OUTPUT=shell_test -GNinja + BUILD_OPTIONS: -DESCARGOT_HOST=linux -DESCARGOT_ARCH=x86 -DESCARGOT_MODE=release -DESCARGOT_THREADING=ON -DESCARGOT_LIBICU_SUPPORT_WITH_DLOPEN=OFF -DESCARGOT_OUTPUT=shell_test -GNinja run: | export CXXFLAGS="-I$GITHUB_WORKSPACE/icu32/usr/include" export LDFLAGS="-L$GITHUB_WORKSPACE/icu32/usr/lib/i386-linux-gnu -Wl,-rpath=$GITHUB_WORKSPACE/icu32/usr/lib/i386-linux-gnu" diff --git a/tools/run-tests.py b/tools/run-tests.py index 3bd245ab2..e391f15be 100755 --- a/tools/run-tests.py +++ b/tools/run-tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2018-present Samsung Electronics Co., Ltd. # @@ -281,13 +281,12 @@ def run_test262_dump(engine, arch): @runner('test262-dump-run', default=False) def run_test262_dump_run(engine, arch): - run(['g++', "./tools/test/test262/test-data-runner.cpp", "-o", "./test/test262/test-data-runner", "-g3", "-std=c++11", "-lpthread"], + run(['g++', "./tools/test/test-data-runner/test-data-runner.cpp", "-o", "./tools/test/test-data-runner/test-data-runner", "-g3", "-std=c++11", "-lpthread"], cwd=PROJECT_SOURCE_DIR, stdout=PIPE) - import multiprocessing - cc = multiprocessing.cpu_count() - stdout = run(['./test-data-runner', engine, str(cc), "1"], + stdout = run([PROJECT_SOURCE_DIR + '/tools/test/test-data-runner/test-data-runner', "--shell", engine, + "--test", "test262", "--test-data", join(PROJECT_SOURCE_DIR, 'test', 'test262', 'test262_data')], cwd=join(PROJECT_SOURCE_DIR, 'test', 'test262'), stdout=PIPE) @@ -328,6 +327,50 @@ def run_spidermonkey(engine, arch): print(diffline) raise Exception('failure files differ') +@runner('spidermonkey-dump', default=True) +def run_spidermonkey_dump(engine, arch): + SPIDERMONKEY_OVERRIDE_DIR = join(PROJECT_SOURCE_DIR, 'tools', 'test', 'spidermonkey') + SPIDERMONKEY_DIR = join(PROJECT_SOURCE_DIR, 'test', 'vendortest', 'SpiderMonkey') + + log_path = join(SPIDERMONKEY_OVERRIDE_DIR, '%s.log.txt' % arch) + if not os.path.exists(log_path): + run_spidermonkey(engine, arch) + + log = sorted(readfile(log_path)) + for idx, x in enumerate(log): + text = log[idx] + text = text.replace(engine + " ", "") + text = text.replace(PROJECT_SOURCE_DIR + "/", "") + text = text.replace("-f ", "") + text = text.replace("\n", "") + log[idx] = text + + with open(join(SPIDERMONKEY_OVERRIDE_DIR, '%s.data.txt' % arch), "w") as output: + for idx, x in enumerate(log): + output.write(log[idx] + "\n") + if log[idx].endswith("-n.js"): + output.write("3\n") + else: + output.write("0\n") + +@runner('spidermonkey-dump-run', default=True) +def run_spidermonkey_dump_run(engine, arch): + run(['g++', "./tools/test/test-data-runner/test-data-runner.cpp", "-o", "./tools/test/test-data-runner/test-data-runner", "-g3", "-std=c++11", "-lpthread"], + cwd=PROJECT_SOURCE_DIR, + stdout=PIPE) + + SPIDERMONKEY_OVERRIDE_DIR = join(PROJECT_SOURCE_DIR, 'tools', 'test', 'spidermonkey') + stdout = run(['./tools/test/test-data-runner/test-data-runner', '--test-data', join(SPIDERMONKEY_OVERRIDE_DIR, '%s.data.txt' % arch), + "--shell", engine, "--env", "LOCALE=en_US"], + cwd=PROJECT_SOURCE_DIR, + stdout=PIPE) + + stdout = stdout.decode("utf-8") + if stdout.find("Passed") < 0: + raise Exception('failed') + print(stdout) + print('spidermonkey-dump-passed') + @runner('jsc-stress', default=True) def run_jsc_stress(engine, arch): diff --git a/tools/test/spidermonkey/excludelist.txt b/tools/test/spidermonkey/excludelist.txt index 0e7504ea9..5335cc982 100644 --- a/tools/test/spidermonkey/excludelist.txt +++ b/tools/test/spidermonkey/excludelist.txt @@ -68,6 +68,9 @@ non262/TypedArray/sort-negative-nan.js non262/Intl/PluralRules/call.js non262/Intl/Collator/toStringTag.js +# needs spidermonkey only test functions +non262/extensions/sharedtypedarray.js + # TODO non262/Array/unscopables.js non262/arrow-functions/arrow-not-as-end-of-statement.js diff --git a/tools/test/test-data-runner/test-data-runner.cpp b/tools/test/test-data-runner/test-data-runner.cpp new file mode 100644 index 000000000..9fc35ff57 --- /dev/null +++ b/tools/test/test-data-runner/test-data-runner.cpp @@ -0,0 +1,202 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct TestData { + std::string canBlockIsFalse; + std::string isModule; + std::string fullPath; + std::string driverFile; + std::string testFile; + std::string code; +}; + +enum TestKind { + General, + Test262 +}; + +std::string g_inputPath; +std::vector g_testDatas; +std::atomic g_index; +std::atomic g_passCount; +std::atomic g_skipCount; +std::string g_skipPattern; +std::string g_env; +TestKind g_testKind; + +int main(int argc, char* argv[]) +{ + std::string shellPath = "escargot"; + int numThread = std::thread::hardware_concurrency(); + g_inputPath = ""; + g_testKind = TestKind::General; + + for (int i = 1; i < argc; i++) { + if (strlen(argv[i]) >= 2 && argv[i][0] == '-') { // parse command line option + if (argv[i][1] == '-') { // `--option` case + if (strcmp(argv[i], "--shell") == 0) { + if (argc > i) { + shellPath = argv[++i]; + continue; + } + } else if (strcmp(argv[i], "--test-data") == 0) { + if (argc > i) { + g_inputPath = argv[++i]; + continue; + } + } else if (strcmp(argv[i], "--test") == 0) { + if (argc > i) { + std::string kind = argv[++i]; + if (kind == "test262") { + g_testKind = TestKind::Test262; + } + continue; + } + } else if (strcmp(argv[i], "--threads") == 0) { + if (argc > i) { + numThread = std::stoi(argv[++i]); + continue; + } + }else if (strcmp(argv[i], "--env") == 0) { + if (argc > i) { + g_env = argv[++i]; + continue; + } + } + } else { // `-option` case + } + fprintf(stderr, "Cannot recognize option `%s`", argv[i]); + continue; + } + } + + if (g_inputPath == "") { + puts("please specifiy test data option with --test-data "); + return -1; + } + + if (g_testKind == TestKind::Test262) { + g_env = "TZ=US/Pacific " + g_env; + } + + int caseNum = 0; + if (g_testKind == TestKind::Test262) { + std::ifstream input(g_inputPath + "/data"); + + std::string canBlockIsFalse; + std::string isModule; + std::string fullPath; + std::string driverFile; + std::string testFile; + std::string code; + + while (std::getline(input, canBlockIsFalse)) { + std::getline(input, isModule); + std::getline(input, fullPath); + std::getline(input, driverFile); + std::getline(input, testFile); + std::getline(input, code); + + g_testDatas.push_back({ + canBlockIsFalse, + isModule, + fullPath, + driverFile, + testFile, + code + }); + caseNum++; + } + } else { + std::ifstream input(g_inputPath); + + std::string commandLine; + std::string code; + while (std::getline(input, commandLine)) { + std::getline(input, code); + g_testDatas.push_back({ + "", + "", + "", + "", + commandLine, + code + }); + caseNum++; + } + } + + printf("Total case number %d\n", caseNum); + + std::vector> threadData; + std::vector threads; + int threadSize = caseNum / numThread; + + int d = 0; + for (int i = 0; i < numThread; i ++) { + threadData.push_back(std::make_pair( + d, d + threadSize + )); + d += threadSize; + } + + threadData.back().second = caseNum; + + for (int i = 0; i < numThread; i ++) { + threads.push_back(std::thread([](std::pair data, std::string shellPath) { + for (int j = data.first; j < data.second; j ++) { + std::string commandline = g_env + " " + shellPath; + const auto& data = g_testDatas[j]; + + if (g_skipPattern.size() && data.fullPath.find(g_skipPattern) != std::string::npos) { + g_skipCount++; + printf("SKIP [%d] %s\n", g_index++, data.fullPath.data()); + continue; + } + + commandline += " " + data.driverFile; + if (data.canBlockIsFalse.size()) { + commandline += " --canblock-is-false"; + } + + if (data.isModule.size()) { + commandline += " --module"; + commandline += " --filename-as=" + g_inputPath + data.fullPath; + } + + commandline += " " + data.testFile; + + int result = WEXITSTATUS(std::system(commandline.data())); + + if (data.code == std::to_string(result)) { + g_passCount++; + printf("Success [%d] %s => %d\n", g_index++, data.fullPath.data(), result); + } else { + printf("Fail [%d] %s,%s\n", g_index++, data.fullPath.data(), commandline.data()); + } + } + }, threadData[i], shellPath)); + } + + for (int i = 0; i < numThread; i ++) { + threads[i].join(); + } + + printf("Result -> %d/%d(Skipped %d) : ", ((int)g_passCount + (int)g_skipCount), caseNum, (int)g_skipCount); + if ((g_passCount + g_skipCount) == caseNum) { + puts("Passed"); + } else { + puts("Failed"); + } + + return 0; +} diff --git a/tools/test/test262/test-data-runner.cpp b/tools/test/test262/test-data-runner.cpp deleted file mode 100644 index 891695b0e..000000000 --- a/tools/test/test262/test-data-runner.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct TestData { - std::string canBlockIsFalse; - std::string isModule; - std::string fullPath; - std::string driverFile; - std::string testFile; - std::string code; -}; - -std::string g_inputPath; -std::vector g_testDatas; -std::atomic g_index; -std::atomic g_passCount; -std::atomic g_skipCount; -std::string g_skipPattern; - -int main(int argc, char* argv[]) -{ - std::string shellPath = "escargot"; - if (argc >= 2) { - shellPath = argv[1]; - } - int numThread = std::thread::hardware_concurrency(); - if (argc >= 3) { - numThread = std::stoi(argv[2]); - } - if (argc >= 4) { - g_skipPattern = argv[3]; - } - - g_inputPath = "test262_data"; - std::ifstream input(g_inputPath + "/data"); - - std::string canBlockIsFalse; - std::string isModule; - std::string fullPath; - std::string driverFile; - std::string testFile; - std::string code; - - int caseNum = 0; - while (std::getline(input, canBlockIsFalse)) { - std::getline(input, isModule); - std::getline(input, fullPath); - std::getline(input, driverFile); - std::getline(input, testFile); - std::getline(input, code); - - g_testDatas.push_back({ - canBlockIsFalse, - isModule, - fullPath, - driverFile, - testFile, - code - }); - caseNum++; - } - - printf("Total case number %d\n", caseNum); - - std::vector> threadData; - std::vector threads; - int threadSize = caseNum / numThread; - - int d = 0; - for (int i = 0; i < numThread; i ++) { - threadData.push_back(std::make_pair( - d, d + threadSize - )); - d += threadSize; - } - - threadData.back().second = caseNum; - - for (int i = 0; i < numThread; i ++) { - printf("%d -> %d\n", threadData[i].first, threadData[i].second); - threads.push_back(std::thread([](std::pair data, std::string shellPath) { - for (int j = data.first; j < data.second; j ++) { - std::string commandline = "TZ=US/Pacific " + shellPath; - const auto& data = g_testDatas[j]; - - if (g_skipPattern.size() && data.fullPath.find(g_skipPattern) != std::string::npos) { - g_skipCount++; - printf("SKIP [%d] %s\n", g_index++, data.fullPath.data()); - continue; - } - - commandline += " " + data.driverFile; - if (data.canBlockIsFalse.size()) { - commandline += " --canblock-is-false"; - } - - if (data.isModule.size()) { - commandline += " --module"; - commandline += " --filename-as=" + g_inputPath + data.fullPath; - } - - commandline += " " + data.testFile; - - int result = WEXITSTATUS(std::system(commandline.data())); - - if (data.code == std::to_string(result)) { - g_passCount++; - printf("Success [%d] %s => %d\n", g_index++, data.fullPath.data(), result); - } else { - printf("Fail [%d] %s,%s\n", g_index++, data.fullPath.data(), commandline.data()); - } - } - }, threadData[i], shellPath)); - } - - for (int i = 0; i < numThread; i ++) { - threads[i].join(); - } - - printf("Result -> %d/%d(Skipped %d) : ", ((int)g_passCount + (int)g_skipCount), caseNum, (int)g_skipCount); - if ((g_passCount + g_skipCount) == caseNum) { - puts("Passed"); - } else { - puts("Failed"); - } - - return 0; -}