#! /bin/sh

mkdir -p tests/tmp/proc

# Old style
echo 'foo 100 0' > tests/tmp/proc/modules
echo 'bar 100 0' >> tests/tmp/proc/modules

[ "`rmmod foo bar`" = "DELETE_MODULE: foo EXCL NONBLOCK 
DELETE_MODULE: bar EXCL NONBLOCK " ]

[ "`rmmod -f foo bar`" = "DELETE_MODULE: foo EXCL TRUNC NONBLOCK 
DELETE_MODULE: bar EXCL TRUNC NONBLOCK " ]

[ "`rmmod -w foo bar`" = "DELETE_MODULE: foo EXCL 
DELETE_MODULE: bar EXCL " ]

# First examine stdout (mixing them gives unpredictable results)
[ "`rmmod foo bar baz 2>/dev/null`" = "DELETE_MODULE: foo EXCL NONBLOCK 
DELETE_MODULE: bar EXCL NONBLOCK " ]
[ "`rmmod baz foo bar 2>/dev/null`" = "DELETE_MODULE: foo EXCL NONBLOCK 
DELETE_MODULE: bar EXCL NONBLOCK " ]

# Now examine stderr.
[ "`rmmod foo bar baz 2>&1 >/dev/null`" = "ERROR: Module baz does not exist in /proc/modules" ]
[ "`rmmod baz foo bar 2>&1 >/dev/null`" = "ERROR: Module baz does not exist in /proc/modules" ]
