diff --git a/bin/gen_build b/bin/gen_build index 6d8a99c6..6b8e286f 100755 --- a/bin/gen_build +++ b/bin/gen_build @@ -860,11 +860,11 @@ rule link_oak_test description = Link test ‘$out’… rule run_test - command = $in && touch $out + command = $in $test_flags && touch $out description = Run test ‘$in’… rule always_run_test - command = $in + command = $in $test_flags description = Run test ‘$in’… rule skip_test diff --git a/bin/gen_test b/bin/gen_test index 1ec7cd58..24bed4e9 100755 --- a/bin/gen_test +++ b/bin/gen_test @@ -139,7 +139,8 @@ static void write_usage (FILE* io) fprintf(io, "Usage: %s [-b|--benchmark] [-m|--measure] [-r|--repeat] [-v|--verbose] [-h|--help] [-V|--version]\n", getprogname()); fprintf(io, "Options:\n"); fprintf(io, " -b/--benchmark Run benchmarks instead of tests.\n"); - fprintf(io, " -m/--measure Measure time of each test. This disables concurrency.\n"); + fprintf(io, " -m/--measure Measure time of each test.\n"); + fprintf(io, " -p/--parallel Run tests in parallel.\n"); fprintf(io, " -r/--repeat Number of times to repeat each test/benchmark.\n"); fprintf(io, " -v/--verbose Be verbose.\n"); fprintf(io, " -h/--help Show this help.\n"); @@ -152,6 +153,7 @@ int main (int argc, char const* argv[]) { { "benchmark", no_argument, 0, 'b' }, { "measure", no_argument, 0, 'm' }, + { "parallel", no_argument, 0, 'p' }, { "repeat", required_argument, 0, 'r' }, { "verbose", no_argument, 0, 'v' }, { "help", no_argument, 0, 'h' }, @@ -160,18 +162,20 @@ int main (int argc, char const* argv[]) }; bool measure = false; + bool parallel = false; bool run_benchmarks = false; bool verbose = false; size_t repeat = 1; unsigned int ch; - while((ch = getopt_long(argc, (char* const*)argv, "bmr:vhV", options, NULL)) != -1) + while((ch = getopt_long(argc, (char* const*)argv, "bmpr:vhV", options, NULL)) != -1) { extern char* optarg; switch(ch) { case 'b': run_benchmarks = true; break; case 'm': measure = true; break; + case 'p': parallel = true; break; case 'r': repeat = atoi(optarg); break; case 'v': verbose = true; break; case 'h': write_usage(stdout); return 0; @@ -221,17 +225,17 @@ int main (int argc, char const* argv[]) if(!run_benchmarks) { dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - if(measure) - { - for(auto test : tests) - test.execute(measure, repeat); - } - else + if(parallel) { dispatch_apply(tests.size(), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t n){ tests[n].execute(measure, repeat); }); } + else + { + for(auto test : tests) + test.execute(measure, repeat); + } }); } diff --git a/configure b/configure index 890d26a6..93402ebe 100755 --- a/configure +++ b/configure @@ -93,7 +93,7 @@ done mkdir -p "$builddir/Frameworks/SoftwareUpdate/fixtures" DST=$(cd >/dev/null "$builddir/Frameworks/SoftwareUpdate/fixtures"; pwd) make -C Frameworks/SoftwareUpdate/fixtures -bin/gen_build -o build.ninja -C "$builddir" -dAPP_NAME="$name" -dAPP_VERSION="$ver" -dAPP_MIN_OS="$min_os" -dCC="$CC" -dCXX="$CXX" -didentity="$identity" -drest_api="$rest_api" -dbzip2_flag="$bzip2_flag" -dcapnp_prefix="$capnp_prefix" -dlibressl_prefix="$libressl_prefix" target +bin/gen_build -o build.ninja -C "$builddir" -dAPP_NAME="$name" -dAPP_VERSION="$ver" -dAPP_MIN_OS="$min_os" -dCC="$CC" -dCXX="$CXX" -didentity="$identity" -drest_api="$rest_api" -dbzip2_flag="$bzip2_flag" -dtest_flags="$test" -dcapnp_prefix="$capnp_prefix" -dlibressl_prefix="$libressl_prefix" target ninja Frameworks/encoding/src/frequencies.capnp.h ninja Frameworks/plist/src/cache.capnp.h