Permalink
Browse files

Added remote testing infrastructure.

  • Loading branch information...
Caleb James DeLisle
Caleb James DeLisle committed Nov 27, 2012
1 parent 65e83fa commit a45f9827b448c7a8de80855d59609c7c9acc39d9
View
@@ -35,6 +35,11 @@ if(WIN32)
# BufferAllocator.c:1:0: error: -fPIC ignored for target (all code is position independent)
set(WITH_PIE OFF CACHE INTERNAL "" FORCE)
endif()
+if(CMAKE_CROSSCOMPILING)
+ if (NOT "$ENV{REMOTE_TEST_IP_PORT}" STREQUAL "")
+ set(REMOTE_TEST_IP_PORT "$ENV{REMOTE_TEST_IP_PORT}")
+ endif()
+endif()
if(CMAKE_SYSTEM_NAME STREQUAL SunOS)
set(ILLUMOS TRUE)
View
@@ -9,23 +9,12 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-cmake_minimum_required(VERSION 2.4)
-
-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)
-
-
-# Anything in this dir which ends with "test.c" is considered a test.
-file(GLOB tests "*test.c")
-foreach(test_source_fullpath ${tests})
- string(REGEX REPLACE "^.*/" "" test_source ${test_source_fullpath})
- string(REPLACE "test.c" "test" test_bin ${test_source})
- message(" " ${test_source})
- add_executable(${test_bin} ${test_source})
- target_link_libraries(${test_bin} cjdns-admin cjdns-admin-client cjdadmintest)
- add_test(${test_bin} ${test_bin})
-endforeach()
-# Add an empty line after tests.
-message("")
+set(Test_FILES
+ Admin_test.c
+)
+set(Test_LIBRARIES
+ cjdns-admin
+ cjdns-admin-client
+ cjdadmintest
+)
+include(${CMAKE_SOURCE_DIR}/cmake/modules/Test.cmake)
@@ -9,24 +9,14 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-cmake_minimum_required(VERSION 2.4)
-
-include_directories(${CMAKE_SOURCE_DIR})
-
-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)
-
-# Anything in this dir which ends with "test.c" is considered a test.
-file(GLOB tests "*test.c")
-foreach(test_source_fullpath ${tests})
- string(REGEX REPLACE "^.*/" "" test_source ${test_source_fullpath})
- string(REPLACE "test.c" "test" test_bin ${test_source})
- message(" " ${test_source})
- add_executable(${test_bin} ${test_source})
- target_link_libraries(${test_bin} cjdbenc cjdbenc_StandardBencSerializer cjdio cjdmemory)
- add_test(${test_bin} ${test_bin})
-endforeach()
-# Add an empty line after tests.
-message("")
+set(Test_FILES
+ benc_serializeInteger_test.c
+ benc_serializeList_test.c
+)
+set(Test_LIBRARIES
+ cjdbenc
+ cjdbenc_StandardBencSerializer
+ cjdio
+ cjdmemory
+)
+include(${CMAKE_SOURCE_DIR}/cmake/modules/Test.cmake)
@@ -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;
View
@@ -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("")
View
@@ -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);
View
@@ -9,33 +9,21 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-cmake_minimum_required(VERSION 2.4)
-
-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})
-remove_definitions(-Werror)
-add_definitions(-DTEST)
#allow us to test internal CryptoAuth.c functions.
add_library(exports Exports.c)
target_link_libraries(exports crypto util)
-# Anything in this dir which ends with "test.c" is considered a test.
-file(GLOB tests "*test.c")
-foreach(test_source_fullpath ${tests})
- string(REGEX REPLACE "^.*/" "" test_source ${test_source_fullpath})
- string(REPLACE "test.c" "test" test_bin ${test_source})
- message(" " ${test_source})
- add_executable(${test_bin} ${test_source})
- target_link_libraries(${test_bin}
+set(Test_FILES
+ CryptoAuth_test.c
+ CryptoAuth_unit_test.c
+ ReplayProtector_test.c
+)
+set(Test_LIBRARIES
crypto
util
exports
cjdns-crypto-random
cjdns-util-events-libevent
- )
- add_test(${test_bin} ${test_bin})
-endforeach()
-# Add an empty line after tests.
-message("")
+)
+include(${CMAKE_SOURCE_DIR}/cmake/modules/Test.cmake)
@@ -9,22 +9,13 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-cmake_minimum_required(VERSION 2.4)
-
-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)
-
-# Anything in this dir which ends with "test.c" is considered a test.
-file(GLOB tests "*test.c")
-foreach(test_source_fullpath ${tests})
- string(REGEX REPLACE "^.*/" "" test_source ${test_source_fullpath})
- string(REPLACE "test.c" "test" test_bin ${test_source})
- message(" " ${test_source})
- add_executable(${test_bin} ${test_source})
- target_link_libraries(${test_bin} dht dhtcore cjdmemory ${LIBEVENT2_LIBRARIES})
- add_test(${test_bin} ${test_bin})
-endforeach()
-# Add an empty line after tests.
-message("")
+set(Test_FILES
+ SearchStore_test.c
+)
+set(Test_LIBRARIES
+ dht
+ dhtcore
+ cjdmemory
+ ${LIBEVENT2_LIBRARIES}
+)
+include(${CMAKE_SOURCE_DIR}/cmake/modules/Test.cmake)
View
@@ -9,22 +9,14 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-cmake_minimum_required(VERSION 2.4)
-
-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)
-
-# Anything in this dir which ends with "test.c" is considered a test.
-file(GLOB tests "*test.c")
-foreach(test_source_fullpath ${tests})
- string(REGEX REPLACE "^.*/" "" test_source ${test_source_fullpath})
- string(REPLACE "test.c" "test" test_bin ${test_source})
- message(" " ${test_source})
- add_executable(${test_bin} ${test_source})
- target_link_libraries(${test_bin} dht cjdmemory ${LIBEVENT2_LIBRARIES})
- add_test(${test_bin} ${test_bin})
-endforeach()
-# Add an empty line after tests.
-message("")
+set(Test_FILES
+ address_mapper_lru_test.c
+ DHTModules_handleIncoming_test.c
+ DHTModules_handleOutgoing_test.c
+)
+set(Test_LIBRARIES
+ dht
+ cjdmemory
+ ${LIBEVENT2_LIBRARIES}
+)
+include(${CMAKE_SOURCE_DIR}/cmake/modules/Test.cmake)
@@ -9,23 +9,15 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-cmake_minimum_required(VERSION 2.4)
-
-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)
-
-
-# Anything in this dir which ends with "test.c" is considered a test.
-file(GLOB tests "*test.c")
-foreach(test_source_fullpath ${tests})
- string(REGEX REPLACE "^.*/" "" test_source ${test_source_fullpath})
- string(REPLACE "test.c" "test" test_bin ${test_source})
- message(" " ${test_source})
- add_executable(${test_bin} ${test_source})
- target_link_libraries(${test_bin} cjdns-admin cjdns-admin-client cjdns-interface-pipeinterface cjdadmintest interface)
- add_test(${test_bin} ${test_bin})
-endforeach()
-# Add an empty line after tests.
-message("")
+set(Test_FILES
+ UDPInterface_test.c
+ ICMP6Generator_test.c
+)
+set(Test_LIBRARIES
+ cjdns-admin
+ cjdns-admin-client
+ cjdns-interface-pipeinterface
+ cjdadmintest
+ interface
+)
+include(${CMAKE_SOURCE_DIR}/cmake/modules/Test.cmake)
Oops, something went wrong.

0 comments on commit a45f982

Please sign in to comment.