unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] posix.test: portability tweaks
@ 2023-01-28  9:58 Omar Polo
  0 siblings, 0 replies; only message in thread
From: Omar Polo @ 2023-01-28  9:58 UTC (permalink / raw)
  To: guile-devel

Hello,

These are some tweaks for posix.test so that now it fully passes on
OpenBSD.  In order:

 - wc(1) may pad its output:

	% echo ">$(seq 2 | wc -w)<"
	>       2<

 - using "seq 3" is more portable than assuming /proc.  seq(1) may not
   be there (on OpenBSD appeared only in 7.1) but it's still better
   than /proc.  Maybe "echo 1 2 3" could be an alternative.

 - fix the crypt(3) invocation.  It failed with EINVAL on OpenBSD,
   here I'm stoling the example one from the crypt(3) manpage.

I've only tested these changes on OpenBSD but, with the exception of
the third, I'm sure they still pass (or allow the tests to pass) on
other unices as well :)

From b47f74cdb2baee8f6fdf40576a7d5bf9ff90aaee Mon Sep 17 00:00:00 2001
From: Omar Polo <op@omarpolo.com>
Date: Sat, 28 Jan 2023 09:46:02 +0000
Subject: [PATCH] posix.test: portability tweaks

 - wc(1) may pad the result with blanks so trim its output
 - use "seq 3" rather than assuming /proc is available
 - fix nonsensical crypt(3) invocation, use example from OpenBSD manpage
---
 test-suite/tests/posix.test | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test
index f20e04453..419bc5086 100644
--- a/test-suite/tests/posix.test
+++ b/test-suite/tests/posix.test
@@ -416,7 +416,7 @@
       (display "Hello world.\n" (cdr a+b))
       (close-port (cdr a+b))
 
-      (let ((str (get-string-all (car c+d))))
+      (let ((str (string-trim (get-string-all (car c+d)))))
         (close-port (car c+d))
         (waitpid pid)
         str)))
@@ -433,18 +433,16 @@
         (waitpid pid)
         str)))
 
-  (pass-if-equal "ls /proc/self/fd"
-      "0\n1\n2\n3\n"                     ;fourth FD is for /proc/self/fd
-    (if (file-exists? "/proc/self/fd")   ;Linux
-        (let* ((input+output (pipe))
-               (pid (spawn "ls" '("ls" "/proc/self/fd")
-                           #:output (cdr input+output))))
-          (close-port (cdr input+output))
-          (let ((str (get-string-all (car input+output))))
-            (close-port (car input+output))
-            (waitpid pid)
-            str))
-        (throw 'unresolved)))
+  (pass-if-equal "seq 3"
+      "1\n2\n3\n"
+    (let* ((input+output (pipe))
+           (pid (spawn "seq" '("seq" "3")
+                       #:output (cdr input+output))))
+      (close-port (cdr input+output))
+      (let ((str (get-string-all (car input+output))))
+        (close-port (car input+output))
+        (waitpid pid)
+        str)))
 
   (pass-if-equal "file not found"
       ENOENT
@@ -464,7 +462,8 @@
   (pass-if "basic usage"
     (if (not (defined? 'crypt))
         (throw 'unsupported)
-        (string? (crypt "pass" "abcdefg"))))
+        (string? (crypt "OrpheanBeholderScryDoubt"
+                        "$2b$12$FPWWO2RJ3CK4FINTw0Hi8OiPKJcX653gzSS.jqltHFMxyDmmQ0Hqq"))))
 
   (pass-if "crypt invalid salt on glibc"
     (begin
-- 
2.39.0




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-28  9:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-28  9:58 [PATCH] posix.test: portability tweaks Omar Polo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).