blob: bfde26e2c9b049da0c02c3fd998b1de35704f832 [file] [log] [blame]
Bernhard Reutner-Fischer82338d82005-10-06 12:50:11 +00001#!/bin/sh
2
3# pidof tests.
4# Copyright 2005 by Bernhard Fischer
5# Licensed under GPL v2, see file LICENSE for details.
6
Denis Vlasenko9213a9e2006-09-17 16:28:10 +00007# AUDIT:
Bernhard Reutner-Fischer82338d82005-10-06 12:50:11 +00008
Bernhard Reutner-Fischer82338d82005-10-06 12:50:11 +00009. testing.sh
10
11# testing "test name" "options" "expected result" "file input" "stdin"
12
Rob Landley4bb1b042006-03-16 15:20:45 +000013testing "pidof (exit with error)" \
14 "pidof veryunlikelyoccuringbinaryname ; echo \$?" "1\n" "" ""
15testing "pidof (exit with success)" "pidof pidof > /dev/null; echo \$?" \
16 "0\n" "" ""
17# We can get away with this because it says #!/bin/sh up top.
Bernhard Reutner-Fischer82338d82005-10-06 12:50:11 +000018
Rob Landley4bb1b042006-03-16 15:20:45 +000019testing "pidof this" "pidof pidof.tests | grep -o -w $$" "$$\n" "" ""
Bernhard Reutner-Fischer82338d82005-10-06 12:50:11 +000020
Rob Landley48c61572005-11-07 08:50:53 +000021optional FEATURE_PIDOF_SINGLE
Rob Landley4bb1b042006-03-16 15:20:45 +000022testing "pidof -s" "pidof -s init" "1\n" "" ""
Bernhard Reutner-Fischer82338d82005-10-06 12:50:11 +000023
Rob Landley48c61572005-11-07 08:50:53 +000024optional FEATURE_PIDOF_OMIT
Rob Landley4bb1b042006-03-16 15:20:45 +000025testing "pidof -o %PPID" "pidof -o %PPID pidof.tests | grep -o -w $$" "" "" ""
26testing "pidof -o %PPID NOP" "pidof -o %PPID -s init" "1\n" "" ""
Denis Vlasenko9213a9e2006-09-17 16:28:10 +000027testing "pidof -o init" "pidof -o 1 init | grep -o -w 1" "" "" ""
Bernhard Reutner-Fischer82338d82005-10-06 12:50:11 +000028
29exit $FAILCOUNT