-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test files regarding to dump and run spidermonkey on android
Signed-off-by: Seonghyun Kim <[email protected]>
- Loading branch information
1 parent
0285779
commit 9581488
Showing
5 changed files
with
254 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <cstdlib> | ||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
#include <atomic> | ||
#include <vector> | ||
#include <thread> | ||
#include <algorithm> | ||
|
||
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<TestData> g_testDatas; | ||
std::atomic<int> g_index; | ||
std::atomic<int> g_passCount; | ||
std::atomic<int> 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 <path>"); | ||
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<std::pair<int, int>> threadData; | ||
std::vector<std::thread> 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<int, int> 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; | ||
} |
Oops, something went wrong.