3
0

pidof.tests 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. # pidof tests.
  3. # Copyright 2005 by Bernhard Reutner-Fischer
  4. # Licensed under GPLv2, see file LICENSE in this source tree.
  5. # AUDIT:
  6. . ./testing.sh
  7. # testing "test name" "options" "expected result" "file input" "stdin"
  8. testing "pidof (exit with error)" \
  9. "pidof veryunlikelyoccuringbinaryname ; echo \$?" "1\n" "" ""
  10. testing "pidof (exit with success)" "pidof pidof > /dev/null; echo \$?" \
  11. "0\n" "" ""
  12. # We can get away with this because it says #!/bin/sh up top.
  13. testing "pidof this" "pidof pidof.tests | grep -o -w $$" "$$\n" "" ""
  14. test x"`cat /proc/1/comm`" = x"init" && {
  15. optional FEATURE_PIDOF_SINGLE
  16. testing "pidof -s" "pidof -s init" "1\n" "" ""
  17. SKIP=
  18. }
  19. test x"`cat /proc/1/comm`" = x"init" && {
  20. optional FEATURE_PIDOF_OMIT FEATURE_PIDOF_SINGLE
  21. # This test fails now because process name matching logic has changed,
  22. # but new logic is not "wrong" either... see find_pid_by_name.c comments
  23. #testing "pidof -o %PPID" "pidof -o %PPID pidof.tests | grep -o -w $$" "" "" ""
  24. testing "pidof -o %PPID NOP" "pidof -o %PPID -s init" "1\n" "" ""
  25. SKIP=
  26. }
  27. optional FEATURE_PIDOF_OMIT
  28. testing "pidof -o init" "pidof -o 1 init | grep -o -w 1" "" "" ""
  29. SKIP=
  30. exit $FAILCOUNT