Debian Codegraph @

tests/grouptools/groupmems/41_groupmems_user_purge_user-not_primary_group/run_groupmems.exp

raw
1 #!/usr/bin/expect
2
3 set timeout 2
4 expect_after default {puts stderr "\nFAIL"; exit 1}
5
6 if {$argc != 0} {
7 puts "usage: run_groupmems.exp"
8 exit 1
9 }
10
11 # First, switch to the testsuite user
12 # (otherwise, no password will be asked)
13 send_user "# switch to the 'myuser' user\n"
14 send_user "# and expect a '$ ' prompt\n"
15 spawn /bin/su myuser
16
17 expect "$ " ;# Wait for the prompt
18
19 send_user "\n# make sure we are now 'myuser'"
20 send_user "\n# id should return 'uid=424242(myuser) gid=424242(myuser) groups=424242(myuser),99(groupmems)'"
21 send "\r" ;# restore the prompt for the logs
22 send "id\r" ;# Verify we are really testsuite
23
24 expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser),99(groupmems)"
25
26 expect "$ " ;# Wait for the prompt
27
28 send_user "\n\n"
29 send_user "# now add user utest1 to the myuser group\n"
30 send_user "# and expect a password prompt"
31 send "\r" ;# restore the prompt for the logs
32 send "/usr/sbin/groupmems -p -g gmyuser\r" ;#
33 expect "groupmems: only root can use the -g/--group option"
34
35 expect "$ " ;# Wait for the prompt
36 send "echo $?\r"
37 expect "3\r"
38 expect "$ " ;# Wait for the prompt
39 close
40
41 puts "\nPASS"
42 exit 0