test-online-cpus: helper to return cpu count
authorJeff Hostetler <jeffhost@microsoft.com>
Mon, 3 Apr 2017 15:16:41 +0000 (15:16 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Apr 2017 06:17:19 +0000 (23:17 -0700)
Created helper executable to print the value of online_cpus()
allowing multi-threaded tests to be skipped when appropriate.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
t/helper/.gitignore
t/helper/test-online-cpus.c [new file with mode: 0644]
index 061d9ea88489fc8575e116d61704b0473c58269c..dc0c3689b11c92bacfeee61fc222d9ace0c222e0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -619,6 +619,7 @@ TEST_PROGRAMS_NEED_X += test-line-buffer
 TEST_PROGRAMS_NEED_X += test-match-trees
 TEST_PROGRAMS_NEED_X += test-mergesort
 TEST_PROGRAMS_NEED_X += test-mktemp
+TEST_PROGRAMS_NEED_X += test-online-cpus
 TEST_PROGRAMS_NEED_X += test-parse-options
 TEST_PROGRAMS_NEED_X += test-path-utils
 TEST_PROGRAMS_NEED_X += test-prio-queue
index 758ed2e8fa127c2b2df9b5d526069472dddc096f..b05d67c237f75d277bb695e3ce2422b9c8c12f05 100644 (file)
@@ -16,6 +16,7 @@
 /test-match-trees
 /test-mergesort
 /test-mktemp
+/test-online-cpus
 /test-parse-options
 /test-path-utils
 /test-prio-queue
diff --git a/t/helper/test-online-cpus.c b/t/helper/test-online-cpus.c
new file mode 100644 (file)
index 0000000..06c09c6
--- /dev/null
@@ -0,0 +1,8 @@
+#include "git-compat-util.h"
+#include "thread-utils.h"
+
+int cmd_main(int argc, const char **argv)
+{
+       printf("%d\n", online_cpus());
+       return 0;
+}