Raymond Toy pushed to branch issue-269-unix-get-user-homedir at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • tests/os.lisp
    ... ... @@ -7,15 +7,18 @@
    7 7
       "Test user-homedir"
    
    8 8
       (:tag :issues)
    
    9 9
       ;; Simple test to see if unix-get-user-homedir returns the expected
    
    10
    -  ;; value.  We assume the envvar USERNAME and HOME exist and are
    
    11
    -  ;; correctly set up for the user running this test.
    
    12
    -  (let ((user-name (unix:unix-getenv "USERNAME")))
    
    13
    -    (assert-true user-name)
    
    14
    -    (when user-name
    
    15
    -      (let ((expected-homedir (pathname
    
    16
    -                               (concatenate 'string
    
    17
    -                                            (unix:unix-getenv "HOME")
    
    18
    -                                            "/")))
    
    19
    -            (homedir (unix:unix-get-user-homedir user-name)))
    
    20
    -        (assert-true expected-homedir)
    
    21
    -        (assert-equal homedir expected-homedir)))))
    10
    +  ;; value.  Use getuid and getpwuid to figure out what the name and
    
    11
    +  ;; home directory should be.
    
    12
    +  (let* ((uid (unix:unix-getuid))
    
    13
    +         (user-info (unix:unix-getpwuid uid)))
    
    14
    +    (assert-true uid)
    
    15
    +    (assert-true user-info)
    
    16
    +    (let ((info-dir (unix:user-info-dir user-info))
    
    17
    +          (info-name (unix:user-info-name user-info))
    
    18
    +          (expected-home-pathname (pathname
    
    19
    +                             (concatenate 'string info-dir "/")))
    
    20
    +          (home-pathname (unix:unix-get-user-homedir user-name)))
    
    21
    +      (assert-true info-dir)
    
    22
    +      (assert-true info-name)
    
    23
    +
    
    24
    +      (assert-equal home-pathname expected-home-pathname))))