diff options
author | Glenn Morris <rgm@gnu.org> | 2018-11-10 19:13:20 -0800 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2018-11-10 19:13:20 -0800 |
commit | c30f24d03dbdc730bc4c8fbc0e1309830e8c9767 (patch) | |
tree | 17f734364169660401c088a302dfdfd80548bef1 /test/src | |
parent | 1a3d471d87ea459bc2c2d704c5578e6977e68e83 (diff) | |
download | emacs-c30f24d03dbdc730bc4c8fbc0e1309830e8c9767.tar.gz |
* test/src/editfns-tests.el (test-group-name): Improve test.
Make more portable and hopefully more robust using getent. (Bug#33195)
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/editfns-tests.el | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index 6ce49fdc28b..09584d1694a 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el @@ -352,17 +352,24 @@ "-0x000000003ffffffffffffffe000000000000000 ")))) (ert-deftest test-group-name () + (should (stringp (group-name (group-gid)))) + (should-error (group-name 'foo)) (cond ((memq system-type '(windows-nt ms-dos)) - (should (stringp (group-name (group-gid)))) - (should-not (group-name 123456789)) - (should-error (group-name 'foo))) - (t - (let ((list `((0 . "root") -;;; (1000 . ,(user-login-name 1000)) - (1212345 . nil)))) - (dolist (test list) - (should (equal (group-name (car test)) (cdr test))))) - (should-error (group-name 'foo))))) + (should-not (group-name 123456789))) + ((executable-find "getent") + (with-temp-buffer + (let (stat name) + (dolist (gid (list 0 1212345 (group-gid))) + (erase-buffer) + (setq stat (call-process "getent" nil '(t nil) nil "group" + (number-to-string gid))) + (setq name (group-name gid)) + (goto-char (point-min)) + (cond ((eq stat 0) + (if (looking-at "\\([[:alnum:]_-]+\\):") + (should (string= (match-string 1) name)))) + ((eq stat 2) + (should-not name))))))))) ;;; editfns-tests.el ends here |