blob: 2af12204dd36d4f47942992aa5ade0e3eaf6dcfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/bin/bash
# Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
# Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
#cleaning 'yes' processes
killall yes >/dev/null 2>&1
[ -f testing.sh ] && . testing.sh
#testing "name" "command" "result" "infile" "stdin"
# Starting processes to test pgrep command
yes >/dev/null &
proc=$!
#echo "# Process created with id: $proc"
sleep .1
session_id=0
proc_parent=`cat /proc/${proc}/stat | awk '{ print $4 }'`
#echo "# Parent Process id of $proc is $proc_parent"
# Testcases for pgrep command
testing "pgrep pattern" "pgrep yes" "$proc\n" "" ""
testing "pgrep wildCardPattern" "pgrep ^y.*s$" "$proc\n" "" ""
testing "pgrep -l pattern" "pgrep -l yes" "$proc yes\n" "" ""
testing "pgrep -f pattern" "pgrep -f yes" "$proc\n" "" ""
testing "pgrep -n pattern" "pgrep -n yes" "$proc\n" "" ""
testing "pgrep -o pattern" "pgrep -o yes" "$proc\n" "" ""
testing "pgrep -s" "pgrep -s $session_id yes" "$proc\n" "" ""
testing "pgrep -P" "pgrep -P $proc_parent yes" "$proc\n" "" ""
#Clean-up
killall yes >/dev/null 2>&1
|