You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

  1. # -*- cperl -*-
  2. # Copyright (c) 2007 MySQL AB
  3. # Use is subject to license terms.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; version 2 of the License.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. use Test::More qw(no_plan);
  18. use strict;
  19. use_ok ("My::SafeProcess::Base");
  20. my $count= 0;
  21. for (1..100){
  22. my $pid= My::SafeProcess::Base::_safe_fork();
  23. exit unless $pid;
  24. (waitpid($pid, 0) == $pid) and $count++;
  25. }
  26. ok($count == 100, "safe_fork");
  27. # A nice little forkbomb
  28. SKIP: {
  29. skip("forkbomb", 1);
  30. eval {
  31. while(1){
  32. my $pid= My::SafeProcess::Base::_safe_fork();
  33. exit unless $pid;
  34. }
  35. };
  36. ok($@, "forkbomb");
  37. }