Permalink
Please sign in to comment.
Showing
with
295 additions
and 245 deletions.
- +5 −0 CMakeLists.txt
- +9 −20 admin/test/CMakeLists.txt
- +11 −21 benc/serialization/standard/test/CMakeLists.txt
- +36 −0 cmake/modules/RemoteTest.cmake
- +21 −0 cmake/modules/RemoteTestTemplate.bash
- +30 −0 cmake/modules/Test.cmake
- +74 −0 contrib/nodejs/runtest.js
- +8 −20 crypto/test/CMakeLists.txt
- +10 −19 dht/dhtcore/test/CMakeLists.txt
- +11 −19 dht/test/CMakeLists.txt
- +12 −20 interface/test/CMakeLists.txt
- +10 −19 io/test/CMakeLists.txt
- +9 −20 memory/test/CMakeLists.txt
- +7 −19 net/test/CMakeLists.txt
- +8 −19 switch/test/CMakeLists.txt
- +12 −18 test/CMakeLists.txt
- +3 −5 tunnel/test/CMakeLists.txt
- +19 −26 util/test/CMakeLists.txt
@@ -0,0 +1,36 @@ | ||
+# You may redistribute this program and/or modify it under the terms of | ||
+# the GNU General Public License as published by the Free Software Foundation, | ||
+# either version 3 of the License, or (at your option) any later version. | ||
+# | ||
+# This program is distributed in the hope that it will be useful, | ||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
+# GNU General Public License for more details. | ||
+# | ||
+# You should have received a copy of the GNU General Public License | ||
+# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
+if (NOT REMOTE_TEST) | ||
+set(REMOTE_TEST TRUE) | ||
+ | ||
+file(READ ${CMAKE_SOURCE_DIR}/cmake/modules/RemoteTestTemplate.bash template) | ||
+string(REPLACE "__REMOTE_TEST_IP_PORT__" "${REMOTE_TEST_IP_PORT}" FILE_CONTENT "${template}") | ||
+set(template FALSE) | ||
+ | ||
+ | ||
+if (REMOTE_TEST_IP_PORT) | ||
+ function(remoteTest executable) | ||
+ string(REPLACE "__TEST_FILE__" "${CMAKE_CURRENT_BINARY_DIR}/${executable}${CMAKE_EXECUTABLE_SUFFIX}" fileContent "${FILE_CONTENT}") | ||
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${executable}_remote.sh "${fileContent}") | ||
+ execute_process(COMMAND chmod | ||
+ "a+x" ${CMAKE_CURRENT_BINARY_DIR}/${executable}_remote.sh | ||
+ ) | ||
+ add_test(${executable} ${CMAKE_CURRENT_BINARY_DIR}/${executable}_remote.sh) | ||
+ message(" Running test remotely") | ||
+ endFunction() | ||
+else() | ||
+ function(remoteTest executable) | ||
+ message(" REMOTE_TEST_IP_PORT unspecified, skipping test.") | ||
+ endfunction() | ||
+endif() | ||
+ | ||
+endif() |
@@ -0,0 +1,21 @@ | ||
+#!/bin/bash | ||
+# You may redistribute this program and/or modify it under the terms of | ||
+# the GNU General Public License as published by the Free Software Foundation, | ||
+# either version 3 of the License, or (at your option) any later version. | ||
+# | ||
+# This program is distributed in the hope that it will be useful, | ||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
+# GNU General Public License for more details. | ||
+# | ||
+# You should have received a copy of the GNU General Public License | ||
+# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
+let line=0 | ||
+curl --data-binary @__TEST_FILE__ __REMOTE_TEST_IP_PORT__ 2>>/dev/null \ | ||
+| while read x | ||
+do | ||
+ [ "${line}" == "0" ] && echo "$x" | grep '4:codei0e' >/dev/null && exit 1; | ||
+ echo "$x"; | ||
+ let "line = line + 1" | ||
+done || exit 0; | ||
+exit 1; |
@@ -0,0 +1,30 @@ | ||
+# You may redistribute this program and/or modify it under the terms of | ||
+# the GNU General Public License as published by the Free Software Foundation, | ||
+# either version 3 of the License, or (at your option) any later version. | ||
+# | ||
+# This program is distributed in the hope that it will be useful, | ||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
+# GNU General Public License for more details. | ||
+# | ||
+# You should have received a copy of the GNU General Public License | ||
+# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
+include(${CMAKE_SOURCE_DIR}/cmake/modules/RemoteTest.cmake) | ||
+ | ||
+string(REGEX REPLACE "^.*/" "" main_dir_name ${CMAKE_SOURCE_DIR}) | ||
+string(REPLACE ${CMAKE_SOURCE_DIR} ${main_dir_name} this_dir ${CMAKE_CURRENT_SOURCE_DIR}) | ||
+message("-- Tests to run for " ${this_dir}) | ||
+add_definitions(-g -DTEST) | ||
+ | ||
+foreach(test_source ${Test_FILES}) | ||
+ string(REPLACE "test.c" "test" test_bin ${test_source}) | ||
+ message(" " ${test_source}) | ||
+ add_executable(${test_bin} ${test_source}) | ||
+ target_link_libraries(${test_bin} ${Test_LIBRARIES}) | ||
+ if (CMAKE_CROSSCOMPILING) | ||
+ remoteTest(${test_bin}) | ||
+ else() | ||
+ add_test(${test_bin} ${test_bin}) | ||
+ endif() | ||
+endforeach() | ||
+message("") |
@@ -0,0 +1,74 @@ | ||
+/* | ||
+ * You may redistribute this program and/or modify it under the terms of | ||
+ * the GNU General Public License as published by the Free Software Foundation, | ||
+ * either version 3 of the License, or (at your option) any later version. | ||
+ * | ||
+ * This program is distributed in the hope that it will be useful, | ||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
+ * GNU General Public License for more details. | ||
+ * | ||
+ * You should have received a copy of the GNU General Public License | ||
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
+ */ | ||
+ | ||
+// THIS SCRIPT IS ESSENTIALLY A BACKDOOR | ||
+// DON'T RUN IT ON ANYTHING YOU CARE ABOUT | ||
+ | ||
+// This script binds port 8083 and allows remote testing on the system. | ||
+ | ||
+var spawn = require('child_process').spawn; | ||
+var http = require("http"); | ||
+var qs = require('querystring'); | ||
+var os = require("os"); | ||
+var fs = require("fs"); | ||
+ | ||
+var PATH = "/home/user/"; | ||
+ | ||
+var spawnProc = function(file, callback, timeoutMilliseconds) { | ||
+ var child = spawn(file); | ||
+ var out = '', err = ''; | ||
+ var to = setTimeout(function() { | ||
+ child.kill('SIGKILL'); | ||
+ err += "TIMEOUT\n"; | ||
+ callback(1000, out, err); | ||
+ }, timeoutMilliseconds); | ||
+ child.stdout.on('data', function (data) { out += data; }); | ||
+ child.stderr.on('data', function (data) { err += data; }); | ||
+ child.on('exit', function (code) { | ||
+ callback(code, out, err); | ||
+ }); | ||
+}; | ||
+ | ||
+var send = function(response, content) { | ||
+ response.writeHeader(200, {"Content-Type": "text/plain"}); | ||
+ response.write(content); | ||
+ response.end(); | ||
+}; | ||
+ | ||
+var runTest = function(fileName, response, timeoutMilliseconds) { | ||
+ fs.chmodSync(fileName, '755'); | ||
+ spawnProc(fileName, function(code, out, err) { | ||
+ send(response, "d4:codei" + code + "e6:stdout" + out.length + ":" + out + "6:stderr" + | ||
+ err.length + ":" + err + "e"); | ||
+ fs.unlink(fileName); | ||
+ }, timeoutMilliseconds); | ||
+}; | ||
+ | ||
+http.createServer(function(request, response) { | ||
+ if (request.method == 'POST') { | ||
+ var fileName = PATH + (Math.random() * 0x100000000) + ".exe"; | ||
+ var fsStream = fs.createWriteStream(fileName); | ||
+ request.on("data", function(chunk) { | ||
+ fsStream.write(chunk); | ||
+ }); | ||
+ request.on("end", function() { | ||
+ fsStream.on("close", function() { | ||
+ runTest(fileName, response, 10000); | ||
+ }); | ||
+ fsStream.end(); | ||
+ }); | ||
+ } else { | ||
+ send(response, "ERROR\nNot a POST"); | ||
+ } | ||
+}).listen(8083); |

Oops, something went wrong.
0 comments on commit
a45f982