We're losing the svn history (which we could probably keep if we tried hard enough) but don't consider that worthwhile. Note these tests are destructive, so run them only in a throwaway environment like a chroot, container, or vm. The tests/run.all script should be the one which launches all the tests. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
		
			
				
	
	
		
			58 lines
		
	
	
		
			1014 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1014 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/sh
 | 
						|
 | 
						|
set -e
 | 
						|
 | 
						|
cd $(dirname $0)
 | 
						|
 | 
						|
# Rational:
 | 
						|
# Test that useradd can add an user and userdel removes it.
 | 
						|
 | 
						|
save()
 | 
						|
{
 | 
						|
	[ ! -d tmp ] && mkdir tmp
 | 
						|
	for i in passwd group shadow gshadow
 | 
						|
	do
 | 
						|
		[ -f /etc/$i  ] && cp /etc/$i  tmp/$i
 | 
						|
	done
 | 
						|
 | 
						|
	true
 | 
						|
}
 | 
						|
 | 
						|
restore()
 | 
						|
{
 | 
						|
	for i in passwd group shadow gshadow
 | 
						|
	do
 | 
						|
		[ -f tmp/$i  ] && cp tmp/$i  /etc/$i  && rm tmp/$i
 | 
						|
	done
 | 
						|
	rmdir tmp
 | 
						|
}
 | 
						|
 | 
						|
save
 | 
						|
 | 
						|
# restore the files on exit
 | 
						|
trap 'restore' 0
 | 
						|
 | 
						|
for i in passwd group shadow gshadow
 | 
						|
do
 | 
						|
	cp data/$i /etc
 | 
						|
done
 | 
						|
 | 
						|
lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ")
 | 
						|
lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ")
 | 
						|
lines_group=$(wc -l /etc/group | cut -f1 -d" ")
 | 
						|
lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ")
 | 
						|
 | 
						|
echo -n "Copy gshadow.new "
 | 
						|
cpgr -s data/gshadow.new
 | 
						|
echo "OK"
 | 
						|
 | 
						|
echo -n "test if the password file was copied"
 | 
						|
diff -au /etc/gshadow data/gshadow.new
 | 
						|
echo "  OK"
 | 
						|
 | 
						|
echo -n "check that the other files were not modified"
 | 
						|
diff -au /etc/group data/group
 | 
						|
diff -au /etc/passwd data/passwd
 | 
						|
diff -au /etc/shadow data/shadow
 | 
						|
echo "  OK"
 |