view tests/groupdel.test @ 1572:da1bf31ed322 draft

Tweak the "ignoring return value" fortify workaround for readlinkat. We zero the buffer and if the link read fails that's left alone, so it's ok for the symlink not to be there. Unfortunately, typecasting the return value to (void) doesn't shut up gcc, and having an if(); with the semicolon on the same line doesn't shut up llvm. (The semicolon on a new line would, but C does not have significant whitespace and I'm not going to humor llvm if it plans to start.) So far, empty curly brackets consistently get the warning to shut up.
author Rob Landley <rob@landley.net>
date Mon, 24 Nov 2014 17:23:23 -0600
parents 8700cbe1cb29
children
line wrap: on
line source

#!/bin/bash

# Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
# Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>

[ -f testing.sh ] && . testing.sh

# Redirecting all output to /dev/null for grep and delgroup
arg="&>/dev/null"

#testing "name" "command" "result" "infile" "stdin"

testing "groupadd group_name (text)" "groupadd toyTestGroup &&
   grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg &&
   echo 'yes'" "yes\n" "" ""
testing "groupadd group_name (alphanumeric)" "groupadd toy1Test2Group3 &&
   grep '^toy1Test2Group3:' /etc/group $arg && groupdel toy1Test2Group3 $arg &&
   echo 'yes'" "yes\n" "" ""
testing "groupadd group_name (numeric)" "groupadd 987654321 &&
   grep '^987654321:' /etc/group $arg && groupdel 987654321 $arg &&
   echo 'yes'" "yes\n" "" ""
testing "groupadd group_name (with ./-)" "groupadd toy.1Test-2Group.3 &&
   grep '^toy.1Test-2Group.3:' /etc/group $arg &&
   groupdel toy.1Test-2Group.3 $arg && echo 'yes'" "yes\n" "" ""
testing "groupadd group_name with group_id" "groupadd -g 49999 toyTestGroup &&
   grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg &&
   echo 'yes'" "yes\n" "" ""