changeset 19136:10c57204fd72

nproc.cc: codesprint: adding tests
author Andreas Weber <andy.weber.aw@gmail.com>
date Sun, 21 Sep 2014 21:32:31 +0200
parents dc51f26f0db5
children cfe8ec7650a1
files libinterp/corefcn/nproc.cc
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/nproc.cc	Sun Sep 21 15:23:46 2014 -0400
+++ b/libinterp/corefcn/nproc.cc	Sun Sep 21 21:32:31 2014 +0200
@@ -87,4 +87,21 @@
 /*
 ## Must always report at least 1 cpu available
 %!assert (nproc () >= 1);
+%!assert (nproc ("all") >= 1);
+%!assert (nproc ("current") >= 1);
+
+%!test
+%! c = nproc ("current");
+%! unwind_protect
+%!   old_val = getenv ("OMP_NUM_THREADS");
+%!   new_val = c + 1;
+%!   setenv ("OMP_NUM_THREADS", num2str (new_val));
+%!   assert (nproc ("overridable"), new_val);
+%! unwind_protect_cleanup
+%!   if (! isempty (old_val))
+%!     setenv ("OMP_NUM_THREADS", old_val);
+%!   endif
+%! end_unwind_protect
+
+%!error nproc ("no_valid_option");
 */