~ubuntu-branches/ubuntu/intrepid/adduser/intrepid

« back to all changes in this revision

Viewing changes to testsuite/test1.pl

  • Committer: Bazaar Package Importer
  • Author(s): Marc Haber, Marc Haber, Stephen Gran
  • Date: 2007-01-19 08:15:21 UTC
  • mfrom: (2.1.8 feisty)
  • Revision ID: james.westby@ubuntu.com-20070119081521-6malwyq1kst6orkm
Tags: 3.102
[ Marc Haber ]
* Add testsuite test9.pl to catch the bug from #407231
* Some testsuite tweaks
* remove shell script tests, they are no longer used

[ Stephen Gran ]
* existing_group_ok was not properly differentiating between an existing
  user group and an existing system group.  (closes: #407231)
* Test suite documentation update
* lib_test.pl did not properly handle out of sequence or gappy usernames in
  getpwent or getgrent loops.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
# expect:
 
4
#  - a new system user $USER
 
5
#  - added to group nogroup
 
6
#  - home directory /home/$USER
 
7
#  - removal of home directory works
 
8
 
 
9
use strict;
 
10
use lib_test;
 
11
 
 
12
my $groupname = "nogroup";
 
13
my $username = find_unused_name(); 
 
14
my $cmd = "adduser --system $username";
 
15
 
 
16
if (!defined (getpwnam($username))) {
 
17
        print "Testing $cmd... ";
 
18
        `$cmd`;
 
19
        my $error = ($?>>8);
 
20
        if ($error) {
 
21
          print "failed\n  adduser returned an errorcode != 0 ($error)\n";
 
22
          exit $error;
 
23
        }
 
24
        assert(check_user_exist ($username));
 
25
        assert(check_homedir_exist($username)); 
 
26
        assert(check_group_exist($groupname));
 
27
        assert(check_user_in_group($username,$groupname));
 
28
        print "ok\n";
 
29
}
 
30
 
 
31
$cmd = "deluser --remove-home $username";
 
32
if (defined (getpwnam($username))) {
 
33
        my $homedir = (getpwnam($username))[7];
 
34
        print "Testing $cmd... ";
 
35
        `$cmd`;
 
36
        my $error = ($?>>8);
 
37
        if ($error) {
 
38
          print "failed\n  adduser returned an errorcode != 0 ($error)\n";
 
39
          exit $error;
 
40
        }
 
41
        assert(check_user_not_exist ($username));
 
42
        assert(check_homedir_not_exist($homedir));      
 
43
        print "ok\n";
 
44
}
 
45