mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-27 21:45:42 +00:00
[tools.testspr] move file testspr/test.sh -> tools/testspr/test.sh
This commit is contained in:
parent
6a58eade0e
commit
3fef178b7c
11 changed files with 374 additions and 159 deletions
|
@ -21,14 +21,12 @@
|
|||
# include <sprout/preprocessor/stringize.hpp>
|
||||
#endif
|
||||
|
||||
#if !(defined(SPROUT_DISABLE_ASSERTS) || defined(NDEBUG))
|
||||
//
|
||||
// SPROUT_ASSERTION_FAILED_FORMAT
|
||||
//
|
||||
# ifndef SPROUT_ASSERTION_FAILED_FORMAT
|
||||
# define SPROUT_ASSERTION_FAILED_FORMAT(expr, file, line) \
|
||||
"***** Internal Program Error - assertion (" #expr ") failed: " file "(" SPROUT_PP_STRINGIZE(line) ")"
|
||||
# endif
|
||||
//
|
||||
// SPROUT_ASSERTION_FAILED_FORMAT
|
||||
//
|
||||
#ifndef SPROUT_ASSERTION_FAILED_FORMAT
|
||||
# define SPROUT_ASSERTION_FAILED_FORMAT(expr, file, line) \
|
||||
"***** Internal Program Error - assertion (" #expr ") failed: " file "(" SPROUT_PP_STRINGIZE(line) ")"
|
||||
#endif
|
||||
|
||||
//
|
||||
|
|
|
@ -8,18 +8,56 @@
|
|||
#ifndef TESTSPR_ASSERT_HPP
|
||||
#define TESTSPR_ASSERT_HPP
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#ifdef TESTSPR_CONFIG_ENABLE_STATIC_WARNING
|
||||
# include <boost/serialization/static_warning.hpp>
|
||||
#endif
|
||||
#include <sprout/assert.hpp>
|
||||
|
||||
namespace testspr {
|
||||
//
|
||||
// assertion_failed
|
||||
//
|
||||
class assertion_failed
|
||||
: public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit assertion_failed(std::string const& msg)
|
||||
: std::runtime_error(msg)
|
||||
{}
|
||||
explicit assertion_failed(char const* msg)
|
||||
: std::runtime_error(msg)
|
||||
{}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
assertion_check(bool cond, std::string const& msg) {
|
||||
return cond ? true
|
||||
: throw testspr::assertion_failed(msg)
|
||||
;
|
||||
}
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
assertion_check(bool cond, char const* msg) {
|
||||
return cond ? true
|
||||
: throw testspr::assertion_failed(msg)
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace testspr
|
||||
|
||||
//
|
||||
// TESTSPR_STATIC_ASSERT
|
||||
// TESTSPR_ASSERT
|
||||
//
|
||||
#define TESTSPR_STATIC_ASSERT(expr) \
|
||||
static_assert(expr, #expr)
|
||||
#define TESTSPR_ASSERT(expr) \
|
||||
((void)sprout::detail::assertion_check((expr), SPROUT_ASSERTION_FAILED_FORMAT(expr, __FILE__, __LINE__)))
|
||||
//
|
||||
// TESTSPR_BOTH_ASSERT
|
||||
//
|
||||
#define TESTSPR_STATIC_ASSERT(expr) static_assert(expr, #expr)
|
||||
#define TESTSPR_ASSERT(expr) assert(expr)
|
||||
#ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR
|
||||
# define TESTSPR_BOTH_ASSERT(expr) TESTSPR_STATIC_ASSERT(expr); TESTSPR_ASSERT(expr)
|
||||
#else // #ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR
|
||||
|
|
|
@ -14,13 +14,40 @@
|
|||
# error undefined TESTSPR_TEST_FUNCTION
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <sprout/preprocessor/stringize.hpp>
|
||||
#include <testspr/assert.hpp>
|
||||
#include <testspr/typeinfo.hpp>
|
||||
|
||||
int main() {
|
||||
std::cout << "testspr exec: " << SPROUT_PP_STRINGIZE(TESTSPR_TEST_FUNCTION) << std::endl;
|
||||
TESTSPR_TEST_FUNCTION();
|
||||
std::cout << "testspr succeeded." << std::endl;
|
||||
std::cout << "testspr exec(" << SPROUT_PP_STRINGIZE(TESTSPR_TEST_FUNCTION) << "):" << std::endl;
|
||||
try {
|
||||
TESTSPR_TEST_FUNCTION();
|
||||
} catch (testspr::assertion_failed const& e) {
|
||||
std::cout
|
||||
<< " testspr failed." << std::endl
|
||||
<< " " << e.what() << std::endl
|
||||
;
|
||||
return EXIT_FAILURE;
|
||||
} catch (std::exception const& e) {
|
||||
std::cout
|
||||
<< " testspr failed for some reason." << std::endl
|
||||
<< " exception handled:" << std::endl
|
||||
<< " type = " << testspr::typename_of(e) << std::endl
|
||||
<< " what = " << e.what() << std::endl
|
||||
;
|
||||
return EXIT_FAILURE;
|
||||
} catch (...) {
|
||||
std::cout
|
||||
<< " testspr failed for some reason." << std::endl
|
||||
<< " exception handled:" << std::endl
|
||||
<< " type = <unknown>" << std::endl
|
||||
;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::cout << " testspr succeeded." << std::endl;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,10 +13,6 @@
|
|||
# define TESTSPR_CPP_INCLUDE
|
||||
#endif
|
||||
|
||||
#ifdef TESTSPR_CONFIG_INCLUDE_HEADER_ALL
|
||||
# include "./header_all.hpp"
|
||||
#endif
|
||||
|
||||
#include "../libs/array/test/array.cpp"
|
||||
#include "../libs/string/test/string.cpp"
|
||||
#include "../libs/bitset/test/bitset.cpp"
|
||||
|
|
135
testspr/test.sh
135
testspr/test.sh
|
@ -1,135 +0,0 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
# https://github.com/bolero-MURAKAMI/Sprout
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
# =============================================================================
|
||||
stagedir="testspr"
|
||||
gcc_version="4.7.0 4.7.1 4.7.2 4.7.3 4.8.0 4.8.1"
|
||||
clang_version="3.2 3.3"
|
||||
gcc_root="/usr/local"
|
||||
clang_root="/usr/local"
|
||||
declare -a user_macros
|
||||
user_macros=()
|
||||
declare -a include_paths
|
||||
include_paths=()
|
||||
force=0
|
||||
use_help=0
|
||||
declare -A version_specific_options
|
||||
version_specific_options=(
|
||||
[clang-3.3]="-ftemplate-depth=512"
|
||||
)
|
||||
declare -A results
|
||||
results=()
|
||||
|
||||
compile() {
|
||||
echo "${1}-${2} compile..."
|
||||
${5}/${1}-${2}/bin/${1/%cc}++ -Wall -pedantic -std=c++11 -o ${stagedir}/test_${1}${2//.} ${4} ${3}
|
||||
results[${1}-${2}]=$?
|
||||
}
|
||||
execute() {
|
||||
if [ ${results[${1}-${2}]} -eq 0 ]; then
|
||||
echo "${1}-${2} compile succeeded."
|
||||
if ${stagedir}/test_$1${2//.}; then
|
||||
echo "${1}-${2} execute succeeded."
|
||||
else
|
||||
echo >&2 "error: ${1}-${2} execute failed."
|
||||
fi
|
||||
else
|
||||
echo >&2 "error: ${1}-${2} compile failed."
|
||||
fi
|
||||
}
|
||||
|
||||
args=`getopt -o S:D:I:f -l stagedir:,gcc-version:,clang-version:,gcc-root:,clang-root:,define:,include:,force,help -- "$@"`
|
||||
if [ "$?" -ne 0 ]; then
|
||||
echo >&2 "error: options parse error. See 'test.sh --help'"
|
||||
exit 1
|
||||
fi
|
||||
eval set -- ${args}
|
||||
while [ -n "$1" ]; do
|
||||
case $1 in
|
||||
-S|--stagedir) stagedir=$2; shift 2;;
|
||||
--gcc-version) gcc_version="$2"; shift 2;;
|
||||
--clang-version) clang_version="$2"; shift 2;;
|
||||
--gcc-root) gcc_root="$2"; shift 2;;
|
||||
--clang-root) clang_root="$2"; shift 2;;
|
||||
-D|--define) user_macros=(${user_macros[@]} "$2"); shift 2;;
|
||||
-I|--include) include_paths=(${include_paths[@]} "$2"); shift 2;;
|
||||
-f|--force) force=1; shift;;
|
||||
--help) use_help=1; shift;;
|
||||
--) shift; break;;
|
||||
*) echo >&2 "error: unknown option($1) used."; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ${use_help} -ne 0 ]; then
|
||||
echo "help:"
|
||||
echo ""
|
||||
echo " -S, --stagedir=<dir> Output files here."
|
||||
echo " Default; 'testspr'"
|
||||
echo ""
|
||||
echo " --gcc-version=<value> Indicates gcc version."
|
||||
echo " Default; '4.7.0 4.7.1 4.7.2 4.7.3 4.8.0 4.8.1'"
|
||||
echo ""
|
||||
echo " --clang-version=<value> Indicates clang version."
|
||||
echo " Default; '3.2 3.3'"
|
||||
echo ""
|
||||
echo " --gcc-root=<dir> Root directory that gcc installed."
|
||||
echo " Default; '/usr/local'"
|
||||
echo ""
|
||||
echo " --clang-root=<dir> Root directory that clang installed."
|
||||
echo " Default; '/usr/local'"
|
||||
echo ""
|
||||
echo " -D, --define=<identifier> Define macro for preprocessor."
|
||||
echo ""
|
||||
echo " -I, --include=<directory> Add system include path."
|
||||
echo ""
|
||||
echo " -f, --force Allow overwrite of <stagedir>."
|
||||
echo ""
|
||||
echo " --help This message."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "settings:"
|
||||
echo " stagedir = '${stagedir}'"
|
||||
echo " gcc-version = (${gcc_version})"
|
||||
echo " clang-version = (${clang_version})"
|
||||
echo " gcc-root = '${gcc_root}'"
|
||||
echo " clang-root = '${clang_root}'"
|
||||
echo " user-macros = (${user_macros[*]})"
|
||||
echo " include-paths = (${include_paths[*]})"
|
||||
echo " force = ${force}"
|
||||
|
||||
for user_macro in ${user_macros}; do
|
||||
define_options="${define_options} -D${user_macro}"
|
||||
done
|
||||
for include_path in ${include_paths}; do
|
||||
include_options="${include_options} -I${include_path}"
|
||||
done
|
||||
|
||||
if [ -d "${stagedir}" ]; then
|
||||
if [ ${force} -eq 0 ]; then
|
||||
echo >&2 "error: stagedir(${stagedir}) already exists."
|
||||
exit 1
|
||||
else
|
||||
rm -f -r ${stagedir}/*
|
||||
fi
|
||||
else
|
||||
mkdir -p ${stagedir}
|
||||
fi
|
||||
|
||||
for version in ${gcc_version}; do
|
||||
compile gcc ${version} $(cd $(dirname $0); pwd)/sprout.cpp "${define_options} ${include_options} ${version_specific_options[gcc-${version}]}" ${gcc_root}
|
||||
done
|
||||
for version in ${clang_version}; do
|
||||
compile clang ${version} $(cd $(dirname $0); pwd)/sprout.cpp "${define_options} ${include_options} ${version_specific_options[clang-${version}]}" ${clang_root}
|
||||
done
|
||||
|
||||
for version in ${gcc_version}; do
|
||||
execute gcc ${version}
|
||||
done
|
||||
for version in ${clang_version}; do
|
||||
execute clang ${version}
|
||||
done
|
|
@ -20,6 +20,7 @@
|
|||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <typeinfo>
|
||||
#ifdef TESTSPR_HAS_CXXABI_H
|
||||
# include <cstdlib>
|
||||
|
@ -53,11 +54,19 @@ namespace testspr {
|
|||
inline std::string typename_of() {
|
||||
return testspr::detail::cxa_demangle(typeid(T).name());
|
||||
}
|
||||
template<typename T>
|
||||
inline std::string typename_of(T&& t) {
|
||||
return testspr::detail::cxa_demangle(typeid(std::forward<T>(t)).name());
|
||||
}
|
||||
#else
|
||||
template<typename T>
|
||||
inline std::string typename_of() {
|
||||
return std::string(typeid(T).name());
|
||||
}
|
||||
template<typename T>
|
||||
inline std::string typename_of(T&& t) {
|
||||
return std::string(typeid(std::forward<T>(t)).name());
|
||||
}
|
||||
#endif
|
||||
} // namespace testspr
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ def main():
|
|||
return any(pool.map(
|
||||
compile,
|
||||
[format_command(x, y)
|
||||
for x in range(0, opts.width, opts.tile_width)
|
||||
for y in range(0, opts.height, opts.tile_height)
|
||||
for x in range(0, opts.width, opts.tile_width)
|
||||
]
|
||||
))
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ while [ -n "$1" ]; do
|
|||
-H|--tile-height) tile_height=$2; shift 2;;
|
||||
-D|--define) user_macros=(${user_macros[@]} "$2"); shift 2;;
|
||||
-I|--include) include_paths=(${include_paths[@]} "$2"); shift 2;;
|
||||
-P|--max_procs) max_procs=$2; shift 2;;
|
||||
-P|--max-procs) max_procs=$2; shift 2;;
|
||||
-f|--force) force=1; shift;;
|
||||
--help) use_help=1; shift;;
|
||||
--) shift; break;;
|
||||
|
@ -166,7 +166,7 @@ if [ ${max_procs} -eq 1 ]; then
|
|||
done
|
||||
echo ""
|
||||
|
||||
let "y_elapsed=${SECONDS}-${y_start}"
|
||||
let y_elapsed=${SECONDS}-${y_start}
|
||||
echo " elapsed = ${y_elapsed}s"
|
||||
done
|
||||
else
|
||||
|
@ -178,15 +178,14 @@ else
|
|||
"--tile_width=${tile_width}" "--tile_height=${tile_height}"" "\
|
||||
"--compile_options=${compile_options}" "--darkcult_cpp=${darkcult_cpp}" \
|
||||
"--max_procs=${max_procs}"
|
||||
echo ""
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo >&2 "error: compile failed."
|
||||
exit 1
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
|
||||
let "elapsed=${SECONDS}-${start}"
|
||||
let elapsed=${SECONDS}-${start}
|
||||
echo " elapsed(total) = ${elapsed}s"
|
||||
|
||||
for ((y=0; y<height; y+=tile_height)); do
|
||||
|
|
12
tools/testspr/test.cpp
Normal file
12
tools/testspr/test.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifdef TESTSPR_CONFIG_INCLUDE_HEADER_ALL
|
||||
# include "../../testspr/header_all.hpp"
|
||||
#endif
|
||||
|
||||
# include "../../testspr/sprout.cpp"
|
61
tools/testspr/test.py
Normal file
61
tools/testspr/test.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env python
|
||||
# =============================================================================
|
||||
# Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
# https://github.com/bolero-MURAKAMI/Sprout
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
# =============================================================================
|
||||
import sys
|
||||
import optparse
|
||||
import subprocess
|
||||
import multiprocessing
|
||||
|
||||
def compile(command):
|
||||
sys.stdout.write(".")
|
||||
sys.stdout.flush()
|
||||
return subprocess.call(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
|
||||
def main():
|
||||
parser = optparse.OptionParser(description='test.py')
|
||||
parser.add_option('--stagedir', type='string')
|
||||
parser.add_option('--gcc_version', type='string')
|
||||
parser.add_option('--clang_version', type='string')
|
||||
parser.add_option('--gcc_root', type='string')
|
||||
parser.add_option('--clang_root', type='string')
|
||||
parser.add_option('--compile_options', type='string')
|
||||
parser.add_option('--test_cpp', type='string')
|
||||
parser.add_option('--serialized_version_specific_options', type='string')
|
||||
parser.add_option('--max_procs', type='int')
|
||||
(opts, args) = parser.parse_args()
|
||||
|
||||
pool = multiprocessing.Pool(opts.max_procs if opts.max_procs != 0 else None)
|
||||
|
||||
def format_command(name, version, root):
|
||||
base = "%s-%s" % (name, version) if version != "." else name
|
||||
bin = "%s/test.%s.out" % (opts.stagedir, base.replace('.', ''))
|
||||
compile_log = "%s/test.%s.compile.log" % (opts.stagedir, base.replace('.', ''))
|
||||
execute_log = "%s/test.%s.execute.log" % (opts.stagedir, base.replace('.', ''))
|
||||
compiler = "%s/%s/bin/%s++" % (root, base, name.rstrip('c')) if version != "." else "%s++" % name.rstrip('c')
|
||||
return "%s -o %s" \
|
||||
" %s %s" \
|
||||
" %s > %s 2>&1" \
|
||||
" && %s > %s 2>&1" \
|
||||
% (compiler, bin,
|
||||
opts.compile_options, eval(opts.serialized_version_specific_options).get(base, ''),
|
||||
opts.test_cpp, compile_log,
|
||||
bin, execute_log
|
||||
)
|
||||
return sum(result != 0 for result in pool.map(
|
||||
compile,
|
||||
[format_command('gcc', version, opts.gcc_root)
|
||||
for version in opts.gcc_version.split(' ')
|
||||
]
|
||||
+
|
||||
[format_command('clang', version, opts.clang_root)
|
||||
for version in opts.clang_version.split(' ')
|
||||
]
|
||||
))
|
||||
|
||||
if __name__=="__main__":
|
||||
sys.exit(main())
|
210
tools/testspr/test.sh
Executable file
210
tools/testspr/test.sh
Executable file
|
@ -0,0 +1,210 @@
|
|||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
# https://github.com/bolero-MURAKAMI/Sprout
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
# =============================================================================
|
||||
#
|
||||
# requires: Python (http://www.python.org/) if parallel mode
|
||||
#
|
||||
stagedir="testspr"
|
||||
gcc_version="."
|
||||
clang_version="."
|
||||
gcc_root="/usr/local"
|
||||
clang_root="/usr/local"
|
||||
declare -a user_macros
|
||||
user_macros=()
|
||||
declare -a include_paths
|
||||
include_paths=()
|
||||
max_procs=1
|
||||
force=0
|
||||
use_help=0
|
||||
declare -a common_options
|
||||
common_options=()
|
||||
declare -a version_options
|
||||
version_options=()
|
||||
declare -A version_specific_options
|
||||
version_specific_options=(
|
||||
[clang-3.3]='-ftemplate-depth=512'
|
||||
)
|
||||
test_cpp=$(cd $(dirname $0); pwd)/test.cpp
|
||||
test_py=$(cd $(dirname $0); pwd)/test.py
|
||||
|
||||
args=`getopt -o S:g:c:O:o:D:I:P:f -l stagedir:,gcc-version:,clang-version:,gcc-root:,clang-root:,option:,version-option:,define:,include:,max-procs:,force,help -- "$@"`
|
||||
if [ "$?" -ne 0 ]; then
|
||||
echo >&2 "error: options parse error. See 'test.sh --help'"
|
||||
exit 1
|
||||
fi
|
||||
eval set -- ${args}
|
||||
while [ -n "$1" ]; do
|
||||
case $1 in
|
||||
-S|--stagedir) stagedir=$2; shift 2;;
|
||||
-g|--gcc-version) gcc_version="$2"; shift 2;;
|
||||
-c|--clang-version) clang_version="$2"; shift 2;;
|
||||
--gcc-root) gcc_root="$2"; shift 2;;
|
||||
--clang-root) clang_root="$2"; shift 2;;
|
||||
-O|--option) common_options=(${common_options[@]} "$2"); shift 2;;
|
||||
-o|--version-option) version_options=(${version_options[@]} "$2"); shift 2;;
|
||||
-D|--define) user_macros=(${user_macros[@]} "$2"); shift 2;;
|
||||
-I|--include) include_paths=(${include_paths[@]} "$2"); shift 2;;
|
||||
-P|--max-procs) max_procs=$2; shift 2;;
|
||||
-f|--force) force=1; shift;;
|
||||
--help) use_help=1; shift;;
|
||||
--) shift; break;;
|
||||
*) echo >&2 "error: unknown option($1) used."; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ${use_help} -ne 0 ]; then
|
||||
echo "help:"
|
||||
echo ""
|
||||
echo " -S, --stagedir=<dir> Output files here."
|
||||
echo " Default; 'testspr'"
|
||||
echo ""
|
||||
echo " -g, --gcc-version=<list> Indicates gcc version list (space separated)."
|
||||
echo " If '.', version that is installed on the system."
|
||||
echo " Default; '.'"
|
||||
echo ""
|
||||
echo " -c, --clang-version=<list> Indicates clang version list (space separated)."
|
||||
echo " If '.', version that is installed on the system."
|
||||
echo " Default; '.'"
|
||||
echo ""
|
||||
echo " --gcc-root=<dir> Root directory that gcc installed."
|
||||
echo " Default; '/usr/local'"
|
||||
echo ""
|
||||
echo " --clang-root=<dir> Root directory that clang installed."
|
||||
echo " Default; '/usr/local'"
|
||||
echo ""
|
||||
echo " -O, --option=<opt> Add compile option."
|
||||
echo ""
|
||||
echo " -o, --version-option=<opt> Add version specific compile option."
|
||||
echo " Example; [clang-3.3]='-ftemplate-depth=512'"
|
||||
echo ""
|
||||
echo " -D, --define=<identifier> Define macro for preprocessor."
|
||||
echo ""
|
||||
echo " -I, --include=<directory> Add system include path."
|
||||
echo ""
|
||||
echo " -P, --max-procs=<value> The maximum number of process use."
|
||||
echo " If other than 1, processing in parallel mode."
|
||||
echo " If 0, using the number of CPUs in the system."
|
||||
echo " Default; 1"
|
||||
echo ""
|
||||
echo " -f, --force Allow overwrite of <stagedir>."
|
||||
echo ""
|
||||
echo " --help This message."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "settings:"
|
||||
echo " stagedir = '${stagedir}'"
|
||||
echo " gcc-version = (${gcc_version})"
|
||||
echo " clang-version = (${clang_version})"
|
||||
echo " gcc-root = '${gcc_root}'"
|
||||
echo " clang-root = '${clang_root}'"
|
||||
echo " common-options = (${common_options[*]})"
|
||||
echo " version-options = (${version_options[*]})"
|
||||
echo " user-macros = (${user_macros[*]})"
|
||||
echo " include-paths = (${include_paths[*]})"
|
||||
echo " max-procs = ${max_procs}"
|
||||
echo " force = ${force}"
|
||||
|
||||
for user_macro in ${user_macros}; do
|
||||
define_options="${define_options} -D${user_macro}"
|
||||
done
|
||||
for include_path in ${include_paths}; do
|
||||
include_options="${include_options} -I${include_path}"
|
||||
done
|
||||
compile_options="-Wall -pedantic -std=c++11 ${define_options} ${include_options} ${common_options[*]}"
|
||||
for option in ${version_options}; do
|
||||
eval "version_specific_options${option}"
|
||||
done
|
||||
|
||||
if [ -d "${stagedir}" ]; then
|
||||
if [ ${force} -eq 0 ]; then
|
||||
echo >&2 "error: stagedir(${stagedir}) already exists."
|
||||
exit 1
|
||||
else
|
||||
rm -f -r ${stagedir}/*
|
||||
fi
|
||||
else
|
||||
mkdir -p ${stagedir}
|
||||
fi
|
||||
|
||||
echo "test:"
|
||||
compile() {
|
||||
local base
|
||||
if [ ${2} != "." ]; then
|
||||
base=${1}-${2}
|
||||
else
|
||||
base=${1}
|
||||
fi
|
||||
local bin=${stagedir}/test.${base//.}.out
|
||||
local compile_log=${stagedir}/test.${base//.}.compile.log
|
||||
local execute_log=${stagedir}/test.${base//.}.execute.log
|
||||
local compiler
|
||||
if [ ${2} != "." ]; then
|
||||
compiler=${6}/${base}/bin/${1/%cc}++
|
||||
else
|
||||
compiler=${1/%cc}++
|
||||
fi
|
||||
echo " compile(${base})..."
|
||||
${compiler} -o ${bin} ${4} ${5[${base}]} ${3} >${compile_log} 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " compile succeeded."
|
||||
echo " execute(${base})..."
|
||||
${bin} >${execute_log} 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " execute succeeded."
|
||||
else
|
||||
echo >&2 " error: execute(${base}) failed."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo >&2 " error: compile(${base}) failed."
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
if [ ${max_procs} -eq 1 ]; then
|
||||
fail_count=0
|
||||
for version in ${gcc_version}; do
|
||||
compile gcc ${version} ${test_cpp} ${compile_options} ${version_specific_options} ${gcc_root}
|
||||
let fail_count=${fail_count}+$?
|
||||
done
|
||||
for version in ${clang_version}; do
|
||||
compile clang ${version} ${test_cpp} ${compile_options} ${version_specific_options} ${clang_root}
|
||||
let fail_count=${fail_count}+$?
|
||||
done
|
||||
if [ ${fail_count} -ne 0 ]; then
|
||||
echo >&2 " error: test(${fail_count}) failed."
|
||||
else
|
||||
echo " test succeeded."
|
||||
fi
|
||||
else
|
||||
echo " processing in parallel mode."
|
||||
echo -n " "
|
||||
serialized_version_specific_options={`
|
||||
for key in $(echo ${!version_specific_options[@]}); do
|
||||
echo \'${key}\':\'${version_specific_options[${key}]}\',
|
||||
done
|
||||
echo \'_\':\'\'
|
||||
`}
|
||||
python "${test_py}" \
|
||||
"--stagedir=${stagedir}" \
|
||||
"--gcc_version=${gcc_version}" "--clang_version=${clang_version}" \
|
||||
"--gcc_root=${gcc_root}" "--clang_root=${clang_root}" \
|
||||
"--compile_options=${compile_options}" "--test_cpp=${test_cpp}" \
|
||||
"--serialized_version_specific_options=${serialized_version_specific_options}" \
|
||||
"--max_procs=${max_procs}"
|
||||
fail_count=$?
|
||||
echo ""
|
||||
if [ ${fail_count} -ne 0 ]; then
|
||||
echo >&2 " error: test(${fail_count}) failed."
|
||||
else
|
||||
echo " test succeeded."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "finished."
|
Loading…
Reference in a new issue